Specify 'check' with subprocess.run

This commit is contained in:
Florian Bruhin 2019-10-01 11:54:18 +02:00
parent 2dfe2b170a
commit 21e9b9b41f
8 changed files with 18 additions and 15 deletions

View File

@ -226,7 +226,7 @@ class AsciiDoc:
try:
subprocess.run(['asciidoc'], stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL)
stderr=subprocess.DEVNULL, check=True)
except OSError:
pass
else:
@ -234,7 +234,7 @@ class AsciiDoc:
try:
subprocess.run(['asciidoc.py'], stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL)
stderr=subprocess.DEVNULL, check=True)
except OSError:
pass
else:

View File

@ -222,7 +222,7 @@ def build_mac():
smoke_test(binary)
finally:
time.sleep(5)
subprocess.run(['hdiutil', 'detach', tmpdir])
subprocess.run(['hdiutil', 'detach', tmpdir], check=False)
except PermissionError as e:
print("Failed to remove tempdir: {}".format(e))

View File

@ -25,7 +25,7 @@ import subprocess
import os
code = subprocess.run(['git', '--no-pager', 'diff',
'--exit-code', '--stat']).returncode
'--exit-code', '--stat'], check=False).returncode
if os.environ.get('TRAVIS_PULL_REQUEST', 'false') != 'false':
if code != 0:
@ -43,6 +43,6 @@ if code != 0:
if 'TRAVIS' in os.environ:
print()
print("travis_fold:start:gitdiff")
subprocess.run(['git', '--no-pager', 'diff'])
subprocess.run(['git', '--no-pager', 'diff'], check=True)
print("travis_fold:end:gitdiff")
sys.exit(code)

View File

@ -85,15 +85,15 @@ def main():
# yep, shell=True. I know what I'm doing.
subprocess.run(
'gprof2dot -f pstats {} | dot -Tpng | feh -F -'.format(
shlex.quote(profilefile)), shell=True)
shlex.quote(profilefile)), shell=True, check=True)
elif args.profile_tool == 'kcachegrind':
callgraphfile = os.path.join(tempdir, 'callgraph')
subprocess.run(['pyprof2calltree', '-k', '-i', profilefile,
'-o', callgraphfile])
'-o', callgraphfile], check=True)
elif args.profile_tool == 'snakeviz':
subprocess.run(['snakeviz', profilefile])
subprocess.run(['snakeviz', profilefile], check=True)
elif args.profile_tool == 'tuna':
subprocess.run(['tuna', profilefile])
subprocess.run(['tuna', profilefile], check=True)
shutil.rmtree(tempdir)

View File

@ -75,7 +75,7 @@ def main():
env = os.environ.copy()
env['PYTHONPATH'] = os.pathsep.join(pythonpath)
ret = subprocess.run(['pylint'] + args, env=env).returncode
ret = subprocess.run(['pylint'] + args, env=env, check=False).returncode
return ret

View File

@ -403,12 +403,12 @@ def update_documentation():
try:
subprocess.run(['asciidoc'], stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL)
stderr=subprocess.DEVNULL, check=True)
except OSError:
pytest.skip("Docs outdated and asciidoc unavailable!")
update_script = os.path.join(script_path, 'asciidoc2html.py')
subprocess.run([sys.executable, update_script])
subprocess.run([sys.executable, update_script], check=True)
## Then

View File

@ -325,8 +325,10 @@ def test_command_on_start(request, quteproc_new):
def test_launching_with_python2():
try:
proc = subprocess.run(['python2', '-m', 'qutebrowser',
'--no-err-windows'], stderr=subprocess.PIPE)
proc = subprocess.run(
['python2', '-m', 'qutebrowser', '--no-err-windows'],
stderr=subprocess.PIPE,
check=False)
except FileNotFoundError:
pytest.skip("python2 not found")
assert proc.returncode == 1

View File

@ -39,7 +39,8 @@ def test_python2():
proc = subprocess.run(
['python2', checkpyver.__file__, '--no-err-windows'],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
stderr=subprocess.PIPE,
check=False)
except FileNotFoundError:
pytest.skip("python2 not found")
assert not proc.stdout