From 9df1c98f47db22345015c94521503c367228e12c Mon Sep 17 00:00:00 2001
From: Hal Simpson <hasimpson@usgs.gov>
Date: Thu, 9 Jul 2015 09:22:24 -0600
Subject: [PATCH] added realtime flag

---
 geomagio/Controller.py | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/geomagio/Controller.py b/geomagio/Controller.py
index cd58f27a..47aa15be 100644
--- a/geomagio/Controller.py
+++ b/geomagio/Controller.py
@@ -292,6 +292,16 @@ def main(args):
 
     # TODO check for unused arguments.
 
+    if (args.realtime):
+        now = UTCDateTime()
+        args.endtime = UTCDateTime(now.year, now.month, now.day,
+                now.hour, now.minute)
+        if args.interval == 'minute':
+            args.starttime = args.endtime - 3600
+        else:
+            args.starttime = args.endtime - 600
+        print args.starttime, args.endtime
+
     controller = Controller(inputfactory, outputfactory, algorithm)
 
     if args.update:
@@ -369,6 +379,11 @@ def parse_args(args):
     parser.add_argument('--output-edge-tag',
             default='GEOMAG',
             help='ID Tag for edge connections, defaults to GEOMAG')
+    parser.add_argument('--realtime',
+            action='store_true',
+            default=False,
+            help='Flag to run the last hour if interval is minute' +
+                    'or the last 10 minutes if interval is seconds')
 
     # Input group
     input_group = parser.add_mutually_exclusive_group(required=True)
-- 
GitLab