当前位置: 首页>>代码示例>>Python>>正文


Python service.MultiService类代码示例

本文整理汇总了Python中twisted.application.service.MultiService的典型用法代码示例。如果您正苦于以下问题:Python MultiService类的具体用法?Python MultiService怎么用?Python MultiService使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了MultiService类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

 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))
开发者ID:isnok,项目名称:mpmf,代码行数:7,代码来源:Client.py

示例2: __init__

    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)
开发者ID:fredrikaubert,项目名称:airpnp,代码行数:32,代码来源:device_discovery.py

示例3: __init__

    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)
开发者ID:IL2HorusTeam,项目名称:minic,代码行数:33,代码来源:__init__.py

示例4: __init__

    def __init__(self, config=None):
        MultiService.__init__(self)
        self.config = config

        # Create a tasks queue
        self.tasks = Tasks()
        self.tasks.setServiceParent(self)
开发者ID:pombredanne,项目名称:boiler,代码行数:7,代码来源:boiler.py

示例5: __init__

    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
开发者ID:fredrikaubert,项目名称:airpnp,代码行数:31,代码来源:AirPlayService.py

示例6: makeService

 def makeService(self, options):
     if not os.path.isfile(options['config']):
         raise ConfigNotFoundException()
     
     config = yaml.load(open(options['config']), OrderedDictYAMLLoader)
     
     self.processProtocol = processProtocol = protocol.ProcessProtocol()
     reactor.spawnProcess(processProtocol, config['config']['udpxy'],
         args=[config['config']['udpxy'],
               '-T',
               '-m', config['config']['iptv_if'],
               '-p', str(config['config']['udpxy_port']),
               '-a', '127.0.0.1',
               '-c', '10'])
     
     from tidaltv.server import TidalTVServer
     tidaltvserver = TidalTVServer(configfile=config, use_ssl=os.path.isfile(config['config']['ssl']))
     
     if config['config']['broadcast_keepalive']:
         from tidaltv.broadcast import KeepAliver
         keepaliver = KeepAliver(config, tidaltvserver.channel_watchers)
     
     site = server.Site(tidaltvserver)
     ms = MultiService()
     tidaltvport = int(config['config']['port'])
     if os.path.isfile(config['config']['ssl']):
         from OpenSSL import SSL
         ms.addService(internet.SSLServer(tidaltvport, site,
                                          ServerContextFactory(config['config']['ssl'])))
     else:
         ms.addService(internet.TCPServer(tidaltvport, site))
     return ms
开发者ID:pombredanne,项目名称:tidalstream-livetv,代码行数:32,代码来源:tidaltvserver.py

示例7: __init__

 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()
开发者ID:runfalk,项目名称:mark2,代码行数:7,代码来源:manager.py

示例8: __init__

 def __init__(self, options):
     MultiService.__init__(self)
     self.options = options
     self.config = {}
     self.common_config = {}
     self.modules = []
     self.fail = False
开发者ID:hitsl,项目名称:bouser,代码行数:7,代码来源:service.py

示例9: __init__

    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)
开发者ID:cloudfleet,项目名称:filesync-server,代码行数:30,代码来源:ssl_proxy.py

示例10: startService

    def startService(self):
        # create WebSocket echo service and make it a child of our app service
        svc = EchoService(self.port)
        svc.setName("EchoService")
        svc.setServiceParent(self)

        MultiService.startService(self)
开发者ID:Anggi-Permana-Harianja,项目名称:autobahn-python,代码行数:7,代码来源:main.py

示例11: stopService

    def stopService(self):
        """
        Stop all child services, then stop the subprocess, if it's running.
        """

        if self.delayedShutdown:
            # We're still in the process of initializing the database, so
            # delay shutdown until the shutdownDeferred fires.
            d = self.shutdownDeferred = Deferred()
            d.addCallback(lambda ignored: MultiService.stopService(self))
        else:
            d = MultiService.stopService(self)

        def superStopped(result):
            # If pg_ctl's startup wasn't successful, don't bother to stop the
            # database.  (This also happens in command-line tools.)
            if self.shouldStopDatabase:
                monitor = PostgresMonitor()
                args = [
                    self._pgCtl, "stop",
                    "--log={}".format(self.logFile),
                ]
                log.info("Requesting postgres stop via: {args}", args=args)
                self.reactor.spawnProcess(
                    monitor, self._pgCtl,
                    args,
                    env=self.env, path=self.workingDir.path,
                    uid=self.uid, gid=self.gid,
                )
                return monitor.completionDeferred
        return d.addCallback(superStopped)
开发者ID:red-hood,项目名称:calendarserver,代码行数:31,代码来源:subpostgres.py

示例12: setUp

class TestServicesBase:

    run_tests_with = AsynchronousDeferredRunTest.make_factory(timeout=5)

    def setUp(self):
        super(TestServicesBase, self).setUp()
        self.observers = theLogPublisher.observers[:]
        self.services = MultiService()
        self.services.privilegedStartService()
        self.services.startService()

    def tearDown(self):
        super(TestServicesBase, self).tearDown()
        d = self.services.stopService()
        # The log file must be read in right after services have stopped,
        # before the temporary directory where the log lives is removed.
        d.addBoth(lambda ignore: self.addDetailFromLog())
        d.addBoth(lambda ignore: self.assertNoObserversLeftBehind())
        return d

    def addDetailFromLog(self):
        content = content_from_file(self.log_filename, buffer_now=True)
        self.addDetail("log", content)

    def assertNoObserversLeftBehind(self):
        self.assertEqual(self.observers, theLogPublisher.observers)
开发者ID:cloudbase,项目名称:maas,代码行数:26,代码来源:test_services.py

示例13: __init__

    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
开发者ID:eventable,项目名称:CalendarServer,代码行数:26,代码来源:suboracle.py

示例14: startService

 def startService(self):
     MultiService.startService(self)
     clusterDir = self.dataStoreDirectory.child("cluster")
     workingDir = self.dataStoreDirectory.child("working")
     env = self.env = os.environ.copy()
     env.update(PGDATA=clusterDir.path,
                PGHOST=self.socketDir.path)
     initdb = which("initdb")[0]
     if not self.socketDir.isdir():
         self.socketDir.createDirectory()
     if self.uid and self.gid:
         os.chown(self.socketDir.path, self.uid, self.gid)
     if self.dataStoreDirectory.isdir():
         self.startDatabase()
     else:
         self.dataStoreDirectory.createDirectory()
         workingDir.createDirectory()
         if self.uid and self.gid:
             os.chown(self.dataStoreDirectory.path, self.uid, self.gid)
             os.chown(workingDir.path, self.uid, self.gid)
         dbInited = Deferred()
         reactor.spawnProcess(
             CapturingProcessProtocol(dbInited, None),
             initdb, [initdb], env, workingDir.path,
             uid=self.uid, gid=self.gid,
         )
         def doCreate(result):
             self.startDatabase()
         dbInited.addCallback(doCreate)
开发者ID:svn2github,项目名称:calendarserver-raw,代码行数:29,代码来源:subpostgres.py

示例15: startService

 def startService(self):
     global configurations, expectations
     print "Loaded configurations: " + str(configurations)
     reload(sys)
     sys.setdefaultencoding('utf8')
     Expectations.display(expectations)
     MultiService.startService(self)
开发者ID:varunmulloli,项目名称:dumbserver,代码行数:7,代码来源:dumbserver_plugin.py


注:本文中的twisted.application.service.MultiService类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。