From 65704e57fdf6be23ab799c4e27cbf2466f0c5f66 Mon Sep 17 00:00:00 2001
From: Karim Ahmed <karim.ahmed@xfel.eu>
Date: Tue, 16 Jul 2019 14:47:03 +0200
Subject: [PATCH] timeout and parseargs help msgs

---
 reportservice/automatic_run.py  | 18 +++++++++++++-----
 reportservice/manual_run.py     | 22 ++++++++++++++++------
 reportservice/report_service.py | 12 +++++++++---
 3 files changed, 38 insertions(+), 14 deletions(-)

diff --git a/reportservice/automatic_run.py b/reportservice/automatic_run.py
index 0f3b79cac..854528dc3 100644
--- a/reportservice/automatic_run.py
+++ b/reportservice/automatic_run.py
@@ -9,7 +9,7 @@ import yaml
 import zmq
 import zmq.asyncio
 
-async def auto_run(cfg):
+async def auto_run(cfg, timeout=3000):
     """
     Run the report service automatically depending on the scheduled times
     in the run_time list, read from the config yaml file (report_conf.yaml)
@@ -38,6 +38,8 @@ async def auto_run(cfg):
             con = zmq.asyncio.Context()
             sock = con.socket(zmq.REQ)
             port = cfg['GLOBAL']['server-port']
+            sock.SNDTIMEO = timeout
+            sock.RCVTIMEO = timeout
             sock.connect(port)
             await sock.send_pyobj(['all'])
             msg = await sock.recv_pyobj()
@@ -51,14 +53,20 @@ async def auto_run(cfg):
 
         # check every 10mins, if there is 
         # a need for an automatic-run.
-        await asyncio.sleep(600)
+        await asyncio.sleep(3000)
 
 
 arg_parser = argparse.ArgumentParser(description='Automatic Launch')
-arg_parser.add_argument('--config-file', type=str, default='./report_conf.yaml')
-arg_parser.add_argument('--log-file', type=str, default='./report.log')
+arg_parser.add_argument('--config-file', type=str, 
+                        default='./report_conf.yaml',
+                        help='config file path with reportservice port. '
+                             'Default=./report_conf.yaml')
+arg_parser.add_argument('--log-file', type=str, default='./report.log',
+                        help='The report log file path. Default=./report.log')
 arg_parser.add_argument('--logging', type=str, default="INFO",
-                    choices=['INFO', 'DEBUG', 'ERROR'])
+                        help='logging modes: INFO, DEBUG or ERROR. '
+                             'Default=INFO',
+                        choices=['INFO', 'DEBUG', 'ERROR'])
 
 if __name__ == "__main__":
     args = vars(arg_parser.parse_args())
diff --git a/reportservice/manual_run.py b/reportservice/manual_run.py
index 2c6b9293d..87f442f19 100644
--- a/reportservice/manual_run.py
+++ b/reportservice/manual_run.py
@@ -33,13 +33,23 @@ def manual_run(request, cfg):
     logging.info('{} Manual Run'.format(msg))
 
 arg_parser = argparse.ArgumentParser(description='Manual Launch')
-arg_parser.add_argument('--instrument', default=['all'], nargs='+')
-arg_parser.add_argument('--testing', dest='testing', action='store_true')
+arg_parser.add_argument('--instrument', default=['all'], nargs='+',
+                        help='select the requested instruments. '
+                             'Default=all')
+arg_parser.add_argument('--testing', dest='testing', action='store_true',
+                        help='required for testing with different'
+                             'config files')
 arg_parser.set_defaults(testing=False)
-arg_parser.add_argument('--config-file', type=str, default='./report_conf.yaml')
-arg_parser.add_argument('--log-file', type=str, default='./report.log')
-arg_parser.add_argument('--logging', type=str, default="INFO",
-                    choices=['INFO', 'DEBUG', 'ERROR'])
+arg_parser.add_argument('--config-file', type=str, 
+                        default='./report_conf.yaml',
+                        help='config file path with reportservice port. '
+                             'Default=./report_conf.yaml')
+arg_parser.add_argument('--log-file', type=str, default='./report.log',
+                        help='The report log file path. Default=./report.log')
+arg_parser.add_argument('--logging', type=str, default="INFO", 
+                        help='logging modes: INFO, DEBUG or ERROR. '
+                             'Default=INFO',
+                        choices=['INFO', 'DEBUG', 'ERROR'])
 
 if __name__ == "__main__":
     args = vars(arg_parser.parse_args())
diff --git a/reportservice/report_service.py b/reportservice/report_service.py
index c39b0e7d7..11dd134f8 100644
--- a/reportservice/report_service.py
+++ b/reportservice/report_service.py
@@ -269,10 +269,16 @@ async def server_runner(config):
             break
 
 arg_parser = argparse.ArgumentParser(description='Start the report service')
-arg_parser.add_argument('--config-file', type=str, default='./report_conf.yaml')
-arg_parser.add_argument('--log-file', type=str, default='./report.log')
+arg_parser.add_argument('--config-file', type=str,
+			default='./report_conf.yaml',
+                        help='config file path with reportservice port. '
+                             'Default=./report_conf.yaml')
+arg_parser.add_argument('--log-file', type=str, default='./report.log',
+                        help='The report log file path. Default=./report.log')
 arg_parser.add_argument('--logging', type=str, default="INFO",
-                    choices=['INFO', 'DEBUG', 'ERROR'])
+                        help='logging modes: INFO, DEBUG or ERROR. '
+                             'Default=INFO',
+                    	choices=['INFO', 'DEBUG', 'ERROR'])
 
 if __name__ == "__main__":
     args = vars(arg_parser.parse_args())
-- 
GitLab