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


Python os.WEXITSTATUS属性代码示例

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


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

示例1: waitfinish

# 需要导入模块: import os [as 别名]
# 或者: from os import WEXITSTATUS [as 别名]
def waitfinish(self, waiter=os.waitpid):
        pid, systemstatus = waiter(self.pid, 0)
        if systemstatus:
            if os.WIFSIGNALED(systemstatus):
                exitstatus = os.WTERMSIG(systemstatus) + 128
            else:
                exitstatus = os.WEXITSTATUS(systemstatus)
        else:
            exitstatus = 0
        signal = systemstatus & 0x7f
        if not exitstatus and not signal:
            retval = self.RETVAL.open('rb')
            try:
                retval_data = retval.read()
            finally:
                retval.close()
            retval = marshal.loads(retval_data)
        else:
            retval = None
        stdout = self.STDOUT.read()
        stderr = self.STDERR.read()
        self._removetemp()
        return Result(exitstatus, signal, retval, stdout, stderr) 
开发者ID:pytest-dev,项目名称:py,代码行数:25,代码来源:forkedfunc.py

示例2: poll

# 需要导入模块: import os [as 别名]
# 或者: from os import WEXITSTATUS [as 别名]
def poll(self, flag=os.WNOHANG):
            if self.returncode is None:
                while True:
                    try:
                        pid, sts = os.waitpid(self.pid, flag)
                    except os.error as e:
                        if e.errno == errno.EINTR:
                            continue
                        # Child process not yet created. See #1731717
                        # e.errno == errno.ECHILD == 10
                        return None
                    else:
                        break
                if pid == self.pid:
                    if os.WIFSIGNALED(sts):
                        self.returncode = -os.WTERMSIG(sts)
                    else:
                        assert os.WIFEXITED(sts)
                        self.returncode = os.WEXITSTATUS(sts)
            return self.returncode 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:22,代码来源:forking.py

示例3: platformProcessEvent

# 需要导入模块: import os [as 别名]
# 或者: from os import WEXITSTATUS [as 别名]
def platformProcessEvent(self, status):

        if os.WIFEXITED(status):
            tid = self.getMeta("ThreadId", -1)
            if tid != self.getPid():
                # Set the selected thread ID to the pid cause
                # the old one's invalid
                if tid in self.pthreads:
                    self.pthreads.remove(tid)
                self.setMeta("ThreadId", self.getPid())
                self._fireExitThread(tid, os.WEXITSTATUS(status))
            else:
                self._fireExit(os.WEXITSTATUS(status))

        elif os.WIFSIGNALED(status):
            self.setMeta("ExitCode", os.WTERMSIG(status))
            self.fireNotifiers(vtrace.NOTIFY_EXIT)

        elif os.WIFSTOPPED(status):
            sig = os.WSTOPSIG(status)
            self.handlePosixSignal(sig)

        else:
            print "OMG WTF JUST HAPPENED??!?11/!?1?>!" 
开发者ID:joxeankoret,项目名称:nightmare,代码行数:26,代码来源:posix.py

示例4: exitStatus

# 需要导入模块: import os [as 别名]
# 或者: from os import WEXITSTATUS [as 别名]
def exitStatus(self, code):
        """
        Construct a status from the given exit code.

        @type code: L{int} between 0 and 255 inclusive.
        @param code: The exit status which the code will represent.

        @rtype: L{int}
        @return: A status integer for the given exit code.
        """
        # /* Macros for constructing status values.  */
        # #define __W_EXITCODE(ret, sig)  ((ret) << 8 | (sig))
        status = (code << 8) | 0

        # Sanity check
        self.assertTrue(os.WIFEXITED(status))
        self.assertEqual(os.WEXITSTATUS(status), code)
        self.assertFalse(os.WIFSIGNALED(status))

        return status 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:22,代码来源:test_mail.py

示例5: _do_commands

# 需要导入模块: import os [as 别名]
# 或者: from os import WEXITSTATUS [as 别名]
def _do_commands(name, cmds, root):
    # use sudo on Linux and possibly other platforms. On Windows it's
    # assumed you're running as Administrator (everybody does it...)
    if root and sys.platform not in ("win32", "cli"):
        sudo = "sudo "
    else:
        sudo = ""
    cmd = "%s%s setup.py %s" % (sudo, sys.executable, " ".join(cmds))
    print("========", name, "==", cmd)
    rv = False
    os.chdir(name)
    try:
        rv = WEXITSTATUS(os.system(cmd)) == 0
    finally:
        os.chdir("..")
        print("====================== END", name, "\n")
    return rv 
开发者ID:kdart,项目名称:pycopia,代码行数:19,代码来源:setup.py

示例6: _do_scripts

# 需要导入模块: import os [as 别名]
# 或者: from os import WEXITSTATUS [as 别名]
def _do_scripts(name, scriptdir, root=False):
    if root and sys.platform not in ("win32", "cli"):
        sudo = "sudo "
    else:
        sudo = ""
    os.chdir(name)
    rv = True
    try:
        if os.path.isdir("bin"):
            if sys.platform == "darwin":
                cmd = "%scp -a bin/* %s" % (sudo, scriptdir)
            else:
                cmd = "%scp -dR --preserve=mode  bin/* %s" % (sudo, scriptdir)
            print("======== SCRIPTS", name, "==", cmd)
            rv = WEXITSTATUS(os.system(cmd)) == 0
    finally:
        os.chdir("..")
    print("====================== END SCRIPTS", name)
    return rv 
开发者ID:kdart,项目名称:pycopia,代码行数:21,代码来源:setup.py

示例7: do_squash

# 需要导入模块: import os [as 别名]
# 或者: from os import WEXITSTATUS [as 别名]
def do_squash(name):
    if not _check_rsync():
        print("Squash requires rsync tool to be installed.")
        return False
    if not os.path.isdir(PYCOPIA_SQUASH):
        os.makedirs(PYCOPIA_SQUASH)
    os.chdir(name)
    uname = os.uname()
    bin_dir = os.path.join("build", "lib.%s-%s-%s" % (uname[0].lower(), uname[4], sys.version[:3]))
    # e.g: build/lib.linux-x86_64-2.5/pycopia
    print("======== SQUASH", name, "to", PYCOPIA_SQUASH)
    try:
        if WEXITSTATUS(os.system("%s setup.py build" % (sys.executable,))) != 0:
            return False
        for pydir in ("build/lib", bin_dir):
            if os.path.isdir(pydir):
                cmd = "rsync -azvu %s/ %s" % (pydir, PYCOPIA_SQUASH)
                if WEXITSTATUS(os.system(cmd)) != 0:
                    return False
    finally:
        os.chdir("..")
    _null_init(PYCOPIA_SQUASH)
    print("====================== END", name, "squashed into", PYCOPIA_SQUASH, "\n")
    return True 
开发者ID:kdart,项目名称:pycopia,代码行数:26,代码来源:setup.py

示例8: GetExitStatus

# 需要导入模块: import os [as 别名]
# 或者: from os import WEXITSTATUS [as 别名]
def GetExitStatus(exit_code):
  """Returns the argument to exit(), or -1 if exit() wasn't called.

  Args:
    exit_code: the result value of os.system(command).
  """

  if os.name == 'nt':
    # On Windows, os.WEXITSTATUS() doesn't work and os.system() returns
    # the argument to exit() directly.
    return exit_code
  else:
    # On Unix, os.WEXITSTATUS() must be used to extract the exit status
    # from the result of os.system().
    if os.WIFEXITED(exit_code):
      return os.WEXITSTATUS(exit_code)
    else:
      return -1 
开发者ID:mlperf,项目名称:training_results_v0.5,代码行数:20,代码来源:gtest_test_utils.py

示例9: GetExitStatus

# 需要导入模块: import os [as 别名]
# 或者: from os import WEXITSTATUS [as 别名]
def GetExitStatus(exit_code):
  """Returns the argument to exit(), or -1 if exit() wasn't called.

  Args:
    exit_code: the result value of os.system(command).
  """

  if os.name == 'nt':
    # On Windows, os.WEXITSTATUS() doesn't work and os.system() returns
    # the argument to exit() directly.
    return exit_code
  else:
    # On Unix, os.WEXITSTATUS() must be used to extract the exit status
    # from the result of os.system().
    if os.WIFEXITED(exit_code):
      return os.WEXITSTATUS(exit_code)
    else:
      return -1


# Suppresses the "Invalid const name" lint complaint
# pylint: disable-msg=C6409

# Exposes utilities from gtest_test_utils. 
开发者ID:mlperf,项目名称:training_results_v0.5,代码行数:26,代码来源:gmock_test_utils.py

示例10: _do_waitpid

# 需要导入模块: import os [as 别名]
# 或者: from os import WEXITSTATUS [as 别名]
def _do_waitpid(self, loop, expected_pid, callback, args):
            assert expected_pid > 0

            try:
                pid, status = os.waitpid(expected_pid, 0)
            except ChildProcessError:
                # The child process is already reaped
                # (may happen if waitpid() is called elsewhere).
                pid = expected_pid
                returncode = 255
                logger.warning(
                    "Unknown child process pid %d, will report returncode 255", pid
                )
            else:
                if os.WIFSIGNALED(status):
                    returncode = -os.WTERMSIG(status)
                elif os.WIFEXITED(status):
                    returncode = os.WEXITSTATUS(status)
                else:
                    returncode = status

                if loop.get_debug():
                    logger.debug(
                        "process %s exited with returncode %s", expected_pid, returncode
                    )

            if loop.is_closed():
                logger.warning("Loop %r that handles pid %r is closed", loop, pid)
            else:
                loop.call_soon_threadsafe(callback, pid, returncode, *args)

            self._threads.pop(expected_pid)

    # add the watcher to the loop policy 
开发者ID:microsoft,项目名称:botbuilder-python,代码行数:36,代码来源:threading_helper.py

示例11: _handle_exitstatus

# 需要导入模块: import os [as 别名]
# 或者: from os import WEXITSTATUS [as 别名]
def _handle_exitstatus(self, sts, _WIFSIGNALED=os.WIFSIGNALED,
                _WTERMSIG=os.WTERMSIG, _WIFEXITED=os.WIFEXITED,
                _WEXITSTATUS=os.WEXITSTATUS):
            # This method is called (indirectly) by __del__, so it cannot
            # refer to anything outside of its local scope."""
            if _WIFSIGNALED(sts):
                self.returncode = -_WTERMSIG(sts)
            elif _WIFEXITED(sts):
                self.returncode = _WEXITSTATUS(sts)
            else:
                # Should never happen
                raise RuntimeError("Unknown child exit status!") 
开发者ID:war-and-code,项目名称:jawfish,代码行数:14,代码来源:subprocess.py

示例12: _set_returncode

# 需要导入模块: import os [as 别名]
# 或者: from os import WEXITSTATUS [as 别名]
def _set_returncode(self, status):
        if os.WIFSIGNALED(status):
            self.returncode = -os.WTERMSIG(status)
        else:
            assert os.WIFEXITED(status)
            self.returncode = os.WEXITSTATUS(status)
        if self._exit_callback:
            callback = self._exit_callback
            self._exit_callback = None
            callback(self.returncode) 
开发者ID:tao12345666333,项目名称:tornado-zh,代码行数:12,代码来源:process.py

示例13: _on_sigchld

# 需要导入模块: import os [as 别名]
# 或者: from os import WEXITSTATUS [as 别名]
def _on_sigchld(self, watcher):
            """Callback of libev child watcher. Called when libev event loop
            catches corresponding SIGCHLD signal.
            """
            watcher.stop()
            # Status evaluation copied from `multiprocessing.forking` in Py2.7.
            if os.WIFSIGNALED(watcher.rstatus):
                self._popen.returncode = -os.WTERMSIG(watcher.rstatus)
            else:
                assert os.WIFEXITED(watcher.rstatus)
                self._popen.returncode = os.WEXITSTATUS(watcher.rstatus)
            self._returnevent.set()
            log.debug("SIGCHLD watcher callback for %s invoked. Exitcode "
                      "stored: %s", self.pid, self._popen.returncode) 
开发者ID:jgehrcke,项目名称:gipc,代码行数:16,代码来源:gipc.py

示例14: getoutput

# 需要导入模块: import os [as 别名]
# 或者: from os import WEXITSTATUS [as 别名]
def getoutput(cmd, successful_status=(0,), stacklevel=1):
    try:
        status, output = getstatusoutput(cmd)
    except EnvironmentError:
        e = get_exception()
        warnings.warn(str(e), UserWarning, stacklevel=stacklevel)
        return False, ""
    if os.WIFEXITED(status) and os.WEXITSTATUS(status) in successful_status:
        return True, output
    return False, output 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:12,代码来源:cpuinfo.py

示例15: _handle_exitstatus

# 需要导入模块: import os [as 别名]
# 或者: from os import WEXITSTATUS [as 别名]
def _handle_exitstatus(self, sts):
            if os.WIFSIGNALED(sts):
                self.returncode = -os.WTERMSIG(sts)
            elif os.WIFEXITED(sts):
                self.returncode = os.WEXITSTATUS(sts)
            else:
                # Should never happen
                raise RuntimeError("Unknown child exit status!")

            _active.remove(self) 
开发者ID:linuxscout,项目名称:mishkal,代码行数:12,代码来源:subprocess24.py


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