• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python subprocesses.captureStdout函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中subprocesses.captureStdout函数的典型用法代码示例。如果您正苦于以下问题:Python captureStdout函数的具体用法?Python captureStdout怎么用?Python captureStdout使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: getRepoHashAndId

def getRepoHashAndId(repoDir, repoRev="parents() and default"):
    """Return the repository hash and id, and whether it is on default.

    It will also ask what the user would like to do, should the repository not be on default.
    """
    # This returns null if the repository is not on default.
    hgLogTmplList = ["hg", "-R", repoDir, "log", "-r", repoRev, "--template", "{node|short} {rev}"]
    hgIdFull = sps.captureStdout(hgLogTmplList)[0]
    onDefault = bool(hgIdFull)
    if not onDefault:
        updateDefault = raw_input(
            "Not on default tip! " + "Would you like to (a)bort, update to (d)efault, or (u)se this rev: "
        )
        if updateDefault == "a":
            print "Aborting..."
            sys.exit(0)
        elif updateDefault == "d":
            subprocess.check_call(["hg", "-R", repoDir, "update", "default"])
            onDefault = True
        elif updateDefault == "u":
            hgLogTmplList = ["hg", "-R", repoDir, "log", "-r", "parents()", "--template", "{node|short} {rev}"]
        else:
            raise Exception("Invalid choice.")
        hgIdFull = sps.captureStdout(hgLogTmplList)[0]
    assert hgIdFull != ""
    (hgIdChangesetHash, hgIdLocalNum) = hgIdFull.split(" ")
    sps.vdump("Finished getting the hash and local id number of the repository.")
    return hgIdChangesetHash, hgIdLocalNum, onDefault
开发者ID:nth10sd,项目名称:funfuzz,代码行数:28,代码来源:hgCmds.py


示例2: printMachineInfo

def printMachineInfo():
    # Log information about the machine.
    print "Platform details: " + " ".join(platform.uname())
    print "hg version: " + sps.captureStdout(['hg', '-q', 'version'])[0]

    # In here temporarily to see if mock Linux slaves on TBPL have gdb installed
    try:
        print "gdb version: " + sps.captureStdout(['gdb', '--version'], combineStderr=True,
                                                  ignoreStderr=True, ignoreExitCode=True)[0]
    except (KeyboardInterrupt, Exception) as e:
        print('Error involving gdb is: ' + repr(e))

    # FIXME: Should have if os.path.exists(path to git) or something
    #print "git version: " + sps.captureStdout(['git', 'version'], combineStderr=True, ignoreStderr=True, ignoreExitCode=True)[0]
    print "Python version: " + sys.version.split()[0]
    print "Number of cores visible to OS: " + str(multiprocessing.cpu_count())
    print 'Free space (GB): ' + str('%.2f') % sps.getFreeSpace('/', 3)

    hgrcLocation = os.path.join(path0, '.hg', 'hgrc')
    if os.path.isfile(hgrcLocation):
        print 'The hgrc of this repository is:'
        with open(hgrcLocation, 'rb') as f:
            hgrcContentList = f.readlines()
        for line in hgrcContentList:
            print line.rstrip()

    if os.name == 'posix':
        # resource library is only applicable to Linux or Mac platforms.
        import resource
        print "Corefile size (soft limit, hard limit) is: " + \
              repr(resource.getrlimit(resource.RLIMIT_CORE))
开发者ID:MikeHolman,项目名称:funfuzz,代码行数:31,代码来源:bot.py


示例3: patchHgRepoUsingMq

def patchHgRepoUsingMq(patchFile, workingDir=os.getcwdu()):
    # We may have passed in the patch with or without the full directory.
    patchAbsPath = os.path.abspath(sps.normExpUserPath(patchFile))
    pname = os.path.basename(patchAbsPath)
    assert pname != ''
    qimportOutput, qimportRetCode = sps.captureStdout(['hg', '-R', workingDir, 'qimport', patchAbsPath],
                                                   combineStderr=True, ignoreStderr=True,
                                                   ignoreExitCode=True)
    if qimportRetCode != 0:
        if 'already exists' in qimportOutput:
            print "A patch with the same name has already been qpush'ed. Please qremove it first."
        raise Exception('Return code from `hg qimport` is: ' + str(qimportRetCode))

    print("Patch qimport'ed..."),

    qpushOutput, qpushRetCode = sps.captureStdout(['hg', '-R', workingDir, 'qpush', pname],
        combineStderr=True, ignoreStderr=True)
    assert ' is empty' not in qpushOutput, "Patch to be qpush'ed should not be empty."

    if qpushRetCode != 0:
        hgQpopQrmAppliedPatch(patchFile, workingDir)
        print 'You may have untracked .rej or .orig files in the repository.'
        print '`hg status` output of the repository of interesting files in ' + workingDir + ' :'
        subprocess.check_call(['hg', '-R', workingDir, 'status', '--modified', '--added',
                               '--removed', '--deleted'])
        raise Exception('Return code from `hg qpush` is: ' + str(qpushRetCode))

    print("Patch qpush'ed. Continuing..."),
    return pname
开发者ID:ArashAll,项目名称:funfuzz,代码行数:29,代码来源:hgCmds.py


示例4: compileJs

def compileJs(shell):
    '''This function compiles and copies a binary.'''
    try:
        cmdList = [MAKE_BINARY, '-C', shell.getJsObjdir(), '-j' + str(COMPILATION_JOBS), '-s']
        out = sps.captureStdout(cmdList, combineStderr=True, ignoreExitCode=True,
                                currWorkingDir=shell.getJsObjdir(), env=shell.getEnvFull())[0]
    except Exception as e:
        # This exception message is returned from sps.captureStdout via cmdList.
        if (sps.isLinux or sps.isMac) and \
                ('GCC running out of memory' in repr(e) or 'Clang running out of memory' in repr(e)):
            # FIXME: Absolute hack to retry after hitting OOM.
            print 'Trying once more due to the compiler running out of memory...'
            out = sps.captureStdout(cmdList, combineStderr=True, ignoreExitCode=True,
                                    currWorkingDir=shell.getJsObjdir(), env=shell.getEnvFull())[0]
        # A non-zero error can be returned during make, but eventually a shell still gets compiled.
        if os.path.exists(shell.getShellCompiledPath()):
            print 'A shell was compiled even though there was a non-zero exit code. Continuing...'
        else:
            print MAKE_BINARY + " did not result in a js shell:"
            raise

    if os.path.exists(shell.getShellCompiledPath()):
        shutil.copy2(shell.getShellCompiledPath(), shell.getShellCacheFullPath())
        for runLib in shell.getShellCompiledRunLibsPath():
            if os.path.isfile(runLib):
                shutil.copy2(runLib, shell.getShellCacheDir())
    else:
        print out
        raise Exception(MAKE_BINARY + " did not result in a js shell, no exception thrown.")
开发者ID:RanchoIce,项目名称:funfuzz,代码行数:29,代码来源:compileShell.py


示例5: getRepoHashAndId

def getRepoHashAndId(repoDir, repoRev='parents() and default'):
    '''
    This function returns the repository hash and id, and whether it is on default.
    It also asks what the user would like to do, should the repository not be on default.
    '''
    # This returns null if the repository is not on default.
    hgLogTmplList = ['hg', '-R', repoDir, 'log', '-r', repoRev,
                     '--template', '{node|short} {rev}']
    hgIdFull = sps.captureStdout(hgLogTmplList)[0]
    onDefault = bool(hgIdFull)
    if not onDefault:
        updateDefault = raw_input('Not on default tip! ' + \
            'Would you like to (a)bort, update to (d)efault, or (u)se this rev: ')
        if updateDefault == 'a':
            print 'Aborting...'
            sys.exit(0)
        elif updateDefault == 'd':
            subprocess.check_call(['hg', '-R', repoDir, 'update', 'default'])
            onDefault = True
        elif updateDefault == 'u':
            hgLogTmplList = ['hg', '-R', repoDir, 'log', '-r', 'parents()', '--template',
                             '{node|short} {rev}']
        else:
            raise Exception('Invalid choice.')
        hgIdFull = sps.captureStdout(hgLogTmplList)[0]
    assert hgIdFull != ''
    (hgIdChangesetHash, hgIdLocalNum) = hgIdFull.split(' ')
    sps.vdump('Finished getting the hash and local id number of the repository.')
    return hgIdChangesetHash, hgIdLocalNum, onDefault
开发者ID:ArashAll,项目名称:funfuzz,代码行数:29,代码来源:hgCmds.py


示例6: untarbz2

def untarbz2(fn, dest):
    '''
    Extracts .tar.bz2 files to their destination.
    '''
    if not os.path.exists(dest):
        os.mkdir(dest)
    sps.captureStdout(['tar', '-C', dest, '-xjf', os.path.abspath(fn)])
开发者ID:ArashAll,项目名称:funfuzz,代码行数:7,代码来源:downloadBuild.py


示例7: checkBlameParents

def checkBlameParents(repoDir, blamedRev, blamedGoodOrBad, labels, testRev, startRepo, endRepo):
    """If bisect blamed a merge, try to figure out why."""

    bisectLied = False
    missedCommonAncestor = False

    parents = sps.captureStdout(["hg", "-R", repoDir] + ["parent", '--template={node|short},',
                                                         "-r", blamedRev])[0].split(",")[:-1]

    if len(parents) == 1:
        return

    for p in parents:
        # Ensure we actually tested the parent.
        if labels.get(p) is None:
            print ""
            print ("Oops! We didn't test rev %s, a parent of the blamed revision! " +
                   "Let's do that now.") % str(p)
            if not hgCmds.isAncestor(repoDir, startRepo, p) and \
                    not hgCmds.isAncestor(repoDir, endRepo, p):
                print ('We did not test rev %s because it is not a descendant of either ' +
                       '%s or %s.') % (str(p), startRepo, endRepo)
                # Note this in case we later decide the bisect result is wrong.
                missedCommonAncestor = True
            label = testRev(p)
            labels[p] = label
            print label[0] + " (" + label[1] + ") "
            print "As expected, the parent's label is the opposite of the blamed rev's label."

        # Check that the parent's label is the opposite of the blamed merge's label.
        if labels[p][0] == "skip":
            print "Parent rev %s was marked as 'skip', so the regression window includes it." % str(p)
        elif labels[p][0] == blamedGoodOrBad:
            print "Bisect lied to us! Parent rev %s was also %s!" % (str(p), blamedGoodOrBad)
            bisectLied = True
        else:
            assert labels[p][0] == {'good': 'bad', 'bad': 'good'}[blamedGoodOrBad]

    # Explain why bisect blamed the merge.
    if bisectLied:
        if missedCommonAncestor:
            ca = hgCmds.findCommonAncestor(repoDir, parents[0], parents[1])
            print ""
            print "Bisect blamed the merge because our initial range did not include one"
            print "of the parents."
            print "The common ancestor of %s and %s is %s." % (parents[0], parents[1], ca)
            label = testRev(ca)
            print label[0] + " (" + label[1] + ") "
            print "Consider re-running autoBisect with -s %s -e %s" % (ca, blamedRev)
            print "in a configuration where earliestWorking is before the common ancestor."
        else:
            print ""
            print "Most likely, bisect's result was unhelpful because one of the"
            print "tested revisions was marked as 'good' or 'bad' for the wrong reason."
            print "I don't know which revision was incorrectly marked. Sorry."
    else:
        print ""
        print "The bug was introduced by a merge (it was not present on either parent)."
        print "I don't know which patches from each side of the merge contributed to the bug. Sorry."
开发者ID:ArashAll,项目名称:funfuzz,代码行数:59,代码来源:autoBisect.py


示例8: downloadURL

def downloadURL(url, dest):
    """Read in a URL and downloads it to a destination."""
    inpCmdList = ['curl', '--output', dest, url] if useCurl else ['wget'] + wgetMaybeNCC + ['-O', dest, url]
    out, retVal = sps.captureStdout(inpCmdList, combineStderr=True, ignoreExitCode=True)
    if retVal != 0:
        print out
        raise Exception('Return code is not 0, but is: ' + str(retVal))
    return dest
开发者ID:jinyu00,项目名称:funfuzz,代码行数:8,代码来源:downloadBuild.py


示例9: isAncestor

def isAncestor(repoDir, a, b):
    """Return true iff |a| is an ancestor of |b|. Throw if |a| or |b| does not exist."""
    return (
        sps.captureStdout(
            ["hg", "-R", repoDir, "log", "-r", a + " and ancestor(" + a + "," + b + ")", "--template={node|short}"]
        )[0]
        != ""
    )
开发者ID:nth10sd,项目名称:funfuzz,代码行数:8,代码来源:hgCmds.py


示例10: testBinary

def testBinary(shellPath, args, useValgrind):
    '''Tests the given shell with the given args.'''
    testCmd = (constructVgCmdList() if useValgrind else []) + [shellPath] + args
    sps.vdump('The testing command is: ' + sps.shellify(testCmd))
    out, rCode = sps.captureStdout(testCmd, combineStderr=True, ignoreStderr=True,
                                   ignoreExitCode=True, env=envVars.envWithPath(
                                       os.path.dirname(os.path.abspath(shellPath))))
    sps.vdump('The exit code is: ' + str(rCode))
    return out, rCode
开发者ID:jruderman,项目名称:funfuzz,代码行数:9,代码来源:inspectShell.py


示例11: testIsHardFpShellARM

def testIsHardFpShellARM(s):
    '''Tests if the ARM shell is compiled with hardfp support.'''
    readelfBin = '/usr/bin/readelf'
    if os.path.exists(readelfBin):
        newEnv = envVars.envWithPath(os.path.dirname(os.path.abspath(s)))
        readelfOutput = sps.captureStdout([readelfBin, '-A', s], env=newEnv)[0]
        return 'Tag_ABI_VFP_args: VFP registers' in readelfOutput
    else:
        raise Exception('readelf is not found.')
开发者ID:jruderman,项目名称:funfuzz,代码行数:9,代码来源:inspectShell.py


示例12: existsAndIsAncestor

def existsAndIsAncestor(repoDir, a, b):
    """Return true iff |a| exists and is an ancestor of |b|."""
    # Takes advantage of "id(badhash)" being the empty set, in contrast to just "badhash", which is an error
    out = sps.captureStdout(
        ["hg", "-R", repoDir, "log", "-r", a + " and ancestor(" + a + "," + b + ")", "--template={node|short}"],
        combineStderr=True,
        ignoreExitCode=True,
    )[0]
    return out != "" and out.find("abort: unknown revision") < 0
开发者ID:nth10sd,项目名称:funfuzz,代码行数:9,代码来源:hgCmds.py


示例13: diffFiles

def diffFiles(f1, f2):
    """Return a command to diff two files, along with the diff output (if it's short)."""
    diffcmd = ["diff", "-u", f1, f2]
    s = ' '.join(diffcmd) + "\n\n"
    diff = sps.captureStdout(diffcmd, ignoreExitCode=True)[0]
    if len(diff) < 10000:
        s += diff + "\n\n"
    else:
        s += diff[:10000] + "\n(truncated after 10000 bytes)... \n\n"
    return s
开发者ID:jinyu00,项目名称:funfuzz,代码行数:10,代码来源:compareJIT.py


示例14: hgQpopQrmAppliedPatch

def hgQpopQrmAppliedPatch(patchFile, repoDir):
    '''Remove applied patch using `hg qpop` and `hg qdelete`.'''
    qpopOutput, qpopRetCode = sps.captureStdout(['hg', '-R', repoDir, 'qpop'],
                                             combineStderr=True, ignoreStderr=True,
                                             ignoreExitCode=True)
    if qpopRetCode != 0:
        print '`hg qpop` output is: ' + qpopOutput
        raise Exception('Return code from `hg qpop` is: ' + str(qpopRetCode))

    print("Patch qpop'ed..."),
    subprocess.check_call(['hg', '-R', repoDir, 'qdelete', os.path.basename(patchFile)])
    print("Patch qdelete'd.")
开发者ID:ArashAll,项目名称:funfuzz,代码行数:12,代码来源:hgCmds.py


示例15: hgQpopQrmAppliedPatch

def hgQpopQrmAppliedPatch(patchFile, repoDir):
    """Remove applied patch using `hg qpop` and `hg qdelete`."""
    qpopOutput, qpopRetCode = sps.captureStdout(
        ["hg", "-R", repoDir, "qpop"], combineStderr=True, ignoreStderr=True, ignoreExitCode=True
    )
    if qpopRetCode != 0:
        print "`hg qpop` output is: " + qpopOutput
        raise Exception("Return code from `hg qpop` is: " + str(qpopRetCode))

    print "Patch qpop'ed...",
    subprocess.check_call(["hg", "-R", repoDir, "qdelete", os.path.basename(patchFile)])
    print "Patch qdelete'd."
开发者ID:nth10sd,项目名称:funfuzz,代码行数:12,代码来源:hgCmds.py


示例16: compileJs

def compileJs(shell):
    """This function compiles and copies a binary."""
    try:
        cmdList = [MAKE_BINARY, "-C", shell.getJsObjdir(), "-j" + str(COMPILATION_JOBS), "-s"]
        out = sps.captureStdout(
            cmdList, combineStderr=True, ignoreExitCode=True, currWorkingDir=shell.getJsObjdir(), env=shell.getEnvFull()
        )[0]
    except Exception as e:
        # This exception message is returned from sps.captureStdout via cmdList.
        if (sps.isLinux or sps.isMac) and (
            "GCC running out of memory" in repr(e) or "Clang running out of memory" in repr(e)
        ):
            # FIXME: Absolute hack to retry after hitting OOM.
            print "Trying once more due to the compiler running out of memory..."
            out = sps.captureStdout(
                cmdList,
                combineStderr=True,
                ignoreExitCode=True,
                currWorkingDir=shell.getJsObjdir(),
                env=shell.getEnvFull(),
            )[0]
        # A non-zero error can be returned during make, but eventually a shell still gets compiled.
        if os.path.exists(shell.getShellCompiledPath()):
            print "A shell was compiled even though there was a non-zero exit code. Continuing..."
        else:
            print MAKE_BINARY + " did not result in a js shell:"
            raise

    if os.path.exists(shell.getShellCompiledPath()):
        shutil.copy2(shell.getShellCompiledPath(), shell.getShellCacheFullPath())
        for runLib in shell.getShellCompiledRunLibsPath():
            if os.path.isfile(runLib):
                shutil.copy2(runLib, shell.getShellCacheDir())
        if sps.isLinux:
            # Restrict this to only Linux for now. At least Mac OS X needs some (possibly *.a)
            # files in the objdir or else the stacks from failing testcases will lack symbols.
            shutil.rmtree(sps.normExpUserPath(os.path.join(shell.getShellCacheDir(), "objdir-js")))
    else:
        print out
        raise Exception(MAKE_BINARY + " did not result in a js shell, no exception thrown.")
开发者ID:xsysvermin,项目名称:funfuzz,代码行数:40,代码来源:compileShell.py


示例17: archOfBinary

def archOfBinary(binary):
    '''This function tests if a binary is 32-bit or 64-bit.'''
    unsplitFiletype = sps.captureStdout(['file', binary])[0]
    filetype = unsplitFiletype.split(':', 1)[1]
    if sps.isWin:
        assert 'MS Windows' in filetype
        return '32' if 'Intel 80386 32-bit' in filetype else '64'
    else:
        if 'universal binary' in filetype:
            raise Exception("I don't know how to deal with multiple-architecture binaries")
        if '32-bit' in filetype or 'i386' in filetype:
            assert '64-bit' not in filetype
            return '32'
        if '64-bit' in filetype:
            assert '32-bit' not in filetype
            return '64'
开发者ID:jruderman,项目名称:funfuzz,代码行数:16,代码来源:inspectShell.py


示例18: hgFindFixParent

  def hgFindFixParent(self, repoDir, bugNum):
    prevRev = None
    hgOut = captureStdout(['hg', 'log', '-l', '10000', '--template', '{node} {desc}\n'], ignoreStderr=True, currWorkingDir=repoDir)[0].split("\n")
    for line in reversed(hgOut):
      line = line.split(' ', 1)

      if len(line) < 2:
        continue

      rev = line[0][0:12]

      if (line[1].find(str(bugNum)) != -1):
        return prevRev

      prevRev = rev
    return None
开发者ID:mozilla,项目名称:JSBugMon,代码行数:16,代码来源:bugmon.py


示例19: compileNspr

def compileNspr(shell):
    '''Compile a NSPR binary.'''
    cfgBin(shell, 'nspr')
    # Continue to use -j1 because NSPR does not yet seem to support parallel compilation very well.
    # Even if we move to parallel compile NSPR in the future, we must beware of breaking old
    # build during bisection. Maybe find the changeset that fixes this, and if before that, use -j1,
    # and after that, use -jX ?
    nsprCmdList = [MAKE_BINARY, '-C', shell.getNsprObjdir(), '-j1', '-s']
    out = sps.captureStdout(nsprCmdList, combineStderr=True, ignoreExitCode=True,
                            currWorkingDir=shell.getNsprObjdir(), env=shell.getEnvFull())[0]
    for compileLib in inspectShell.ALL_COMPILE_LIBS:
        if not sps.normExpUserPath(os.path.join(shell.getNsprObjdir(), 'dist', 'lib', compileLib)):
            print out
            raise Exception(MAKE_BINARY + " did not result in a NSPR binary.")

    assert os.path.isdir(sps.normExpUserPath(
        os.path.join(shell.getNsprObjdir(), 'dist', 'include', 'nspr')))
开发者ID:RanchoIce,项目名称:funfuzz,代码行数:17,代码来源:compileShell.py


示例20: undmg

def undmg(fn, dest, mountpoint):
    """Extract .dmg files to their destination via a mount point."""
    if os.path.exists(mountpoint):
        # If the mount point already exists, detach it first.
        sps.captureStdout(['hdiutil', 'detach', mountpoint, '-force'])
    sps.captureStdout(['hdiutil', 'attach', '-quiet', '-mountpoint', mountpoint, fn])
    try:
        apps = [x for x in os.listdir(mountpoint) if x.endswith('app')]
        assert len(apps) == 1
        shutil.copytree(mountpoint + '/' + apps[0], dest + '/' + apps[0])
    finally:
        sps.captureStdout(['hdiutil', 'detach', mountpoint])
开发者ID:jinyu00,项目名称:funfuzz,代码行数:12,代码来源:downloadBuild.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python subprocesses.normExpUserPath函数代码示例发布时间:2022-05-27
下一篇:
Python subprocess32.Popen类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap