Skip to content

Commit 04d3558

Browse files
author
Raul Gutierrez Sanchez
committed
Merge pull request astropy#8 in JWST/jwst-astroquery from release/jwst-astroquery-0.4.X to master
* commit 'fbd117f836b4701af2eb3c5c63265b54336d0ffa': JWSTPCR-135: rephrasing docs JWSTPCR-135: MAST token in login, login_gui, set_token and documentation JWSTPCR-179: e2e tests and JWSTPCR-184: update to CAOM 2.4 JWSTPCR-179: e2e tests and remote_data tested JWSTPCR-179: remote-data tests
2 parents f91c303 + fbd117f commit 04d3558

File tree

6 files changed

+936
-11
lines changed

6 files changed

+936
-11
lines changed

astroquery/jwst/core.py

Lines changed: 50 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
from .data_access import JwstDataHandler
3939

4040
from builtins import isinstance
41+
from astroquery.jwst.token import TokenDialog
4142

4243
__all__ = ['Jwst', 'JwstClass']
4344

@@ -950,7 +951,7 @@ def save_results(self, job, verbose=False):
950951
return self.__jwsttap.save_results(job, verbose)
951952

952953
def login(self, user=None, password=None, credentials_file=None,
953-
verbose=False):
954+
token=None, verbose=False):
954955
"""Performs a login.
955956
TAP+ only
956957
User and password can be used or a file that contains user name and
@@ -966,13 +967,17 @@ def login(self, user=None, password=None, credentials_file=None,
966967
credentials_file : str, mandatory if no 'user' & 'password' are
967968
provided
968969
file containing user and password in two lines
970+
token: str, optional
971+
MAST token to have access to propietary data
969972
verbose : bool, optional, default 'False'
970973
flag to display information about the process
971974
"""
972-
return self.__jwsttap.login(user=user,
973-
password=password,
974-
credentials_file=credentials_file,
975-
verbose=verbose)
975+
self.__jwsttap.login(user=user,
976+
password=password,
977+
credentials_file=credentials_file,
978+
verbose=verbose)
979+
if token:
980+
self.set_token(token)
976981

977982
def login_gui(self, verbose=False):
978983
"""Performs a login using a GUI dialog
@@ -985,6 +990,31 @@ def login_gui(self, verbose=False):
985990
"""
986991
return self.__jwsttap.login_gui(verbose)
987992

993+
def login_token_gui(self, verbose=False):
994+
"""Performs a login using a GUI dialog
995+
TAP+ only, with an additiona field to
996+
specify a token
997+
998+
Parameters
999+
----------
1000+
verbose : bool, optional, default 'False'
1001+
flag to display information about the process
1002+
"""
1003+
connHandler = self.__jwsttap._TapPlus__getconnhandler()
1004+
url = connHandler.get_host_url()
1005+
loginDialog = TokenDialog(url)
1006+
loginDialog.show_login()
1007+
if loginDialog.is_accepted():
1008+
user = loginDialog.get_user()
1009+
pwd = loginDialog.get_password()
1010+
if loginDialog.get_token():
1011+
token = loginDialog.get_token()
1012+
self.login(user=user, password=pwd, token=token,
1013+
verbose=verbose)
1014+
else:
1015+
self.login(user=user, password=pwd, verbose=verbose)
1016+
# execute login
1017+
9881018
def logout(self, verbose=False):
9891019
"""Performs a logout
9901020
TAP+ only
@@ -996,6 +1026,19 @@ def logout(self, verbose=False):
9961026
"""
9971027
return self.__jwsttap.logout(verbose)
9981028

1029+
def set_token(self, token):
1030+
"""Links a MAST token to the logged user
1031+
1032+
Parameters
1033+
----------
1034+
token: str, mandatory
1035+
MAST token to have access to propietary data
1036+
"""
1037+
subcontext = 'session'
1038+
data = 'action=set&key=mast_token&value=' + token
1039+
self.__jwsttap._TapPlus__getconnhandler().execute_tappost(subcontext,
1040+
data)
1041+
9991042
def get_product_list(self, observation_id=None,
10001043
cal_level="ALL",
10011044
product_type=None):
@@ -1122,8 +1165,8 @@ def __get_member_planes(self, planeid, cal_level='ALL'):
11221165
"product_planeid, mp.calibrationlevel as "\
11231166
"product_level FROM {0} o JOIN {1} p on "\
11241167
"o.obsid=p.obsid JOIN {2} m on "\
1125-
"o.obsid=m.compositeid JOIN {0} "\
1126-
"mo on m.simpleid=mo.observationuri JOIN "\
1168+
"o.obsid=m.parentid JOIN {0} "\
1169+
"mo on m.memberid=mo.observationuri JOIN "\
11271170
"{1} mp on mo.obsid=mp.obsid {3}'{4}'"\
11281171
.format(self.JWST_OBSERVATION_TABLE,
11291172
self.JWST_PLANE_TABLE,

0 commit comments

Comments
 (0)