tree-wide: always explicitly pass check to subprocess.run

pylint recently started recommending this.
This commit is contained in:
Lars Karlitski 2019-09-24 16:11:53 +02:00 committed by Tom Gundersen
parent ff8b21ae22
commit cd59b94ded
5 changed files with 22 additions and 17 deletions

View file

@ -36,11 +36,11 @@ def main(tree, options):
mount -o bind /sys {tree}/sys
mount -o bind /proc {tree}/proc
"""
returncode = subprocess.run(["/bin/sh", "-c", script]).returncode
if returncode != 0:
print(f"setting up API VFS in target tree failed: {returncode}")
return returncode
try:
subprocess.run(["/bin/sh", "-c", script], check=True)
except subprocess.CalledProcessError as err:
print(f"setting up API VFS in target tree failed: {err.returncode}")
return err.returncode
cmd = [
"dnf", "-yv",

View file

@ -18,7 +18,7 @@ def main(tree, options):
os.chmod(scriptfile, 0o550)
atexit.register(lambda: os.unlink(scriptfile))
return subprocess.run(["chroot", tree, "/osbuild-script"]).returncode
return subprocess.run(["chroot", tree, "/osbuild-script"], check=False).returncode
if __name__ == '__main__':

View file

@ -36,11 +36,11 @@ def main(tree, options):
mount -t sysfs none {tree}/sys
mount -t proc none {tree}/proc
"""
returncode = subprocess.run(["/bin/sh", "-c", script]).returncode
if returncode != 0:
print(f"setting up API VFS in target tree failed: {returncode}")
return returncode
try:
subprocess.run(["/bin/sh", "-c", script], check=True)
except subprocess.CalledProcessError as err:
print(f"setting up API VFS in target tree failed: {err.returncode}")
return err.returncode
cmd = [
"yum", "-y", "-v",
@ -53,7 +53,7 @@ def main(tree, options):
] + packages
print(" ".join(cmd), flush=True)
return subprocess.run(cmd).returncode
return subprocess.run(cmd, check=False).returncode
if __name__ == '__main__':