Commit eda90500 authored by Tomas Pettersson's avatar Tomas Pettersson 🏸

better paths

parent c677c2a3
......@@ -17,6 +17,7 @@ Group: Applications/Webb/System
URL: http://www.smhi.se
Source: padmwsverify.tar
Source1: extras.zip
Requires: python-requests
%description
......@@ -61,6 +62,8 @@ mv run${SMHI_MODE}.cfg run/run.cfg
chmod 400 run/run.cfg
rm -f run{utv,test,prod,demo}.cfg
chmod +x main.sh
chmod +x run/run.py
case "$SMHI_MODE" in
prod)
......
0
\ No newline at end of file
1
\ No newline at end of file
......@@ -7,13 +7,14 @@ import requests
from requests.auth import HTTPBasicAuth
from time import time, strftime, sleep
from datetime import datetime, timedelta
from pprint import pprint
from ConfigParser import SafeConfigParser
global path
class Runner(object):
def __init__(self):
settings = SafeConfigParser()
settings.read('run/run.cfg')
settings.read(path+'/run.cfg')
self.url = settings.get('misc', 'url');
self.usr = settings.get('misc', 'usr');
self.pwd = settings.get('misc', 'pwd');
......@@ -47,10 +48,10 @@ class Runner(object):
end = time()
# done
hasError = requests.get('/'.join([self.url, "workarea", "v2", wid, "error.txt"])).status_code == 200
with open('run/output/'+name+'.txt', 'w') as outputfile:
with open(path+'/output/'+name+'.txt', 'w') as outputfile:
if (status != 'COMPLETE') or hasError:
outputfile.write('0')
with open('run/output/'+name+'_'+datetime.utcnow().strftime("%Y%m%d%H%M")+'.txt', 'w') as errorfile:
with open(path+'/output/'+name+'_'+datetime.utcnow().strftime("%Y%m%d%H%M")+'.txt', 'w') as errorfile:
errorfile.write(wid)
else:
outputfile.write('1')
......@@ -59,7 +60,7 @@ class HELCOM_NEMO(Runner):
def __init__(self, value):
super(HELCOM_NEMO, self).__init__()
self.name = 'helcom_nemo_'+str(value)
with open('run/input/'+self.name+'.json') as file:
with open(path+'/input/'+self.name+'.json') as file:
self.jdata = json.load(file)
def __call__(self):
super(HELCOM_NEMO, self).__call__(self.jdata, self.name, "HELCOM_NEMO")
......@@ -68,7 +69,7 @@ class BF_NEMO(Runner):
def __init__(self, value):
super(BF_NEMO, self).__init__()
self.name = 'bf_nemo_'+str(value)
with open('run/input/'+self.name+'.json') as file:
with open(path+'/input/'+self.name+'.json') as file:
self.jdata = json.load(file)
def __call__(self):
super(BF_NEMO, self).__call__(self.jdata, self.name, "BF_NEMO")
......@@ -77,7 +78,7 @@ class VN_NEMO(Runner):
def __init__(self, value):
super(VN_NEMO, self).__init__()
self.name = 'vn_nemo_'+str(value)
with open('run/input/'+self.name+'.json') as file:
with open(path+'/input/'+self.name+'.json') as file:
self.jdata = json.load(file)
def __call__(self):
super(VN_NEMO, self).__call__(self.jdata, self.name, "VN_NEMO")
......@@ -94,7 +95,12 @@ def main():
except Exception as error:
print error
sys.exit(1)
'''
To run in terminal call with python run/run.py run
'''
if __name__ == "__main__":
path = '.'
if (len(sys.argv) > 1):
path = sys.argv[1]
main()
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment