# HG changeset patch # User Jeff Hammel # Date 1471994953 25200 # Node ID 8dc42075402381bdf8651e0f825f8a62bb4baf77 # Parent d3a4f7b41944b1cbeeef80528b63e57aee926182 minor upgrades to prepare for streamlining diff -r d3a4f7b41944 -r 8dc420754023 fail.py --- a/fail.py Tue Aug 23 15:39:06 2016 -0700 +++ b/fail.py Tue Aug 23 16:29:13 2016 -0700 @@ -18,7 +18,7 @@ parser = argparse.ArgumentParser(description=__doc__) parser.add_argument('command', help="command to run") parser.add_argument('--code', dest='codes', default=(0,), nargs='+', - help="allowed exit codes") + help="allowed exit codes [DEFAULT: 0]") parser.add_argument('-s', '--sleep', dest='sleep', type=float, default=1., help="sleep between iterations [DEFAULT: %(default)s]") @@ -26,16 +26,20 @@ try: + # main loop ctr = 0 + start_loop = time.time() while True: + # note program start time + program_start_time = time.time() if ctr else start_loop + + # run the subcommand + process = subprocess.Popen(options.command, shell=True) + stdout, stderr = process.communicate() ctr += 1 - # run it - process = subprocess.Popen(options.command, shell=True) - _, _ = process.communicate() - - + # print iteration information print ("Iteration {}".format(ctr)) # test it