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