changeset 4:8dc420754023

minor upgrades to prepare for streamlining
author Jeff Hammel <k0scist@gmail.com>
date Tue, 23 Aug 2016 16:29:13 -0700
parents d3a4f7b41944
children b407681e6f2c
files fail.py
diffstat 1 files changed, 10 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- 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