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


Python UnwrapObject.hookIO方法代码示例

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


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

示例1: KoTerminalProcess

# 需要导入模块: from xpcom.server import UnwrapObject [as 别名]
# 或者: from xpcom.server.UnwrapObject import hookIO [as 别名]
class KoTerminalProcess(KoRunProcess):

    _terminal = None

    def linkIOWithTerminal(self, terminal):
        # Need to unwrap the terminal handler because we are not actually
        # passing in koIFile xpcom objects as described by the API, we are
        # using the subprocess python file handles instead.
        self._terminal = UnwrapObject(terminal)
        self._terminal.hookIO(self._process.stdin, self._process.stdout,
                              self._process.stderr, "KoTerminalProcess")

    # Override the KoRunProcess.wait() method.
    def wait(self, timeout=None):
        retval = KoRunProcess.wait(self, timeout)
        if self._terminal:
            # Need to wait until the IO is fully synchronized (due to threads)
            # before returning. Otherwise additional data could arrive after
            # this call returns.
            # 
            # Set timeout to 5 seconds due to bugs 89280 and 88439
            self._terminal.waitForIOToFinish(timeout=5)
            self._terminal = None
        return retval

    def waitAsynchronously(self, runTerminationListener):
        t = threading.Thread(target=_terminalProcessWaiter,
                             args=(self, runTerminationListener))
        t.setDaemon(True)
        t.start()
开发者ID:Acidburn0zzz,项目名称:KomodoEdit,代码行数:32,代码来源:runutils.py

示例2: KoStackatoServices

# 需要导入模块: from xpcom.server import UnwrapObject [as 别名]
# 或者: from xpcom.server.UnwrapObject import hookIO [as 别名]

#.........这里部分代码省略.........
                                             async_callback)

    def _logout(self):
        return _runCommand("logout", noJSON=True)

    def runCommand(self, async_callback, args):
        return self.runCommandAsynchronously("generic run command",
                                             self._doRunCommand,
                                             async_callback,
                                             args)

    def _doRunCommand(self, args):
        try:
            #qlog.debug(" _doRunCommand: cmd: %s", args)
            noJSON = "--json" not in args
            result = _runCommand(args[0], *args[1:], noJSON=noJSON)
            #qlog.debug(" _doRunCommand: result.stdout:%s, result.stderr:%s",
            #           result.stdout, result.stderr)
            return result
        except:
            log.exception("_doRunCommand failed")
        
    def getApplications(self, async_callback):
        return self.runCommandAsynchronously("getApplications",
                                             self._getApplications,
                                             async_callback)

    def _getApplications(self):
        return _runCommand("apps")

    def getServices(self, async_callback):
        return self.runCommandAsynchronously("getServices",
                                             self._getServices,
                                             async_callback)

    def _getServices(self):
        return _runCommand("services")

    def getFrameworks(self, async_callback):
        return self.runCommandAsynchronously("getFrameworks",
                                             self._getFrameworks,
                                             async_callback)

    def _getFrameworks(self):
        return _runCommand("frameworks")

    def getRuntimes(self, async_callback):
        return self.runCommandAsynchronously("getRuntimes",
                                             self._getRuntimes,
                                             async_callback)

    def _getRuntimes(self):
        return _runCommand("runtimes")

    def getTargets(self, async_callback):
        return self.runCommandAsynchronously("getTargets",
                                             self._getTargets,
                                             async_callback)

    def _getTargets(self):
        return _runCommand("targets")

    def runCommandInTerminal(self, async_callback, terminalHandler, args, env):
        # Run asynchronously
        self.terminalHandler = UnwrapObject(terminalHandler)
        import koprocessutils
        currentEnv = koprocessutils.getUserEnv()
        newEnvParts = env.split(";")
        for part in newEnvParts:
            parts = part.split("=")
            if len(parts) == 2:
                currentEnv[parts[0]] = parts[1]
            else:
                currentEnv[parts[0]] = ""
        self.env = currentEnv
        async_svc = components.classes["@activestate.com/koAsyncService;1"].\
                        getService(components.interfaces.koIAsyncService)
        async_op = koAsyncOperationBase(self._doRunCommandInTerminal, args)
        async_svc.run("Stackato %s" % (args[0]),
                      async_op, async_callback, [], False)
        return async_op

    def _doRunCommandInTerminal(self, args):
        argv = [stackatoPath] + args
        try:
            p = self._processHelper.ProcessOpen(cmd=argv,
                                                cwd=None,
                                                env=self.env,
                                                stdin=None,
                                                universal_newlines=True)
        except:
            log.exception("Failed to run: %s", argv)
            raise
        try:
            self.terminalHandler.hookIO(p.stdin, p.stdout, p.stderr, " ".join(args))
        except:
            log.exception("Failed to run: %s", argv)
            raise
        p.wait()
        p.close()
开发者ID:Acidburn0zzz,项目名称:KomodoEdit,代码行数:104,代码来源:koStackatoData.py


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