Commit 9bd20b44 authored by Thomas Jürges's avatar Thomas Jürges

Add API for on-hold and running items

parent f411cc01
......@@ -7,11 +7,12 @@
# !! This is to ensure that when we change the remote interface, your scripts don't break and you will only have to
# !! upgrade this module.
__version__ = "1.0"
__version__ = "1.1"
import xmlrpclib
import datetime
from os.path import expanduser
from astropy.utils.compat.futures import process
#---
# Determine credentials and create proxy
......@@ -32,7 +33,7 @@ except IOError:
if line.startswith("user"):
user = line.split('=')[1].strip()
if line.startswith("password"):
passw = line.split('=')[1].strip()
passw = line.split('=', 1)[1].strip()
print datetime.datetime.now(), "stager_access: Creating proxy"
proxy = xmlrpclib.ServerProxy("https://"+user+':'+passw+"@webportal.astron.nl/service-public/xmlrpc")
......@@ -86,3 +87,39 @@ def prettyprint(dictionary, indent=""):
else:
print "stager_access: This prettyprint takes a dict only!"
def get_progress_on_hold():
""" Get a detailed list of all running requests that have a status 'on hold' and
their current progress. As a normal user, this only returns your own requests.
"""
requests = get_progress()
requests_on_hold = {key: value for key, value in requests.iteritems() if value["Status"] == "on hold"}
return requests_on_hold
def reschedule_on_hold():
""" Get a detailed list of all running requests that have a status other than 'success' and
their current progress. As a normal user, this only returns your own requests.
"""
requests_on_hold = get_progress_on_hold()
for key in requests_on_hold.keys():
reschedule(int(key))
def print_on_hold():
"""Print a list of all requests that are on hold.
"""
requests_on_hold = get_progress_on_hold()
prettyprint(requests_on_hold)
def get_running():
"""Return a list of requests that are currently executed and do not have a
status of "success".
"""
requests = get_progress()
requests_running = {key: value for key, value in requests.iteritems() if value["Status"] != "success"}
return requests_running
def print_running():
"""Print a list of requests that are currently executed and do not have a
status of "success"
"""
requests_running = get_running()
prettyprint(requests_running)
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