Skip to content
Snippets Groups Projects
Commit 59aca06b authored by Thomas Juerges's avatar Thomas Juerges
Browse files

Remove credentials in exceptions thrown by LtaProxy calls

parent e14e0a10
No related branches found
No related tags found
No related merge requests found
......@@ -22,7 +22,7 @@
# !! 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.5"
__version__ = "1.6"
import datetime
import configparser
......@@ -86,44 +86,75 @@ else:
# ---
def remove_credentials_from_exception(exception):
s = str(exception).replace(user + ":" + passw + "@", "")
return s
def stage(surls, send_notifications=True):
""" Stage list of SURLs, optionally enable/disable email notifications """
if isinstance(surls, str):
surls = [surls]
stageid = proxy.LtaStager.add_getid(surls, send_notifications)
try:
stageid = proxy.LtaStager.add_getid(surls, send_notifications)
except xmlrpclib.Error as e:
raise Exception(remove_credentials_from_exception(e))
return stageid
def get_status(stageid):
""" Get status of request with given ID """
return proxy.LtaStager.getstatus(stageid)
try:
return proxy.LtaStager.getstatus(stageid)
except xmlrpclib.Error as e:
raise Exception(remove_credentials_from_exception(e))
def abort(stageid):
""" Abort running request / release data of a finished request with given ID """
return proxy.LtaStager.abort(stageid)
try:
return proxy.LtaStager.abort(stageid)
except xmlrpclib.Error as e:
raise Exception(remove_credentials_from_exception(e))
def get_surls_requested(stageid):
""" Get a list of all files that are requested via a running request with given ID """
return proxy.LtaStager.getrequestedurls(stageid)
try:
return proxy.LtaStager.getrequestedurls(stageid)
except xmlrpclib.Error as e:
raise Exception(remove_credentials_from_exception(e))
def get_surls_pending(stageid):
""" Get a list of all files that are not yet online for a running request with given ID """
return proxy.LtaStager.getoutstandingurls(stageid)
try:
return proxy.LtaStager.getoutstandingurls(stageid)
except xmlrpclib.Error as e:
raise Exception(remove_credentials_from_exception(e))
def get_surls_failed(stageid):
""" Get a list of all files that have failed in a running request with given ID """
return proxy.LtaStager.getfailedurls(stageid)
try:
return proxy.LtaStager.getfailedurls(stageid)
except xmlrpclib.Error as e:
raise Exception(remove_credentials_from_exception(e))
def get_surls_online(stageid):
""" Get a list of all files that are already online for a running request with given ID """
return proxy.LtaStager.getstagedurls(stageid)
try:
return proxy.LtaStager.getstagedurls(stageid)
except xmlrpclib.Error as e:
raise Exception(remove_credentials_from_exception(e))
def get_srm_token(stageid):
""" Get the SRM request token for direct interaction with the SRM site via Grid/SRM tools """
return proxy.LtaStager.gettoken(stageid)
try:
return proxy.LtaStager.gettoken(stageid)
except xmlrpclib.Error as e:
raise Exception(remove_credentials_from_exception(e))
def reschedule(stageid):
""" Reschedule a request with a given ID, e.g. after it was put on hold due to maintenance """
return proxy.LtaStager.reschedule(stageid)
try:
return proxy.LtaStager.reschedule(stageid)
except xmlrpclib.Error as e:
raise Exception(remove_credentials_from_exception(e))
def get_progress(status=None, exclude=False):
""" Get a detailed list of all running requests and their current progress.
......@@ -133,7 +164,10 @@ def get_progress(status=None, exclude=False):
:param exclude: If set to True then the requests with status 'status' are
excluded.
"""
all_requests = proxy.LtaStager.getprogress()
try:
all_requests = proxy.LtaStager.getprogress()
except xmlrpclib.Error as e:
raise Exception(remove_credentials_from_exception(e))
if status is not None and isinstance(status, string_types):
if python_version == 3:
all_items = all_requests.items()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment