Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/342.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/mercurial/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python hg验证不';t返回0或1_Python_Mercurial_Popen - Fatal编程技术网

Python hg验证不';t返回0或1

Python hg验证不';t返回0或1,python,mercurial,popen,Python,Mercurial,Popen,根据帮助 $ hg -v help verify hg verify verify the integrity of the repository Verify the integrity of the current repository. This will perform an extensive check of the repository's integrity, validating the hashes and checksums of each e

根据帮助

$ hg -v help verify
hg verify

verify the integrity of the repository

    Verify the integrity of the current repository.

    This will perform an extensive check of the repository's integrity,
    validating the hashes and checksums of each entry in the changelog,
    manifest, and tracked files, as well as the integrity of their crosslinks
    and indices.

    Returns 0 on success, 1 if errors are encountered.
控制台输出

>>> from subprocess import Popen, PIPE
>>> p = Popen(['hg', 'verify', '-R', 'sample-master'], stdout=PIPE, stdin=PIPE)
>>> out, err = p.communicate()
>>> out
'checking changesets\nchecking manifests\ncrosschecking files in changesets and manifests\nchecking files\n2186 files, 214 changesets, 3055 total revisions\n'
>>> err
>>> """-q is quite suppress output"""
>>> p = Popen(['hg', 'verify', '-R', 'sample-master', '-q'], stdout=PIPE, stdin=PIPE)
>>> out, err = p.communicate()
>>> out
''
我现在损坏了
.hg/store

>>> out, err = Popen(['hg', 'verify', '-R', 'sample-master', '-q'], stdout=PIPE, stdin=PIPE, stderr=PIPE).communicate()
>>> out, err
('', ' data/req.txt.i@119: missing revlog!\n 119: empty or missing req.txt\n req.txt@119: 8befed264a2f in manifests not found\n3 integrity errors encountered!\n(first damaged changeset appears to be 119)\n')
我看不到0或1。我错过什么了吗

谢谢。

您正在寻找:


该文档是指该流程的流程。

Ah。我从来不知道。所以习惯于读标准输入法和标准输出法。困惑的现在我学到了一些东西。非常感谢。@cppnearner--如果您想要从
sh
样式的shell中最后执行的程序返回代码,您可以从
$?
@mgilson获得它,只需向Popen提供
$?
。@cppnearner:不,如果您在shell中运行
hg verify
,并且想要返回代码,您将使用
$?
。在Python中使用
returncode
:-)@马蒂扬皮特斯:好的。我现在明白了。谢谢你教育我:)
p = Popen(['hg', 'verify', '-R', 'natrium-master', '-q'], stdout=PIPE, stdin=PIPE)
out, err = p.communicate()
print p.returncode