Add stricter requirement that callable returns 0 or None.
Not just any falsey value will do.
This commit is contained in:
parent
19ce9fea03
commit
c8fc83dacf
1 changed files with 8 additions and 2 deletions
10
rarpar.py
10
rarpar.py
|
@ -190,6 +190,13 @@ def normalize_volume(volume, pathsize):
|
||||||
return volume
|
return volume
|
||||||
|
|
||||||
def run_script(script, dry=False):
|
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
|
status = 0
|
||||||
|
|
||||||
if dry:
|
if dry:
|
||||||
|
@ -203,8 +210,7 @@ def run_script(script, dry=False):
|
||||||
status = os.system(command)
|
status = os.system(command)
|
||||||
else:
|
else:
|
||||||
status = command()
|
status = command()
|
||||||
status = status or 0
|
if status not in [0, None]:
|
||||||
if status != 0:
|
|
||||||
break
|
break
|
||||||
|
|
||||||
return status
|
return status
|
||||||
|
|
Loading…
Reference in a new issue