From 403cbf16d2d90a1ef8786bd429ef67bb7b860528 Mon Sep 17 00:00:00 2001
From: Anne Philipp <anne.philipp@univie.ac.at>
Date: Fri, 16 Nov 2018 23:27:15 +0100
Subject: [PATCH] added header writing to marsrequest file and corrected bug in
 normalexit call in submit

---
 source/python/mods/get_mars_data.py | 21 ++++++++++++++++++---
 source/python/submit.py             |  2 +-
 2 files changed, 19 insertions(+), 4 deletions(-)

diff --git a/source/python/mods/get_mars_data.py b/source/python/mods/get_mars_data.py
index b48859e..4f05a7c 100755
--- a/source/python/mods/get_mars_data.py
+++ b/source/python/mods/get_mars_data.py
@@ -73,6 +73,7 @@ from tools import (my_error, normal_exit, get_cmdline_arguments,
                    read_ecenv, make_dir)
 from classes.EcFlexpart import EcFlexpart
 from classes.UioFiles import UioFiles
+from classes.MarsRetrieval import MarsRetrieval
 
 try:
     ecapi = True
@@ -130,10 +131,24 @@ def get_mars_data(c):
     if not os.path.exists(c.inputdir):
         make_dir(c.inputdir)
 
-    if c.request == 0 or c.request == 2:
+    if c.request == 0:
         print("Retrieving EC data!")
-    elif c.request == 1:
-        print("Printing mars requests!")
+    else:
+        if c.request == 1:
+            print("Printing mars requests!")
+        elif c.request == 2:
+            print("Retrieving EC data and printing mars request!")
+        # first, write header with the mars parameter to file
+        # create a dummy MarsRetrieval to get parameter
+        MR = MarsRetrieval(None, None)
+        attrs = vars(MR).copy()
+        del attrs['server']
+        del attrs['public']
+        marsfile = os.path.join(c.inputdir, _config.FILE_MARS_REQUESTS)
+        with open(marsfile, 'w') as f:
+            f.write('request_number' + ', ')
+            f.write(', '.join(str(key) for key in sorted(attrs.iterkeys())))
+            f.write('\n')
 
     print("start date %s " % (c.start_date))
     print("end date %s " % (c.end_date))
diff --git a/source/python/submit.py b/source/python/submit.py
index 4f80b28..3a23c2a 100755
--- a/source/python/submit.py
+++ b/source/python/submit.py
@@ -100,7 +100,7 @@ def main():
     else:
         submit(args.job_template, c, args.queue)
 
-    normal_exit(c.mailops, c.queue, exit_message)
+    normal_exit(exit_message)
 
     return
 
-- 
GitLab