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

run

parent dbc90929
{
"python.pythonPath": "c:/Python27/python.exe",
"python.linting.enabled": false
"python.linting.enabled": false,
"python.autoComplete.extraPaths": [
"${env.SPARK_HOME}\\python",
"${env.SPARK_HOME}\\python\\pyspark"
]
}
\ No newline at end of file
......@@ -2,6 +2,10 @@
# coding: utf-8
import json
import requests
from requests.auth import HTTPBasicAuth
from time import gmtime, strftime
from datetime import datetime, timedelta
from pprint import pprint
from ConfigParser import SafeConfigParser
......@@ -21,7 +25,7 @@ from ConfigParser import SafeConfigParser
# for v in [custom_validator, EmailValidator()]:
# v(value) # <-----
class Runner:
class Runner(object):
def __init__(self):
settings = SafeConfigParser()
settings.read('run/run.cfg')
......@@ -29,38 +33,39 @@ class Runner:
self.usr = settings.get('misc', 'usr');
self.pwd = settings.get('misc', 'pwd');
def __call__(self):
usr = self.settings.get('misc', 'usr');
pwd = self.settings.get('misc', 'pwd');
print usr, pwd
pprint(helcom_nemo_1)
class HELCOM_NEMO:
def __call__(self, json):
# print json
# # create
# rCreate = requests.post('/'.join([self.url, "workarea", "v2"]), data=None, json = None, auth=HTTPBasicAuth(self.usr, self.pwd))
# wid = rCreate.headers['Location'].split('/')[-1]
# # domain
# rDomain = requests.post('/'.join([self.url, "workarea", "v2", wid, "op", "domain"]), data=None, json = {"domain": "HELCOM_NEMO"}, auth=HTTPBasicAuth(self.usr, self.pwd))
# # setting
# setting = json['setting']
# setting['start'] = datetime.utcnow().strftime("%Y-%m-%d %H:%M")+':00'
# end = datetime.utcnow()
# end += timedelta(hours=json['timeperiod'])
# setting['end'] = end.strftime("%Y-%m-%d %H:%M")+':00'
# rSetting = requests.post('/'.join([self.url, "workarea", "v2", wid, "op", "setting"]), data=None, json = json['setting'], auth=HTTPBasicAuth(self.usr, self.pwd))
# # coordinates
# rCoords = requests.post('/'.join([self.url, "workarea", "v2", wid, "op", "coordinates"]), data=None, json = {"coordinate": json['coordinate']}, auth=HTTPBasicAuth(self.usr, self.pwd))
# run
# rRun = requests.post('/'.join([self.url, "runner", "v2"]), data='workareaId='+wid, json=None, auth=HTTPBasicAuth(self.usr, self.pwd))
wid = 'b1814927-20de-41e1-8d24-9edf6451cba2'
status = requests.get('/'.join([self.url, "runner", "v2", wid, "progress"])).content
print status
class HELCOM_NEMO(Runner):
def __init__(self):
super(HELCOM_NEMO, self).__init__()
with open('run/helcom_nemo_1.json') as helcom_nemo_1_file:
self.helcom_nemo_1 = json.load(helcom_nemo_1_file)
def __call__(self):
super(Runner, self).__call__(value)
'''
#!/bin/bash
. padmrun.properties
WID=`curl -u $USER:$PWD -s -I -X POST $HOST/workarea/v2 | grep Location: | awk {'print $2'} | rev | cut -d/ -f1 | rev | tr -d '\r'`
curl -u $USER:$PWD -X POST -d 'padmVersion=NS03_HIRLAM_2.7&modelSetupVersion=NS03_HIRLAM&forcingVersion=NS03_HIRLAM' $HOST/workarea/v2/$WID/op/version
curl -u $USER:$PWD -X POST -H 'Content-type: application/json' -d '{ "forecastMethod": "HIRLAM", "outletType": "AREA","forwardCalculation": "true", "start": "2016-06-01 00:00:00", "end": "2016-06-01 12:00:00", "calculationType": "Oil classes", "substance": "Medium oils (100-1000 cSt)", "fresh": "true", "winddrag": "0.00", "outletPoints": "3", "depth": "0", "instantaneous": "true", "amount": "100", "amountUnit": "m3", "duration": "24","durationUnit": "hours","uncertainty": "false","calculationMode": "Normal" }' $HOST/workarea/v2/$WID/op/setting
curl -u $USER:$PWD -X POST -H 'Content-type: application/json' -d '{"coordinate":[{"latitude":60.356127978060933,"longitude":26.961650443838113},{"latitude":60.348048724559071,"longitude":26.934164170849897},{"latitude":60.357731733846322,"longitude":26.935840154054311},{"latitude":60.362457652517769,"longitude":26.958385167216541}]}' $HOST/workarea/v2/$WID/op/coordinates
curl -u $USER:$PWD -v -X POST -d 'workareaId='$WID $HOST/runner/v2
echo $WID
'''
return ""
super(HELCOM_NEMO, self).__call__(self.helcom_nemo_1)
def main():
for v in [HELCOM_NEMO()]:
v() # <-----
v() # <-----
print "ok"
if __name__ == "__main__":
main()
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