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


Python popen2.Popen3方法代码示例

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


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

示例1: print_chain

# 需要导入模块: import popen2 [as 别名]
# 或者: from popen2 import Popen3 [as 别名]
def print_chain(l):
    llen = len(l) - 1
    if llen < 0:
        return ""
    c = l[llen]
    llen -= 1
    s = "_ "
    if not c.isSelfSigned():
        s = "_ ... [Missing Root]\n"
    else:
        s += "%s [Self Signed]\n" % c.subject
    i = 1
    while (llen != -1):
        c = l[llen]
        s += "%s\_ %s" % (" "*i, c.subject)
        if llen != 0:
            s += "\n"
        i += 2
        llen -= 1
    print s

# import popen2
# a=popen2.Popen3("openssl crl -text -inform DER -noout ", capturestderr=True)
# a.tochild.write(open("samples/klasa1.crl").read())
# a.tochild.close()
# a.poll() 
开发者ID:medbenali,项目名称:CyberScan,代码行数:28,代码来源:cert.py

示例2: readProcess

# 需要导入模块: import popen2 [as 别名]
# 或者: from popen2 import Popen3 [as 别名]
def readProcess(cmd, *args):
    r"""Similar to `os.popen3`, but returns 2 strings (stdin, stdout) and the
    exit code (unlike popen2, exit is 0 if no problems occured (for some
    bizarre reason popen2 returns None... <sigh>).

    FIXME: only works for UNIX; handling of signalled processes.
    """
    import popen2
    BUFSIZE=1024
    import select
    popen = popen2.Popen3((cmd,) + args, capturestderr=True)
    which = {id(popen.fromchild): [],
             id(popen.childerr):  []}
    select = Result(select.select)
    read   = Result(os.read)
    try:
        popen.tochild.close() # XXX make sure we're not waiting forever
        while select([popen.fromchild, popen.childerr], [], []):
            readSomething = False
            for f in select.result[0]:
                while read(f.fileno(), BUFSIZE):
                    which[id(f)].append(read.result)
                    readSomething = True
            if not readSomething:
                break
        out, err = ["".join(which[id(f)])
                    for f in [popen.fromchild, popen.childerr]]
        returncode = popen.wait()

        if os.WIFEXITED(returncode):
            exit = os.WEXITSTATUS(returncode)
        else:
            exit = returncode or 1 # HACK: ensure non-zero
    finally:
        try:
            popen.fromchild.close()
        finally:
            popen.childerr.close()
    return out or "", err or "", exit 
开发者ID:hello-sea,项目名称:DeepLearning_Wavelet-LSTM,代码行数:41,代码来源:awmstools.py

示例3: __init__

# 需要导入模块: import popen2 [as 别名]
# 或者: from popen2 import Popen3 [as 别名]
def __init__(self, command, **kw):
                if kw.get('stderr') == 'STDOUT':
                    popen2.Popen4.__init__(self, command, 1)
                else:
                    popen2.Popen3.__init__(self, command, 1)
                self.stdin = self.tochild
                self.stdout = self.fromchild
                self.stderr = self.childerr 
开发者ID:turbulenz,项目名称:gyp,代码行数:10,代码来源:TestCmd.py

示例4: wait

# 需要导入模块: import popen2 [as 别名]
# 或者: from popen2 import Popen3 [as 别名]
def wait(self, *args, **kw):
                resultcode = popen2.Popen3.wait(self, *args, **kw)
                if os.WIFEXITED(resultcode):
                    return os.WEXITSTATUS(resultcode)
                elif os.WIFSIGNALED(resultcode):
                    return os.WTERMSIG(resultcode)
                else:
                    return None 
开发者ID:turbulenz,项目名称:gyp,代码行数:10,代码来源:TestCmd.py

示例5: __init__

# 需要导入模块: import popen2 [as 别名]
# 或者: from popen2 import Popen3 [as 别名]
def __init__(self, command, **kw):
                if kw.get('stderr') == 'STDOUT':
                    apply(popen2.Popen4.__init__, (self, command, 1))
                else:
                    apply(popen2.Popen3.__init__, (self, command, 1))
                self.stdin = self.tochild
                self.stdout = self.fromchild
                self.stderr = self.childerr 
开发者ID:kawalpemilu,项目名称:kawalpemilu2014,代码行数:10,代码来源:TestCmd.py

示例6: wait

# 需要导入模块: import popen2 [as 别名]
# 或者: from popen2 import Popen3 [as 别名]
def wait(self, *args, **kw):
                resultcode = apply(popen2.Popen3.wait, (self,)+args, kw)
                if os.WIFEXITED(resultcode):
                    return os.WEXITSTATUS(resultcode)
                elif os.WIFSIGNALED(resultcode):
                    return os.WTERMSIG(resultcode)
                else:
                    return None 
开发者ID:kawalpemilu,项目名称:kawalpemilu2014,代码行数:10,代码来源:TestCmd.py

示例7: decompress

# 需要导入模块: import popen2 [as 别名]
# 或者: from popen2 import Popen3 [as 别名]
def decompress(self, data):
            pop = popen2.Popen3("bunzip2", capturestderr=1)
            pop.tochild.write(data)
            pop.tochild.close()
            ret = pop.fromchild.read()
            pop.fromchild.close()
            if pop.wait() != 0:
                ret = bz2.decompress(data)
            return ret 
开发者ID:ofermend,项目名称:medicare-demo,代码行数:11,代码来源:test_bz2.py


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