當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。