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


Python Terminal.communicate方法代码示例

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


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

示例1: DADispatcher

# 需要导入模块: from terminal import Terminal [as 别名]
# 或者: from terminal.Terminal import communicate [as 别名]

#.........这里部分代码省略.........
        try:
            response = request_.recv(1024)
            request_.send("OK")
            if response == "HB":
                self.log("Heart beat from", jobName_)
                return
            elif response in DADispatcher.STATES:
                self.log("Set state", jobName_, response)
            else:
                raise Exception()
        except:
            response = "UNKNOWN"

        with self._lock:
            try:
                jobInfo.state = response

                finished = False

                if jobInfo.state == "DONE":
                    self._activeJobs[jobInfo.cluster].remove(jobInfo)
                    finished = True
                elif jobInfo.state == "FAILED":
                    self._activeJobs[jobInfo.cluster].remove(jobInfo)
                    if self._resubmit:
                        self._readyJobs[jobInfo.cluster].append(jobInfo)

                    finished = True

                if finished:
                    if jobInfo.cluster == "interactive":
                        jobInfo.proc.close()
                    elif jobInfo.cluster == "local":
                        jobInfo.proc.communicate()

            except:
                self.log("Exception while serving", jobName_, "\n", excDump())

            if jobInfo.state == "FAILED":
                with open(self._workspace + "/logs/" + jobName_ + ".fail", "w") as failLog:
                    pass

        self._stateChanged.set()

    def createJob(self, jobName_, cluster_, append=True):
        jobInfo = DADispatcher.JobInfo(jobName_)
        jobInfo.cluster = cluster_
        self._jobInfo[jobName_] = jobInfo
        if append:
            self._readyJobs[cluster_].append(jobInfo)
        if DEBUG:
            self.log("Created", jobName_)
        return jobInfo

    def submitOne(self, cluster, logdir=""):
        if len(self._activeJobs[cluster]) >= DADispatcher.MAXACTIVE[cluster] or len(self._readyJobs[cluster]) == 0:
            return False

        with self._lock:
            try:
                jobInfo = self._readyJobs[cluster].pop(0)
            except IndexError:
                return False

        if DEBUG:
            self.log("submit", jobInfo.name)
开发者ID:CMUCMS,项目名称:dcmutools,代码行数:70,代码来源:dap.py

示例2: RuntimeError

# 需要导入模块: from terminal import Terminal [as 别名]
# 或者: from terminal.Terminal import communicate [as 别名]
        jobConfig["outputFile"] = options.outputFile.strip()
        jobConfig["addSuffix"] = not options.noSuffix
        jobConfig["reducer"] = options.reducer.strip()
        jobConfig["maxSize"] = options.maxSize

        if jobConfig["reducer"] != "None" and not jobConfig["outputFile"]:
            raise RuntimeError("Reducer requires output file name specification")

        ### OPEN WORKSPACE ###

        os.mkdir(workspace)
        os.mkdir(workspace + "/inputs")
        os.mkdir(workspace + "/logs")

        if options.environment.strip():
            cmds = terminal.communicate(options.environment.strip())
            with open(workspace + "/environment", "w") as envFile:
                for cmd in cmds:
                    envFile.write(cmd + "\n")

    print "Using {0} as workspace".format(workspace)

    ### RUNTIME-SPECIFIC CONFIGURATIONS ###

    jobConfig["taskID"] = taskID
    jobConfig["serverHost"] = os.environ["HOSTNAME"]
    jobConfig["serverPort"] = tcpServer.server_address[1]
    jobConfig["serverWorkDir"] = TMPDIR + "/" + taskID
    jobConfig["logDir"] = HTMLDIR + "/" + taskID + "/logs"
    # In principle log directory can be anywhere; we are choosing it to be directly in the HTMLDIR for convenience
开发者ID:CMUCMS,项目名称:dcmutools,代码行数:32,代码来源:dap.py


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