当前位置: 首页>>代码示例>>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;未经允许,请勿转载。