Commit 4b7be979 authored by Carlo Ferrigno's avatar Carlo Ferrigno
Browse files

Use of legacy dispatcher for timeservices

Introduced token and integral_data_rights parameter in wrapper construction.
parent e857fe26
......@@ -19,6 +19,7 @@ __all__ = ['INTEGRALwrapper']
# Hopefully, this is stable enough
oda_public_host = 'https://www.astro.unige.ch/mmoda/dispatch-data'
legacy_oda_public_host = 'https://www.astro.unige.ch/cdci/astrooda/dispatch-data'
@logged
class INTEGRALwrapper(object):
......@@ -27,9 +28,11 @@ class INTEGRALwrapper(object):
# - product is compatible with oda_api
# - the list of science windows can be ordered
def __init__(self, host_type='production'):
def __init__(self, host_type='production', token='', integral_data_rights='public'):
self.product = 'None'
self.token = token
self.integral_data_rights = integral_data_rights
instrument = 'isgri'
# if('jemx' in product):
......@@ -124,6 +127,19 @@ class INTEGRALwrapper(object):
else:
local_arguments['osa_version'] = arguments['osa_version']
if self.token != '' and 'token' not in arguments:
local_arguments.update({'token': self.token})
self.__log.debug("Inserted token in local arguments")
else:
self.__log.debug("token present in input arguments or not defined")
if 'integral_data_rights' not in arguments:
local_arguments.update({'integral_data_rights': self.integral_data_rights})
self.__log.debug("Inserted integral_data_rights in local arguments")
else:
self.__log.debug("integral_data_rights present in input arguments")
scw_list_str = ",".join([s for s in sorted(set(scw_list))])
self.__log.debug(f"Is submitted: {_disp.is_submitted}")
if not _disp.is_submitted:
......@@ -1136,7 +1152,7 @@ class INTEGRALwrapper(object):
def get_pointings(ra, dec, radius, tstart='2003-01-01T00:00:00', tstop='2020-04-01T00:00:00', type='cons',
min_good_isgri=500):
url = oda_public_host + '/gw/timesystem/api/v1.0/scwlist/' + type + '/'
url = legacy_oda_public_host + '/gw/timesystem/api/v1.0/scwlist/' + type + '/'
url += tstart + '/' + tstop + '?'
url += 'ra=%.4f&dec=%.4f&radius=%.2f&min_good_isgri=%.0f&return_columns=SWID,RA_SCX,DEC_SCX' % (
ra, dec, radius, min_good_isgri)
......@@ -1159,7 +1175,7 @@ class INTEGRALwrapper(object):
@staticmethod
def get_utc_from_revnum(revnum):
url = oda_public_host + '/gw/timesystem/api/v1.0/converttime/REVNUM/%04d/IJD' % revnum
url = legacy_oda_public_host + '/gw/timesystem/api/v1.0/converttime/REVNUM/%04d/IJD' % revnum
ijd = requests.get(url).json()
ijd_start = ijd.split()[1]
ijd_stop = ijd.split()[2]
......@@ -1172,7 +1188,7 @@ class INTEGRALwrapper(object):
@staticmethod
def converttime(informat, intime, outformat, debug=True):
import time
url = oda_public_host + '/gw/timesystem/api/v1.0/converttime/' + \
url = legacy_oda_public_host + '/gw/timesystem/api/v1.0/converttime/' + \
informat + '/' + t2str(intime) + '/' + outformat
ntries_left = 3
......
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