Skip to content

Commit

Permalink
Improve error handling in prerequisites.py
Browse files Browse the repository at this point in the history
Some subprocess call commands in the script didn't check the actual exit
code. Also replace manual os.chdir() calls with make's --directory (-C)
option.
  • Loading branch information
andreyv authored and stefano-maggiolo committed Nov 5, 2018
1 parent d247b5a commit 4936c02
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions prerequisites.py
Expand Up @@ -195,11 +195,9 @@ def build_isolate():
assert_not_root()

print("===== Compiling isolate")
os.chdir("isolate")
# We make only the executable isolate, otherwise the tool a2x
# is needed and we have to add more compilation dependencies.
subprocess.call(["make", "isolate"])
os.chdir("..")
subprocess.check_call(["make", "-C", "isolate", "isolate"])


def install_isolate():
Expand Down Expand Up @@ -305,9 +303,8 @@ def install():
build()
else:
# Run build() command as not root
if subprocess.call(["sudo", "-E", "-u", real_user,
sys.executable, sys.argv[0], "build"]):
exit(1)
subprocess.check_call(["sudo", "-E", "-u", real_user,
sys.executable, sys.argv[0], "build"])

install_isolate()

Expand Down Expand Up @@ -344,7 +341,7 @@ def install():
print("===== Adding yourself to the %s group" % CMSUSER)
if ask("Type Y if you want me to automatically add "
"\"%s\" to the %s group: " % (real_user, CMSUSER)):
subprocess.call(["usermod", "-a", "-G", CMSUSER, real_user])
subprocess.check_call(["usermod", "-a", "-G", CMSUSER, real_user])
print("""
###########################################################################
### ###
Expand Down

0 comments on commit 4936c02

Please sign in to comment.