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


Python service.Service方法代码示例

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


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

示例1: privilegedStartService

# 需要导入模块: from twisted.application import service [as 别名]
# 或者: from twisted.application.service import Service [as 别名]
def privilegedStartService(self):
        """
        Start listening on the endpoint.
        """
        service.Service.privilegedStartService(self)
        self._waitingForPort = self.endpoint.listen(self.factory)
        raisedNow = []
        def handleIt(err):
            if self._raiseSynchronously:
                raisedNow.append(err)
            elif not err.check(CancelledError):
                log.err(err)
        self._waitingForPort.addErrback(handleIt)
        if raisedNow:
            raisedNow[0].raiseException()
        self._raiseSynchronously = False 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:18,代码来源:internet.py

示例2: test_everythingThere

# 需要导入模块: from twisted.application import service [as 别名]
# 或者: from twisted.application.service import Service [as 别名]
def test_everythingThere(self):
        """
        L{twisted.application.internet} dynamically defines a set of
        L{service.Service} subclasses that in general have corresponding
        reactor.listenXXX or reactor.connectXXX calls.
        """
        trans = 'TCP UNIX SSL UDP UNIXDatagram Multicast'.split()
        for tran in trans[:]:
            if not getattr(interfaces, "IReactor" + tran)(reactor, None):
                trans.remove(tran)
        for tran in trans:
            for side in 'Server Client'.split():
                if tran == "Multicast" and side == "Client":
                    continue
                if tran == "UDP" and side == "Client":
                    continue
                self.assertTrue(hasattr(internet, tran + side))
                method = getattr(internet, tran + side).method
                prefix = {'Server': 'listen', 'Client': 'connect'}[side]
                self.assertTrue(hasattr(reactor, prefix + method) or
                        (prefix == "connect" and method == "UDP"))
                o = getattr(internet, tran + side)()
                self.assertEqual(service.IService(o), o) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:25,代码来源:test_application.py

示例3: test_service_factory

# 需要导入模块: from twisted.application import service [as 别名]
# 或者: from twisted.application.service import Service [as 别名]
def test_service_factory(self):
        """
        ``VolumeScript._create_volume_service`` uses
        ``VolumeScript._service_factory`` to create a ``VolumeService`` (or
        whatever else that hook decides to create).
        """
        expected = Service()
        script = VolumeScript(object())
        self.patch(
            VolumeScript, "_service_factory",
            staticmethod(lambda config_path, pool, reactor: expected))

        options = VolumeOptions()
        options.parseOptions([])
        service = script._create_volume_service(
            object(), object(), options)
        self.assertIs(expected, service) 
开发者ID:ClusterHQ,项目名称:flocker,代码行数:19,代码来源:test_service.py

示例4: test_main_deferred_fires_after_service_stop

# 需要导入模块: from twisted.application import service [as 别名]
# 或者: from twisted.application.service import Service [as 别名]
def test_main_deferred_fires_after_service_stop(self):
        """
        The ``Deferred`` returned by ``AgentScript.main`` doesn't fire
        until after the ``Deferred`` returned by the ``stopService`` method of
        the service created by ``service_factory``.
        """
        shutdown_deferred = Deferred()

        class SlowShutdown(Service):
            def stopService(self):
                return shutdown_deferred

        service = SlowShutdown()
        agent = AgentScript(
            service_factory=lambda reactor, options: service
        )
        stop_deferred = agent.main(self.reactor, self.options)
        self.reactor.fireSystemEvent("shutdown")
        self.assertNoResult(stop_deferred)
        shutdown_deferred.callback(None)
        self.assertIs(None, self.successResultOf(stop_deferred)) 
开发者ID:ClusterHQ,项目名称:flocker,代码行数:23,代码来源:test_script.py

示例5: assertErrorWritten

# 需要导入模块: from twisted.application import service [as 别名]
# 或者: from twisted.application.service import Service [as 别名]
def assertErrorWritten(self, raised, reported):
        """
        Assert L{UnixApplicationRunner.postApplication} writes
        C{reported} to its status pipe if the service raises an
        exception whose message is C{raised}.
        """
        class FakeService(service.Service):

            def startService(self):
                raise RuntimeError(raised)

        errorService = FakeService()
        errorService.setServiceParent(self.runner.application)

        with AlternateReactor(FakeDaemonizingReactor()):
            self.assertRaises(RuntimeError, self.runner.postApplication)
        self.assertEqual(
            self.mockos.actions,
            [('chdir', '.'), ('umask', 0o077), ('fork', True), 'setsid',
             ('fork', True), ('write', -2, reported),
             ('unlink', 'twistd.pid')])
        self.assertEqual(self.mockos.closed, [-3, -2]) 
开发者ID:wistbean,项目名称:learn_python3_spider,代码行数:24,代码来源:test_twistd.py

示例6: startService

# 需要导入模块: from twisted.application import service [as 别名]
# 或者: from twisted.application.service import Service [as 别名]
def startService(self):
        service.Service.startService(self)
        factory = redis.SubscriberFactory()
        factory.protocol = MasterProtocol
        factory.continueTrying = True
        factory.db = self.db
        yield self.db.startService()
        yield reactor.connectTCP(config.REDIS_HOST, config.REDIS_PORT, factory)
        self.rc = yield factory.deferred
        yield self.rc.subscribe(self.channel)
        log.info('Subscribed to {channel}', channel=self.channel)
        self.lc = LoopingCall(self.checkNoData)
        self.nodata_check = self.lc.start(config.NODATA_CHECK_INTERVAL, now=True) 
开发者ID:moira-alert,项目名称:worker,代码行数:15,代码来源:master.py

示例7: __init__

# 需要导入模块: from twisted.application import service [as 别名]
# 或者: from twisted.application.service import Service [as 别名]
def __init__(self, basedir):
        service.Service.__init__(self)
        self._basedir = basedir 
开发者ID:leapcode,项目名称:bitmask-dev,代码行数:5,代码来源:mail_services.py

示例8: startService

# 需要导入模块: from twisted.application import service [as 别名]
# 或者: from twisted.application.service import Service [as 别名]
def startService(self):
        self.log.info('Starting Soledad Service')
        self._container = SoledadContainer(service=self)
        super(SoledadService, self).startService()

    # hooks 
开发者ID:leapcode,项目名称:bitmask-dev,代码行数:8,代码来源:mail_services.py

示例9: _hook_on_passphrase_entry

# 需要导入模块: from twisted.application import service [as 别名]
# 或者: from twisted.application.service import Service [as 别名]
def _hook_on_passphrase_entry(self, provider, **kw):
        if is_service_ready('mx', provider):
            userid = kw.get('username')
            password = kw.get('password')
            uuid = kw.get('uuid')
            container = self._container
            self.log.debug('On_passphrase_entry: '
                           'New Soledad Instance: %s' % userid)
            if not container.get_instance(userid):
                container.add_instance(userid, password, uuid=uuid, token=None)
        else:
            self.log.debug('Service MX is not ready...') 
开发者ID:leapcode,项目名称:bitmask-dev,代码行数:14,代码来源:mail_services.py

示例10: stopService

# 需要导入模块: from twisted.application import service [as 别名]
# 或者: from twisted.application.service import Service [as 别名]
def stopService(self):
        self.log.info('Stopping IMAP Service')
        if self._port:
            self._port.stopListening()
            self._port = None
        if self._factory:
            self._factory.doStop()
        super(IMAPService, self).stopService() 
开发者ID:leapcode,项目名称:bitmask-dev,代码行数:10,代码来源:mail_services.py

示例11: startInstance

# 需要导入模块: from twisted.application import service [as 别名]
# 或者: from twisted.application.service import Service [as 别名]
def startInstance(self, userid):
        """returns: a deferred"""
        self._set_status(userid, "starting")
        soledad = self._mail.get_soledad_session(userid)
        keymanager = self._mail.get_keymanager_session(userid)

        self.log.info('Setting up Incoming Mail Service for %s' % userid)
        return self._start_incoming_mail_instance(
            keymanager, soledad, userid) 
开发者ID:leapcode,项目名称:bitmask-dev,代码行数:11,代码来源:mail_services.py

示例12: startService

# 需要导入模块: from twisted.application import service [as 别名]
# 或者: from twisted.application.service import Service [as 别名]
def startService(self):
        zf = ZmqFactory()
        e = ZmqEndpoint(ZmqEndpointType.bind, ENDPOINT)

        self._conn = _DispatcherREPConnection(zf, e, self._core)
        reactor.callWhenRunning(self._conn.do_greet)
        service.Service.startService(self) 
开发者ID:leapcode,项目名称:bitmask-dev,代码行数:9,代码来源:_zmq.py

示例13: stopService

# 需要导入模块: from twisted.application import service [as 别名]
# 或者: from twisted.application.service import Service [as 别名]
def stopService(self):
        service.Service.stopService(self) 
开发者ID:leapcode,项目名称:bitmask-dev,代码行数:4,代码来源:_zmq.py

示例14: setupService

# 需要导入模块: from twisted.application import service [as 别名]
# 或者: from twisted.application.service import Service [as 别名]
def setupService(self):

        self.log(log.info, u'Bootstrapping')
        self.settings = self.parent.settings

        # Optionally register subsystem component as child service
        for subsystem in self.subsystems:
            if hasattr(self, subsystem):
                subsystem_service = getattr(self, subsystem)
                if isinstance(subsystem_service, Service):
                    log.info('Registering subsystem component "{subsystem}" as service', subsystem=subsystem)
                    self.registerService(subsystem_service)

        # Configure metrics to be collected each X seconds
        metrics_interval = int(self.channel.get('metrics_logger_interval', 60))
        self.metrics = Bunch(tx_count=0, starttime=time.time(), interval=metrics_interval)

        subscriptions = read_list(self.channel.mqtt_topics)
        self.mqtt_service = MqttAdapter(
            name          = u'mqtt-' + self.channel.realm,
            broker_host   = self.settings.mqtt.host,
            broker_port   = int(self.settings.mqtt.port),
            broker_username = self.settings.mqtt.username,
            broker_password = self.settings.mqtt.password,
            callback      = self.mqtt_receive,
            subscriptions = subscriptions)

        self.registerService(self.mqtt_service)

        self.influx = InfluxDBAdapter(settings = self.settings.influxdb)

        # Perform MQTT message processing using a different thread pool
        self.threadpool = ThreadPool()
        self.thimble = Thimble(reactor, self.threadpool, self, ["process_message"]) 
开发者ID:daq-tools,项目名称:kotori,代码行数:36,代码来源:mig.py

示例15: __getstate__

# 需要导入模块: from twisted.application import service [as 别名]
# 或者: from twisted.application.service import Service [as 别名]
def __getstate__(self):
        d = service.Service.__getstate__(self)
        for attr in self.volatile:
            if attr in d:
                del d[attr]
        return d 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:8,代码来源:internet.py


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