def __init__(self, ip_addr, sn_types=[], device_types=[], required_services=[]): # pylint: disable-msg=W0102 """Initialize the service. Arguments: ip_addr -- IP address for listening services. sn_types -- list of device and/or service types to look for in UPnP notifications and responses; other types will be ignored. "upnp:rootdevice" is automatically tracked, and should not be in this list. device_types -- list of interesting device types, used to filter out devices based on their "deviceType" attribute. An empty list means that all types are interesting. required_services -- if non-empty, list of services that the device must have for it to be considered """ MultiService.__init__(self) self._builders = {} self._devices = {} self._ignored = [] self._sn_types = ['upnp:rootdevice'] + sn_types self._dev_types = device_types self._req_services = required_services self._ip_addr = ip_addr # create the UPnP listener service UpnpService(self._datagram_handler, ip_addr).setServiceParent(self) # create the periodic M-SEARCH request service msearch = MSearchRequest(self._datagram_handler) TimerService(DISCOVERY_INTERVAL, self._msearch_discover, msearch).setServiceParent(self)
def __init__(self, apserver, name=None, host="0.0.0.0", port=22555, index=-1, device_id=None): MultiService.__init__(self) self.apserver = IAirPlayServer(apserver) if device_id: self.deviceid = device_id else: macstr = "%012X" % uuid.getnode() self.deviceid = ''.join("%s:" % macstr[i:i + 2] for i in range(0, len(macstr), 2))[:-1] # 0x77 instead of 0x07 in order to support AirPlay from ordinary apps; # also means that the body for play will be a binary plist. self.features = 0x77 self.model = "AppleTV2,1" # create TCP server TCPServer(port, self.create_site(), 100, interface=host).setServiceParent(self) # create avahi service if (name is None): name = "Airplay Service on " + platform.node() zconf = ZeroconfService(name, port=port, stype="_airplay._tcp", text=["deviceid=" + self.deviceid, "features=" + hex(self.features), "model=" + self.model], index=index) zconf.setServiceParent(self) # for logging self.name_ = name self.host = host self.port = port
def __init__(self, settings=None, channel=None): MultiService.__init__(self) # Make channel object from application settings configuration object self.setupChannel(channel=channel) # Shortcut to global settings self.config = settings if not 'port' in self.config['grafana']: self.config['grafana']['port'] = '3000' name = self.__class__.__name__ log.info('Starting GrafanaManager "{}". grafana={}:{}'.format( name, self.config['grafana']['host'], self.config['grafana']['port'])) # Initialize key cache # Utility functions for remembering whether the dashboard has been created already. # This is important as we would otherwise talk to Grafana for each ingress measurement (on each hit). self.keycache = KeyCache() # Boot further child services self.boot_workers() # Connect to Grafana API self.connect()
def __init__(self, shared_path, server_name, server_path, jar_file=None): MultiService.__init__(self) self.shared_path = shared_path self.server_name = server_name self.server_path = server_path self.jar_file = jar_file self.players = set()
def __init__(self, config_file): MultiService.__init__(self) self.config_file = SafeConfigParser() self.config_file.readfp(open(config_file)) self.config = None
def __init__( self, dataStoreDirectory, subServiceFactory, dsnUser=None, testMode=False, reactor=None, ): """ Initialize a L{OracleService} pointed at a data store directory. @param dataStoreDirectory: the directory to @type dataStoreDirectory: L{twext.python.filepath.CachingFilePath} @param subServiceFactory: a 1-arg callable that will be called with a 1-arg callable which returns a DB-API cursor. @type subServiceFactory: C{callable} """ MultiService.__init__(self) self.subServiceFactory = subServiceFactory self.dataStoreDirectory = dataStoreDirectory self.workingDir = self.dataStoreDirectory.child("working") self.dsnUser = dsnUser self.testMode = testMode self._reactor = reactor
def __init__(self, kz_client, interval, partitioner_path, buckets, time_boundary, log, got_buckets, clock=None): """ :param log: a bound log :param kz_client: txKazoo client :param partitioner_path: ZooKeeper path, used for partitioning :param buckets: iterable of buckets to distribute between nodes. Ideally there should be at least as many elements as nodes taking part in this partitioner. This should be a sequence of str. :param time_boundary: time to wait for partitioning to stabilize. :param got_buckets: Callable which will be called with a list of buckets when buckets have been allocated to this node. :param clock: clock to use for checking the buckets on an interval. """ MultiService.__init__(self) self.kz_client = kz_client self.partitioner_path = partitioner_path self.buckets = buckets self.log = log self.got_buckets = got_buckets self.time_boundary = time_boundary ts = TimerService(interval, self.check_partition) ts.setServiceParent(self) ts.clock = clock self._old_buckets = []
def __init__(self, parser): MultiService.__init__(self) NamedComponentized.__init__(self, parser.parse_args().game) if not self.config.verbose: HTTPClientFactory.noisy = False registerGlobal(self, IClient) self.addService(IWebWorld(self))
def __init__(self): MultiService.__init__(self) # Init shared storage which is used to share information about server # to the ouside world self.shared_storage = get_storage() # Init pilots service from commander.service.pilots import PilotService self.pilots = PilotService() self.pilots.setServiceParent(self) # Init objects service from commander.service.objects import ObjectsService self.objects = ObjectsService() self.objects.setServiceParent(self) # Init missions service with log watcher from commander.service.missions import MissionService log_watcher = LogWatchingService(settings.IL2_EVENTS_LOG_PATH) self.missions = MissionService(log_watcher) self.log_parser = EventLogParser( (self.pilots, self.objects, self.missions, )) log_watcher.set_parser(self.log_parser) self.missions.setServiceParent(self) # Init console and DeviceLink parsers self.console_parser = ConsoleParser((self.pilots, self.missions, )) self.dl_parser = DeviceLinkParser()
def __init__(self): MultiService.__init__(self) # Init pilots service -------------------------------------------------- from minic.service.pilots import PilotsService pilots = PilotsService() pilots.setServiceParent(self) # Init objects service ------------------------------------------------- from minic.service.objects import ObjectsService objects = ObjectsService() objects.setServiceParent(self) # Init missions service ------------------------------------------------ from minic.service.missions import MissionsService log_watcher = LogWatchingService() missions = MissionsService(log_watcher) log_parser = EventLogParser((pilots, objects, missions, )) log_watcher.set_parser(log_parser) missions.setServiceParent(self) # Init console and DeviceLink parsers ---------------------------------- console_parser = ConsoleParser((pilots, missions, )) device_link_parser = DeviceLinkParser() log_parser = EventLogParser((pilots, objects, missions, )) # Group parsers and services ------------------------------------------- self.parsers = namedtuple( 'commander_parsers', ['console', 'device_link', 'log'])( console_parser, device_link_parser, log_parser) self.services = namedtuple( 'commander_services', ['pilots', 'objects', 'missions'])( pilots, objects, missions)
def __init__(self, config=None): MultiService.__init__(self) self.config = config # Create a tasks queue self.tasks = Tasks() self.tasks.setServiceParent(self)
def __init__(self, options): MultiService.__init__(self) self.options = options self.config = {} self.common_config = {} self.modules = [] self.fail = False
def __init__(self, config): MultiService.__init__(self) import os from bouser.utils import safe_traverse from twisted.internet import reactor from twisted.application import strports from bouser.web.resource import DefaultRootResource from bouser.web.site import BouserSite from bouser.proxied_logger import proxiedLogFormatter root_resource = DefaultRootResource() current_dir = os.path.dirname(__file__) site = BouserSite( root_resource, static_path=safe_traverse(config, 'static-path', default=os.path.join(current_dir, 'static')), template_path=safe_traverse(config, 'template-path', default=os.path.join(current_dir, 'templates')), logFormatter=proxiedLogFormatter) description = config.get('strport', 'tcp:%s:interface=%s' % ( config.get('port', 5000), config.get('host', '127.0.0.1') )) self.cors_domain = config.get('cors-domain', 'http://127.0.0.1:5000/') allowed_domains = set(filter(None, config.get('allowed-domains', '').replace(',', ' ').split(' '))) self.allowed_domains = set(allowed_domains) | {self.cors_domain} service = strports.service(description, site, reactor=reactor) service.setServiceParent(self) self.root_resource = root_resource self.site = site self.service = service
def __init__(self, ssl_cert, ssl_key, ssl_cert_chain, ssl_port, dest_host, dest_port, server_name, status_port): """ Create a rageServerService. @param ssl_cert: the certificate text. @param ssl_key: the key text. @param ssl_port: the port to listen on with ssl. @param dest_host: destination hostname. @param dest_port: destination port. @param server_name: name of this server. """ MultiService.__init__(self) self.heartbeat_writer = None if server_name is None: server_name = "anonymous_instance" self.server_name = server_name self.factory = SSLProxyFactory(ssl_port, dest_host, dest_port, self.server_name) ssl_context_factory = ProxyContextFactory(ssl_cert, ssl_key, ssl_cert_chain) self.ssl_service = SSLServer(ssl_port, self.factory, ssl_context_factory) self.ssl_service.setName("SSL") self.ssl_service.setServiceParent(self) # setup the status service self.status_service = create_status_service(self.factory, status_port) self.status_service.setServiceParent(self) # disable ssl compression if config.ssl_proxy.disable_ssl_compression: disable_ssl_compression(logger)
def __init__(self): MultiService.__init__(self) # Start up our AMP RPC. self.amp = TCPServer(25600, ConsoleRPCFactory(self)) MultiService.addService(self, self.amp) self.configure_services(configuration)
def __init__(self, host, port, password, hub, session_store): MultiService.__init__(self) self.host = host self.port = port self.password = password self.hub = hub self.session_store = session_store self.die = False
def __init__(self, reactor): MultiService.__init__(self) self._deployment_state = DeploymentState() timer = TimerService(1, self._wipe_expired) timer.clock = reactor timer.setServiceParent(self) self._information_wipers = pmap() self._clock = reactor
def __init__(self): MultiService.__init__(self) self.config = read_configuration() self.factorylist = list() self.irc = False self.ircbots = list() self.configure_services()
def __init__(self): MultiService.__init__(self) convergence_loop = build_convergence_loop_fsm( self.reactor, self.deployer ) self.logger = convergence_loop.logger self.cluster_status = build_cluster_status_fsm(convergence_loop) self.factory = ReconnectingClientFactory.forProtocol( lambda: AgentAMP(self))
def __init__(self, name, twirc, token): MultiService.__init__(self) self.name = name self.twirc = twirc self.token = token self.tagCounter = 0 self.tweets = {} self.tweetsByID = {} self.stream = None self.settings = twirc.channelSettings.setdefault(name, {})
def __init__(self, context_factory): """ :param context_factory: TLS context factory for the AMP client. """ MultiService.__init__(self) convergence_loop = build_convergence_loop_fsm(self.reactor, self.deployer) self.logger = convergence_loop.logger self.cluster_status = build_cluster_status_fsm(convergence_loop) self.reconnecting_factory = ReconnectingClientFactory.forProtocol(lambda: AgentAMP(self.reactor, self)) self.factory = TLSMemoryBIOFactory(context_factory, True, self.reconnecting_factory)
class Service(MultiService): def __init__(self, **options): basePort = 18710 MultiService.__init__(self) sCtx = OpenSSLContextFactoryFactory.getFactory('fesl.ea.com') sFact = Mercs2LoginFactory() #sFact = makeTLSFwdFactory('fesl.fwdCli', 'fesl.fwdSer')('mercs2-pc.fesl.ea.com', basePort) self.addService(SSLServer(basePort, sFact, sCtx)) sFact = Mercs2TheaterFactory() #sFact = makeTCPFwdFactory('theater.fwdCli', 'theater.fwdSer')('mercs2-pc.theater.ea.com', basePort+5)
def __init__(self, reactor, path): """ :param reactor: Reactor to use for thread pool. :param FilePath path: Directory where desired deployment will be persisted. """ MultiService.__init__(self) self._path = path self._change_callbacks = [] LeaseService(reactor, self).setServiceParent(self)
def __init__(self, path, managers): MultiService.__init__(self) self.path = path self.managers = managers self.servers = set() self.session_store = SessionStore(path, self) for signal in self.signals: self.wrapSignal(signal) for host, port, password in managers: self.add_server(host, port, password)
def __init__(self): MultiService.__init__(self) # Start up our AMP RPC. self.amp = TCPServer(25601, ConsoleRPCFactory(self)) MultiService.addService(self, self.amp) self.factorylist = list() self.irc = False self.ircbots = list() self.configure_services(configuration)
def __init__(self, frame): MultiService.__init__(self) self._frame = frame self._blank = urwid.SolidFill() self._windows = None self._nwindows = 0 self._curr = None self._nextwid = 1 self._focus = None self._windowlist = urwid.ListBox(self) urwid.WidgetWrap.__init__(self, self._windowlist)
class Burnout08Service(MultiService): def __init__(self, addresses=None): MultiService.__init__(self) ctx = OpenSSLContextFactoryFactory.getFactory('fesl.ea.com') fact = Burnout08LoginServerFactory() #fact = makeTLSFwdFactory('fesl.fwdCli', 'fesl.fwdSer', fC, fS)(*address) self.addService(SSLServer(addresses[0][1], fact, ctx)) fact = Burnout08TheaterServerFactory() #fact = makeTCPFwdFactory('theater.fwdCli', 'theater.fwdSer', fwdDRC, fwdDRS)(address[0], address[1]+1)
def __init__(self, addresses=None): MultiService.__init__(self) ports = dict(addresses) name = 'prodgos28.ea.com' sCtx = OpenSSLContextFactoryFactory.getFactory(name) address = (name, ports[name]) #sFact = RedAlert3LoginFactory() sFact = makeTLSFwdFactory('login.cnc4.client', 'login.cnc4.server', fwd, fwd)(*address) self.addService(SSLServer(address[1], sFact, sCtx))
def __init__(self, channel=None): MultiService.__init__(self) self.channel = channel or Bunch(realm=None, subscriptions=[]) self.name = u'service-fb-' + self.channel.get('realm', unicode(id(self))) # A bunch of locks for constraining concurrent # make processes on the same directory. self.locks = defaultdict(threading.RLock)
def __init__(self, path, managers): MultiService.__init__(self) self.path = path self.managers = managers self.servers = set() self.session_store = dv.SessionStore(path, self) for signal in self.signals: self.wrapSignal(signal) for host, port, password in managers: x = DataVaultConnector(host, port, password, self, self.path, self.session_store) x.setServiceParent(self)
def __init__(self): MultiService.__init__(self)
def __init__(self, reactor, config): MultiService.__init__(self) self._config = config self._reactor = reactor
def __attrs_post_init__(self): MultiService.__init__(self)
def __init__(self, name, host, port): MultiService.__init__(self) self.name = name self.host = host self.port = port
def __init__(self, log_path=None): MultiService.__init__(self) self.evt_log = EventLoggingService(log_path) self.user_command_id = 0 self.set_server_info() self._init_children()
def __init__(self, settings=None): MultiService.__init__(self) self.settings = settings
def __init__( self, dataStoreDirectory, subServiceFactory, schema, resetSchema=False, databaseName="subpostgres", clusterName="cluster", logFile="postgres.log", logDirectory="", socketDir="", listenAddresses=[], sharedBuffers=30, maxConnections=20, options=[], testMode=False, uid=None, gid=None, spawnedDBUser="******", importFileName=None, pgCtl="pg_ctl", initDB="initdb", reactor=None, ): """ Initialize a L{PostgresService} pointed at a data store directory. @param dataStoreDirectory: the directory to @type dataStoreDirectory: L{twext.python.filepath.CachingFilePath} @param subServiceFactory: a 1-arg callable that will be called with a 1-arg callable which returns a DB-API cursor. @type subServiceFactory: C{callable} @param spawnedDBUser: the postgres role @type spawnedDBUser: C{str} @param importFileName: path to SQL file containing previous data to import @type importFileName: C{str} """ # FIXME: By default there is very little (4MB) shared memory available, # so at the moment I am lowering these postgres config options to allow # multiple servers to run. We might want to look into raising # kern.sysv.shmmax. # See: http://www.postgresql.org/docs/8.4/static/kernel-resources.html MultiService.__init__(self) self.subServiceFactory = subServiceFactory self.dataStoreDirectory = dataStoreDirectory self.workingDir = self.dataStoreDirectory.child("working") self.resetSchema = resetSchema # In order to delay a shutdown until database initialization has # completed, our stopService( ) examines the delayedShutdown flag. # If True, we wait on the shutdownDeferred to fire before proceeding. # The deferred gets fired once database init is complete. self.delayedShutdown = False # set to True when in critical code self.shutdownDeferred = None # the actual deferred # Options from config self.databaseName = databaseName self.clusterName = clusterName # Make logFile absolute in case the working directory of postgres is # elsewhere: self.logFile = os.path.abspath(logFile) if logDirectory: self.logDirectory = os.path.abspath(logDirectory) else: self.logDirectory = "" # Always use our own configured socket dir in case the built-in # postgres tries to use a directory we don't have permissions for if not socketDir: # Socket directory was not specified, so come up with one # in /tmp and based on a hash of the data store directory digest = md5(dataStoreDirectory.path).hexdigest() socketDir = "/tmp/ccs_postgres_" + digest self.socketDir = CachingFilePath(socketDir) if listenAddresses: if ":" in listenAddresses[0]: self.host, self.port = listenAddresses[0].split(":") else: self.host, self.port = (listenAddresses[0], None) self.listenAddresses = [ addr.split(":")[0] for addr in listenAddresses ] else: self.host = self.socketDir.path self.port = None self.listenAddresses = [] self.sharedBuffers = sharedBuffers if not testMode else 16 self.maxConnections = maxConnections if not testMode else 8 self.options = options self.uid = uid self.gid = gid self.spawnedDBUser = spawnedDBUser self.importFileName = importFileName self.schema = schema self.monitor = None self.openConnections = [] self._pgCtl = pgCtl self._initdb = initDB self._reactor = reactor self._postgresPid = None
def __init__(self, channel=None, preset='standard'): self.channel = channel or Bunch() self.preset = preset MultiService.__init__(self)
def __init__(self, options: Options) -> None: self._options = options MultiService.__init__(self)
def __init__(self, reactor): MultiService.__init__(self) self._reactor = reactor self._route_mapping = freeze({})
def __init__(self, main_loop, session_bus): MultiService.__init__(self) self.main_loop = main_loop self.session_bus = session_bus
def __init__(self, name, host, port, tls=C.MANAGER_TLS): MultiService.__init__(self) self.name = name self.host = host self.port = port self.tls = tls
def __init__(self, basedir, configFileName): MultiService.__init__(self) self._basedir = basedir self._configFileName = configFileName self._config = None # Configuration dictionary
def __init__(self, gpg_pub_key): MultiService.__init__(self) self.gpg_key = gpg_pub_key
def __init__(self): MultiService.__init__(self) convergence_loop = build_convergence_loop_fsm(self.deployer) self.cluster_status = build_cluster_status_fsm(convergence_loop) self.factory = ReconnectingClientFactory.forProtocol( lambda: AgentAMP(self))
def __init__(self, name=None): MultiService.__init__(self) self.name = name