• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python service.MultiService类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: __init__

    def __init__(self, config_file):
        MultiService.__init__(self)

        self.config_file = SafeConfigParser()
        self.config_file.readfp(open(config_file))

        self.config = None
开发者ID:automatron,项目名称:automatron,代码行数:7,代码来源:controller.py


示例17: makeService

    def makeService(self, options):
        if options['data-dir'] != None:
            if not os.access(options['data-dir'], os.X_OK | os.W_OK):
                raise core.SmapException("Cannot access " + options['data-dir'])
            smapconf.SERVER['DataDir'] = options['data-dir']

        inst = loader.load(options['conf'])
        # override defaults with command-line args
        smapconf.SERVER.update(dict([(k.lower(), v) for (k, v) in
                                     options.iteritems() if v != None]))

        if 'SuggestThreadPool' in smapconf.SERVER:
            reactor.suggestThreadPoolSize(int(smapconf.SERVER['SuggestThreadPool']))

        inst.start()
        reactor.addSystemEventTrigger('before', 'shutdown', inst.stop)

        site = getSite(inst, docroot=smapconf.SERVER['docroot'])
        service = MultiService()

        # add HTTP and HTTPS servers to the twisted multiservice
        if 'port' in smapconf.SERVER:
            service.addService(internet.TCPServer(int(smapconf.SERVER['port']), site))
        if 'sslport' in smapconf.SERVER:
            service.addService(internet.SSLServer(int(smapconf.SERVER['sslport']), 
                                                  site, 
                                                  SslServerContextFactory(smapconf.SERVER)))
        return service
开发者ID:Alwnikrotikz,项目名称:smap-data,代码行数:28,代码来源:smap_plugin.py


示例18: __init__

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


示例19: __init__

    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()
开发者ID:Kamyhin,项目名称:il2ds-events-commander,代码行数:29,代码来源:__init__.py


示例20: __init__

    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
开发者ID:hitsl,项目名称:bouser,代码行数:34,代码来源:service.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python service.Service类代码示例发布时间:2022-05-27
下一篇:
Python service.loadApplication函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap