changeset 207:04c5464355b8

monitor
author Jeff Hammel <k0scist@gmail.com>
date Tue, 27 Jan 2015 12:21:45 -0800
parents d9d7bfdb54db
children f7f7831f7c8c
files makeitso/python_package/{{package}}/{{main}}.py
diffstat 1 files changed, 14 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/makeitso/python_package/{{package}}/{{main}}.py	Fri Nov 21 14:36:17 2014 -0800
+++ b/makeitso/python_package/{{package}}/{{main}}.py	Tue Jan 27 12:21:45 2015 -0800
@@ -10,6 +10,7 @@
 import os
 import subprocess
 import sys
+import time
 
 # module globals
 __all__ = ['main', 'Parser']
@@ -32,6 +33,9 @@
         kwargs.setdefault('formatter_class', argparse.RawTextHelpFormatter)
         kwargs.setdefault('description', __doc__)
         argparse.ArgumentParser.__init__(self, **kwargs)
+        self.add_argument('--monitor', dest='monitor',
+                          type=float, metavar='SLEEP',
+                          help="run in monitor mode")
         self.options = None
 
     def parse_args(self, *args, **kw):
@@ -50,5 +54,15 @@
     parser = Parser()
     options = parser.parse_args(args)
 
+    try:
+        while True:
+            if options.monitor:
+                time.sleep(options.monitor)
+            else:
+                break
+    except KeyboardInterrupt:
+        pass
+
 if __name__ == '__main__':
     main()
+