當前位置: 首頁>>代碼示例>>Python>>正文


Python error.ProcessTerminated方法代碼示例

本文整理匯總了Python中twisted.internet.error.ProcessTerminated方法的典型用法代碼示例。如果您正苦於以下問題:Python error.ProcessTerminated方法的具體用法?Python error.ProcessTerminated怎麽用?Python error.ProcessTerminated使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在twisted.internet.error的用法示例。


在下文中一共展示了error.ProcessTerminated方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: processExited

# 需要導入模塊: from twisted.internet import error [as 別名]
# 或者: from twisted.internet.error import ProcessTerminated [as 別名]
def processExited(self, failure):
        err = failure.trap(
            internet_error.ProcessDone, internet_error.ProcessTerminated)

        if err == internet_error.ProcessDone:
            pass

        elif err == internet_error.ProcessTerminated:
            self.failed = True
            self.errmsg = failure.value.exitCode
            if self.errmsg:
                self.log.debug('Process Exited, status %d' % (self.errmsg,))
            else:
                self.log.warn('%r' % failure.value)
        if IS_MAC:
            # TODO: need to exit properly!
            self.errmsg = None
        self.proto = None
        self._turn_state_off() 
開發者ID:leapcode,項目名稱:bitmask-dev,代碼行數:21,代碼來源:process.py

示例2: test_processAliasTimeout

# 需要導入模塊: from twisted.internet import error [as 別名]
# 或者: from twisted.internet.error import ProcessTerminated [as 別名]
def test_processAliasTimeout(self):
        """
        If the alias child process does not exit within a particular period of
        time, the L{Deferred} returned by L{MessageWrapper.eomReceived} should
        fail with L{ProcessAliasTimeout} and send the I{KILL} signal to the
        child process..
        """
        reactor = task.Clock()
        transport = StubProcess()
        proto = mail.alias.ProcessAliasProtocol()
        proto.makeConnection(transport)

        receiver = mail.alias.MessageWrapper(proto, None, reactor)
        d = receiver.eomReceived()
        reactor.advance(receiver.completionTimeout)
        def timedOut(ignored):
            self.assertEqual(transport.signals, ['KILL'])
            # Now that it has been killed, disconnect the protocol associated
            # with it.
            proto.processEnded(
                ProcessTerminated(self.signalStatus(signal.SIGKILL)))
        self.assertFailure(d, mail.alias.ProcessAliasTimeout)
        d.addCallback(timedOut)
        return d 
開發者ID:proxysh,項目名稱:Safejumper-for-Desktop,代碼行數:26,代碼來源:test_mail.py

示例3: test_wrapProcessProtocol_Protocol

# 需要導入模塊: from twisted.internet import error [as 別名]
# 或者: from twisted.internet.error import ProcessTerminated [as 別名]
def test_wrapProcessProtocol_Protocol(self):
        """
        L{wrapPRocessProtocol}, when passed a L{Protocol} should return
        something that follows the L{IProcessProtocol} interface, with
        connectionMade() mapping to connectionMade(), outReceived() mapping to
        dataReceived() and processEnded() mapping to connectionLost().
        """
        protocol = MockProtocol()
        protocol.transport = StubTransport()
        process_protocol = session.wrapProcessProtocol(protocol)
        process_protocol.connectionMade()
        process_protocol.outReceived(b'data')
        self.assertEqual(protocol.transport.buf, b'data~')
        process_protocol.processEnded(failure.Failure(
            error.ProcessTerminated(0, None, None)))
        protocol.reason.trap(error.ProcessTerminated) 
開發者ID:proxysh,項目名稱:Safejumper-for-Desktop,代碼行數:18,代碼來源:test_session.py

示例4: test_abnormalTermination

# 需要導入模塊: from twisted.internet import error [as 別名]
# 或者: from twisted.internet.error import ProcessTerminated [as 別名]
def test_abnormalTermination(self):
        """
        When a process terminates with a system exit code set to 1,
        C{processEnded} is called with a L{error.ProcessTerminated} error,
        the C{exitCode} attribute reflecting the system exit code.
        """
        d = defer.Deferred()
        p = TrivialProcessProtocol(d)
        reactor.spawnProcess(p, pyExe,
                             [pyExe, b'-c', b'import sys; sys.exit(1)'],
                             env=None, usePTY=self.usePTY)

        def check(ignored):
            p.reason.trap(error.ProcessTerminated)
            self.assertEqual(p.reason.value.exitCode, 1)
            self.assertIsNone(p.reason.value.signal)
        d.addCallback(check)
        return d 
開發者ID:proxysh,項目名稱:Safejumper-for-Desktop,代碼行數:20,代碼來源:test_process.py

示例5: is_process_running

# 需要導入模塊: from twisted.internet import error [as 別名]
# 或者: from twisted.internet.error import ProcessTerminated [as 別名]
def is_process_running(node, name):
    """
    Check if the process `name` is running on `node`.

    :param Node node: the node to check.
    :param bytes name: the name of the process to look for.
    :return Deferred[bool]: a deferred that will fire
        with whether at least one process named `name` is running
        on `node`.
    """
    # pidof will return the pid if the processes is
    # running else exit with status 1 which triggers the
    # errback chain.
    command = [b'pidof', b'-x', name]
    d = node.run_as_root(command)

    def not_existing(failure):
        failure.trap(ProcessTerminated)
        return False
    d.addCallbacks(lambda result: True, not_existing)
    return d 
開發者ID:ClusterHQ,項目名稱:flocker,代碼行數:23,代碼來源:testtools.py

示例6: test_processEndedWithExitSignalCoreDump

# 需要導入模塊: from twisted.internet import error [as 別名]
# 或者: from twisted.internet.error import ProcessTerminated [as 別名]
def test_processEndedWithExitSignalCoreDump(self):
        """
        When processEnded is called, if there is an exit signal in the reason
        it should be sent in an exit-signal message.  The connection should be
        closed.
        """
        self.pp.processEnded(
            Failure(ProcessTerminated(1,
                signal.SIGTERM, 1 << 7))) # 7th bit means core dumped
        self.assertRequestsEqual(
            [(b'exit-signal',
              common.NS(b'TERM') # signal name
              + b'\x01' # core dumped is true
              + common.NS(b'') # error message
              + common.NS(b''), # language tag
              False)])
        self.assertSessionClosed() 
開發者ID:wistbean,項目名稱:learn_python3_spider,代碼行數:19,代碼來源:test_session.py

示例7: test_process_ends_after_timeout

# 需要導入模塊: from twisted.internet import error [as 別名]
# 或者: from twisted.internet.error import ProcessTerminated [as 別名]
def test_process_ends_after_timeout(self):
        """
        If the process ends after the error checking timeout has passed
        C{result} will not be re-fired.
        """
        message = {"type": "shutdown", "reboot": False, "operation-id": 100}
        self.plugin.perform_shutdown(message)

        stash = []

        def restart_performed(ignore):
            self.assertEqual(stash, [])
            stash.append(True)

        [arguments] = self.process_factory.spawns
        protocol = arguments[0]
        protocol.result.addCallback(restart_performed)
        self.manager.reactor.advance(10)
        protocol.processEnded(Failure(ProcessTerminated(exitCode=1)))
        return protocol.result 
開發者ID:CanonicalLtd,項目名稱:landscape-client,代碼行數:22,代碼來源:test_shutdownmanager.py

示例8: test_prematureEndOfHeaders

# 需要導入模塊: from twisted.internet import error [as 別名]
# 或者: from twisted.internet.error import ProcessTerminated [as 別名]
def test_prematureEndOfHeaders(self):
        """
        If the process communicating with L{CGIProcessProtocol} ends before
        finishing writing out headers, the response has I{INTERNAL SERVER
        ERROR} as its status code.
        """
        request = DummyRequest([''])
        protocol = twcgi.CGIProcessProtocol(request)
        protocol.processEnded(failure.Failure(error.ProcessTerminated()))
        self.assertEqual(request.responseCode, INTERNAL_SERVER_ERROR) 
開發者ID:proxysh,項目名稱:Safejumper-for-Desktop,代碼行數:12,代碼來源:test_cgi.py

示例9: _getReason

# 需要導入模塊: from twisted.internet import error [as 別名]
# 或者: from twisted.internet.error import ProcessTerminated [as 別名]
def _getReason(self, status):
        if status == 0:
            return error.ProcessDone(status)
        return error.ProcessTerminated(status) 
開發者ID:proxysh,項目名稱:Safejumper-for-Desktop,代碼行數:6,代碼來源:_dumbwin32proc.py

示例10: _getReason

# 需要導入模塊: from twisted.internet import error [as 別名]
# 或者: from twisted.internet.error import ProcessTerminated [as 別名]
def _getReason(self, status):
        exitCode = sig = None
        if os.WIFEXITED(status):
            exitCode = os.WEXITSTATUS(status)
        else:
            sig = os.WTERMSIG(status)
        if exitCode or sig:
            return error.ProcessTerminated(exitCode, sig, status)
        return error.ProcessDone(status) 
開發者ID:proxysh,項目名稱:Safejumper-for-Desktop,代碼行數:11,代碼來源:process.py

示例11: test_processEnded

# 需要導入模塊: from twisted.internet import error [as 別名]
# 或者: from twisted.internet.error import ProcessTerminated [as 別名]
def test_processEnded(self):
        """
        Exceptions other than L{error.ProcessDone} with status=0 are turned
        into L{error.ConnectionLost}.
        """
        d = self.ep.connect(self.factory)
        self.successResultOf(d)
        wpp = self.reactor.processProtocol

        wpp.processEnded(Failure(error.ProcessTerminated()))
        self.assertEqual(wpp.protocol.reason.check(error.ConnectionLost),
                         error.ConnectionLost) 
開發者ID:proxysh,項目名稱:Safejumper-for-Desktop,代碼行數:14,代碼來源:test_endpoints.py

示例12: request_exit_status

# 需要導入模塊: from twisted.internet import error [as 別名]
# 或者: from twisted.internet.error import ProcessTerminated [as 別名]
def request_exit_status(self, data):
        """
        When the server sends the command's exit status, record it for later
        delivery to the protocol.

        @param data: The network-order four byte representation of the exit
            status of the command.
        @type data: L{bytes}
        """
        (status,) = unpack('>L', data)
        if status != 0:
            self._reason = ProcessTerminated(status, None, None) 
開發者ID:proxysh,項目名稱:Safejumper-for-Desktop,代碼行數:14,代碼來源:endpoints.py

示例13: request_exit_signal

# 需要導入模塊: from twisted.internet import error [as 別名]
# 或者: from twisted.internet.error import ProcessTerminated [as 別名]
def request_exit_signal(self, data):
        """
        When the server sends the command's exit status, record it for later
        delivery to the protocol.

        @param data: The network-order four byte representation of the exit
            signal of the command.
        @type data: L{bytes}
        """
        (signal,) = unpack('>L', data)
        self._reason = ProcessTerminated(None, signal, None) 
開發者ID:proxysh,項目名稱:Safejumper-for-Desktop,代碼行數:13,代碼來源:endpoints.py

示例14: loseConnection

# 需要導入模塊: from twisted.internet import error [as 別名]
# 或者: from twisted.internet.error import ProcessTerminated [as 別名]
def loseConnection(self):
        """
        Disconnect the protocol associated with this transport.
        """
        if self.closed:
            return
        self.closed = 1
        self.proto.inConnectionLost()
        self.proto.outConnectionLost()
        self.proto.errConnectionLost()
        self.proto.processEnded(failure.Failure(ProcessTerminated(255, None, None))) 
開發者ID:proxysh,項目名稱:Safejumper-for-Desktop,代碼行數:13,代碼來源:test_ssh.py

示例15: tearDown

# 需要導入模塊: from twisted.internet import error [as 別名]
# 或者: from twisted.internet.error import ProcessTerminated [as 別名]
def tearDown(self):
        # Kill the child process.  We're done with it.
        try:
            self.clientTransport.signalProcess("KILL")
        except (error.ProcessExitedAlready, OSError):
            pass
        def trap(failure):
            failure.trap(error.ProcessTerminated)
            self.assertIsNone(failure.value.exitCode)
            self.assertEqual(failure.value.status, 9)
        return self.testTerminal.onDisconnection.addErrback(trap) 
開發者ID:proxysh,項目名稱:Safejumper-for-Desktop,代碼行數:13,代碼來源:test_recvline.py


注:本文中的twisted.internet.error.ProcessTerminated方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。