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


Python win32process.GetExitCodeProcess方法代码示例

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


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

示例1: call

# 需要导入模块: import win32process [as 别名]
# 或者: from win32process import GetExitCodeProcess [as 别名]
def call(self, method, args):
            """
            Launch program to consume file

            @type	method: string
            @param	method: Command to execute
            @type	args: array of objects
            @param	args: Arguments to pass
            """

            hProcess, hThread, dwProcessId, dwThreadId = win32process.CreateProcess(
                None, self.commandLine, None, None, 0,
                win32con.NORMAL_PRIORITY_CLASS, None, None, None)

            while win32process.GetExitCodeProcess(hProcess) == win32con.STILL_ACTIVE:
                time.sleep(0.25)

            self.closeApp(hProcess, self._windowName) 
开发者ID:MozillaSecurity,项目名称:peach,代码行数:20,代码来源:process.py

示例2: exitCode

# 需要导入模块: import win32process [as 别名]
# 或者: from win32process import GetExitCodeProcess [as 别名]
def exitCode(self):
        """
        Return process exit code.
        """
        return win32process.GetExitCodeProcess(self.hProcess) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:7,代码来源:winprocess.py

示例3: join

# 需要导入模块: import win32process [as 别名]
# 或者: from win32process import GetExitCodeProcess [as 别名]
def join(self):
        win32event.WaitForSingleObject(self.processHandle,
                                       win32event.INFINITE)
        self.exitCode = win32process.GetExitCodeProcess(self.processHandle) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:6,代码来源:test_win32trace.py

示例4: test_wait

# 需要导入模块: import win32process [as 别名]
# 或者: from win32process import GetExitCodeProcess [as 别名]
def test_wait(self):
        handle = win32api.OpenProcess(win32con.PROCESS_QUERY_INFORMATION,
                                      win32con.FALSE, self.pid)
        self.addCleanup(win32api.CloseHandle, handle)
        p = psutil.Process(self.pid)
        p.terminate()
        psutil_value = p.wait()
        sys_value = win32process.GetExitCodeProcess(handle)
        self.assertEqual(psutil_value, sys_value) 
开发者ID:birforce,项目名称:vnpy_crypto,代码行数:11,代码来源:test_windows.py

示例5: checkWork

# 需要导入模块: import win32process [as 别名]
# 或者: from win32process import GetExitCodeProcess [as 别名]
def checkWork(self):
        if win32event.WaitForSingleObject(self.proc.hProcess, 0) != win32event.WAIT_OBJECT_0:
            return 0
        exitCode = win32process.GetExitCodeProcess(self.proc.hProcess)
        self.deactivate()
        self.proc.processEnded(exitCode)
        return 0 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:9,代码来源:_dumbwin32proc.py

示例6: close

# 需要导入模块: import win32process [as 别名]
# 或者: from win32process import GetExitCodeProcess [as 别名]
def close(self):
        if win32process.GetExitCodeProcess(self.handle) == win32con.STILL_ACTIVE:
            self.kill()
        self.child_stdin.close()
        self.child_stdin = None
        if self.child_stderr:
            self.child_stdin.close()
            self.child_stdin = None
        es = ExitStatus(self.cmdline, self.child_stdout.close())
        if self.exitstatus is None:
            self.exitstatus = es
        self.child_stdout = None
        self.dead()
        return self.exitstatus 
开发者ID:kdart,项目名称:pycopia,代码行数:16,代码来源:WindowsServer.py

示例7: poll

# 需要导入模块: import win32process [as 别名]
# 或者: from win32process import GetExitCodeProcess [as 别名]
def poll(self):
        es = win32process.GetExitCodeProcess(self.handle)
        if es == win32con.STILL_ACTIVE:
            return None
        else:
            self.exitstatus = ExitStatus(self.cmdline, es)
            self.dead()
            return self.exitstatus

    # called when process determined to be daed 
开发者ID:kdart,项目名称:pycopia,代码行数:12,代码来源:WindowsServer.py

示例8: alive

# 需要导入模块: import win32process [as 别名]
# 或者: from win32process import GetExitCodeProcess [as 别名]
def alive(self):
        es = win32process.GetExitCodeProcess(self.handle)
        if es == win32con.STILL_ACTIVE:
            return True
        else:
            return False

    # wait until finished 
开发者ID:kdart,项目名称:pycopia,代码行数:10,代码来源:WindowsServer.py

示例9: isalive

# 需要导入模块: import win32process [as 别名]
# 或者: from win32process import GetExitCodeProcess [as 别名]
def isalive(self):
        return win32process.GetExitCodeProcess(self.hProcess) == win32con.STILL_ACTIVE 
开发者ID:turingsec,项目名称:marsnake,代码行数:4,代码来源:winpty.py

示例10: _run_as_administrators

# 需要导入模块: import win32process [as 别名]
# 或者: from win32process import GetExitCodeProcess [as 别名]
def _run_as_administrators(self, executable, arguments):
        """Invokes the specified executable with the specified arguments, escalating the privileges of the process
        to Administrators.

        All output that process generates to stdout/stderr will be echoed to this process's stdout/stderr.

        Note, this can only be used on executables that accept the `--redirect-to-pipe` option to allow for this
        process to capture the output from the escalated process.

        Note, Windows will ask for confirmation and/or an Administrator password before the process is escalated.

        @param executable: The path to the Windows executable to run escalated.
        @param arguments: An array of arguments to supply to the executable.

        @type executable: str
        @type arguments: []

        @return: The exit code of the process.
        @rtype: int
        """
        client = PipeRedirectorClient()
        arguments = arguments + ["--redirect-to-pipe", client.pipe_name]

        child_process = win32com.shell.shell.ShellExecuteEx(
            fMask=256 + 64,
            lpVerb="runas",
            lpFile=executable,
            lpParameters=" ".join(arguments),
        )
        client.start()

        proc_handle = child_process["hProcess"]
        win32event.WaitForSingleObject(proc_handle, -1)

        client.stop()
        return win32process.GetExitCodeProcess(proc_handle) 
开发者ID:scalyr,项目名称:scalyr-agent-2,代码行数:38,代码来源:platform_windows.py

示例11: enumCallback

# 需要导入模块: import win32process [as 别名]
# 或者: from win32process import GetExitCodeProcess [as 别名]
def enumCallback(hwnd, windowName):
            """
            Will get called by win32gui.EnumWindows, once for each
            top level application window.
            """

            try:

                # Get window title
                title = win32gui.GetWindowText(hwnd)

                # Is this our guy?
                if title.find(windowName) == -1:
                    return

                (threadId, processId) = win32process.GetWindowThreadProcessId(hwnd)

                # Send WM_CLOSE message
                try:
                    win32gui.PostMessage(hwnd, win32con.WM_CLOSE, 0, 0)
                    win32gui.PostQuitMessage(hwnd)
                except:
                    pass

                # Give it upto 5 sec
                for i in range(100):
                    if win32process.GetExitCodeProcess(processId) != win32con.STILL_ACTIVE:
                        # Process exited already
                        return

                    time.sleep(0.25)

                try:
                    # Kill application
                    win32process.TerminateProcess(processId, 0)
                except:
                    pass
            except:
                pass 
开发者ID:MozillaSecurity,项目名称:peach,代码行数:41,代码来源:tcp.py

示例12: checkWork

# 需要导入模块: import win32process [as 别名]
# 或者: from win32process import GetExitCodeProcess [as 别名]
def checkWork(self):
        if win32event.WaitForSingleObject(self.proc.hProcess, 0) != win32event.WAIT_OBJECT_0:
            return 0
        exitCode = win32process.GetExitCodeProcess(self.proc.hProcess)
        if exitCode == 0:
            err = error.ProcessDone(exitCode)
        else:
            err = error.ProcessTerminated(exitCode)
        self.deactivate()
        self.proc.protocol.processEnded(failure.Failure(err))
        return 0 
开发者ID:kenorb-contrib,项目名称:BitTorrent,代码行数:13,代码来源:_dumbwin32proc.py

示例13: connectionLost

# 需要导入模块: import win32process [as 别名]
# 或者: from win32process import GetExitCodeProcess [as 别名]
def connectionLost(self, reason=None):
        """Shut down resources."""
        # Get the exit status and notify the protocol
        exitCode = win32process.GetExitCodeProcess(self.hProcess)
        if exitCode == 0:
            err = error.ProcessDone(exitCode)
        else:
            err = error.ProcessTerminated(exitCode)
        self.protocol.processEnded(failure.Failure(err))
    
    ## IConsumer 
开发者ID:kenorb-contrib,项目名称:BitTorrent,代码行数:13,代码来源:process.py

示例14: runAsAdmin

# 需要导入模块: import win32process [as 别名]
# 或者: from win32process import GetExitCodeProcess [as 别名]
def runAsAdmin(cmdLine=None, wait=True):

    if os.name != 'nt':
        raise RuntimeError, "This function is only implemented on Windows."

    import win32api
    import win32con
    import win32event
    import win32process
    from win32com.shell.shell import ShellExecuteEx
    from win32com.shell import shellcon

    python_exe = sys.executable

    if cmdLine is None:
        cmdLine = [python_exe] + sys.argv
    elif type(cmdLine) not in (types.TupleType, types.ListType):
        raise ValueError, "cmdLine is not a sequence."
    cmd = '"%s"' % (cmdLine[0],)
    # XXX TODO: isn't there a function or something we can call to massage command line params?
    params = " ".join(['"%s"' % (x,) for x in cmdLine[1:]])
    cmdDir = ''
    #showCmd = win32con.SW_SHOWNORMAL
    showCmd = win32con.SW_HIDE
    lpVerb = 'runas'  # causes UAC elevation prompt.

    # print "Running", cmd, params

    # ShellExecute() doesn't seem to allow us to fetch the PID or handle
    # of the process, so we can't get anything useful from it. Therefore
    # the more complex ShellExecuteEx() must be used.

    # procHandle = win32api.ShellExecute(0, lpVerb, cmd, params, cmdDir, showCmd)

    procInfo = ShellExecuteEx(nShow=showCmd,
                              fMask=shellcon.SEE_MASK_NOCLOSEPROCESS,
                              lpVerb=lpVerb,
                              lpFile=cmd,
                              lpParameters=params)

    if wait:
        procHandle = procInfo['hProcess']
        obj = win32event.WaitForSingleObject(procHandle, win32event.INFINITE)
        rc = win32process.GetExitCodeProcess(procHandle)
        # print "Process handle %s returned code %s" % (procHandle, rc)
    else:
        rc = None

    return rc 
开发者ID:ElevenPaths,项目名称:uac-a-mola,代码行数:51,代码来源:admin.py

示例15: callWindows

# 需要导入模块: import win32process [as 别名]
# 或者: from win32process import GetExitCodeProcess [as 别名]
def callWindows(self):
        """
        Launch program to consume file
        """

        # Launch via spawn

        realArgs = ["cmd.exe", "/c", self.command]
        for a in self.args:
            realArgs.append(a)

        phandle = os.spawnv(os.P_NOWAIT, os.path.join(os.getenv('SystemRoot'), 'system32', 'cmd.exe'), realArgs)

        # Give it some time before we KILL!
        for i in range(int(self.waitTime / 0.25)):
            if win32process.GetExitCodeProcess(phandle) != win32con.STILL_ACTIVE:
                # Process exited already
                break

            time.sleep(0.25)

        try:
            pid = ctypes.windll.kernel32.GetProcessId(ctypes.c_ulong(phandle))
            if pid > 0:
                for cid in self.FindChildrenOf(pid):

                    chandle = win32api.OpenProcess(1, 0, cid)
                    win32process.TerminateProcess(chandle, 0)

                    try:
                        win32api.CloseHandle(chandle)
                    except:
                        pass

            win32process.TerminateProcess(phandle, 0)

            try:
                win32api.CloseHandle(phandle)
            except:
                pass

        except:
            pass 
开发者ID:MozillaSecurity,项目名称:peach,代码行数:45,代码来源:process.py


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