From c8fc83dacf36cc01b4ffbec3c029cd2e84de79f6 Mon Sep 17 00:00:00 2001 From: Ethan Dalool Date: Wed, 24 Jun 2020 22:26:27 -0700 Subject: [PATCH] Add stricter requirement that callable returns 0 or None. Not just any falsey value will do. --- rarpar.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/rarpar.py b/rarpar.py index 1c3d365..da4af11 100644 --- a/rarpar.py +++ b/rarpar.py @@ -190,6 +190,13 @@ def normalize_volume(volume, pathsize): return volume def run_script(script, dry=False): + ''' + `script` can be a list of strings, which are command line commands, or + callable Python functions. They will be run in order, and the sequence + will terminate if any step returns a bad status code. Your Python functions + must return either 0 or None to be considered successful, all other return + values will be considered failures. + ''' status = 0 if dry: @@ -203,8 +210,7 @@ def run_script(script, dry=False): status = os.system(command) else: status = command() - status = status or 0 - if status != 0: + if status not in [0, None]: break return status