Commit 6bfdc0c9 authored by Marco Govoni's avatar Marco Govoni
Browse files

Merge branch 'westpy-restpy-cherry-test' into 'west-restpy-cherry'

Added Status and File Size checks

See merge request west-tutorial/westpy!1
parents e29b285f d1cc0849
...@@ -15,10 +15,11 @@ class Session(object): ...@@ -15,10 +15,11 @@ class Session(object):
# #
# --- CONFIGURABLE PARAMETERS --- # --- CONFIGURABLE PARAMETERS ---
self.serverName = "imedevel.uchicago.edu" self.serverName = "imedevel.uchicago.edu"
self.restAPIinit = "http://imedevel.uchicago.edu:8000/getSessionId" self.restAPIinit = "http://imedevel.uchicago.edu:8000/init"
self.restAPIrun = "http://imedevel.uchicago.edu:8000/runWestCode" self.restAPIrun = "http://imedevel.uchicago.edu:8000/run"
self.restAPIstop = "http://imedevel.uchicago.edu:8000/stopSession" self.restAPIstop = "http://imedevel.uchicago.edu:8000/stop"
self.maxSessionTime = 1800 # seconds self.restAPIstatus = "http://imedevel.uchicago.edu:8000/status"
self.maxSessionTime = 3600 # seconds
self.maxWaitTime = 1800 # seconds self.maxWaitTime = 1800 # seconds
self.maxNumberOfCores = 4 self.maxNumberOfCores = 4
self.allowedExecutables = ["pw","wstat","wfreq"] self.allowedExecutables = ["pw","wstat","wfreq"]
...@@ -80,7 +81,28 @@ class Session(object): ...@@ -80,7 +81,28 @@ class Session(object):
except Exception as e: except Exception as e:
print('The server is not responding.',e) print('The server is not responding.',e)
return json.loads(response.text) return json.loads(response.text)
def status(self):
"""Returns whether the session is active and time left.
:Example:
>>> from westpy import *
>>> session = Session("email@domain.com")
>>> session.status()
"""
import requests
import json
#
headers = {'Content-Type':'application/json; charset=utf-8','emailId':self.emailId,'token':self.token}
try:
response = requests.get(self.restAPIstatus, headers=headers, timeout=None)
except Exception as e:
print('The server is not responding.',e)
return json.loads(response.text)
def run(self,executable=None,inputFile=None,outputFile=None,downloadUrl=[],number_of_cores=2) : def run(self,executable=None,inputFile=None,outputFile=None,downloadUrl=[],number_of_cores=2) :
"""Runs the executable on the remote server. """Runs the executable on the remote server.
......
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