Skip to content
Snippets Groups Projects

feat: subprocess.run should check return code or check=True

Merged Wouter Deconinck requested to merge subprocess-run-check-true into master
4 files
+ 14
14
Compare changes
  • Side-by-side
  • Inline
Files
4
@@ -77,7 +77,7 @@ if 'sim' in procs:
'--angmin', '{}'.format(args.amin), '--angmax', '{}'.format(args.amax),
'--pmin', '{}'.format(args.pmin), '--pmax', '{}'.format(args.pmax),
'--particles', args.particles]
subprocess.run(gen_cmd)
subprocess.run(gen_cmd, check=True)
# simulation
sim_cmd = ['ddsim',
'--part.minimalKineticEnergy', '1*TeV',
@@ -94,7 +94,7 @@ if 'sim' in procs:
if return_code is not None and return_code < 0:
print("ERROR running simulation!")
exit(1)
subprocess.run(['rootls', '-t', sim_file])
subprocess.run(['rootls', '-t', sim_file], check=True)
if 'rec' in procs:
@@ -110,7 +110,7 @@ if 'rec' in procs:
if return_code is not None and return_code < 0:
print('ERROR running juggler ({})!'.format(opt))
exit(1)
process = subprocess.run(['rootls', '-t', rec_file])
process = subprocess.run(['rootls', '-t', rec_file], check=True)
if 'ana' in procs:
@@ -127,7 +127,7 @@ if 'ana' in procs:
# upload generated data files if it was small enough (< 10 Mb)
for upload in [rec_file]:
process = subprocess.run(['stat', '--format=%s', upload], stdout=subprocess.PIPE)
process = subprocess.run(['stat', '--format=%s', upload], check=True, stdout=subprocess.PIPE)
size = int(process.stdout)/1024./1024.
if size > args.uploadSizeLimit:
print('Skip uploading file \"{}\" because its size ({:.2f} Mb) > {:.2f} Mb'\
Loading