Skip to content

Commit 63987c7

Browse files
“Javierbsipocz
authored andcommitted
Fixes for PR 2140
1 parent 959bac6 commit 63987c7

File tree

5 files changed

+136
-198
lines changed

5 files changed

+136
-198
lines changed

astroquery/esa/jwst/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ class Conf(_config.ConfigNamespace):
2626

2727
JWST_TAP_SERVER = _config.ConfigItem("http://jwstdummytap.com")
2828
JWST_DATA_SERVER = _config.ConfigItem("http://jwstdummydata.com")
29+
JWST_TOKEN = _config.ConfigItem("jwstToken")
30+
JWST_MESSAGES = _config.ConfigItem("notification?action=GetNotifications")
2931

3032
JWST_MAIN_TABLE = _config.ConfigItem("jwst.main", "JWST main table, combination of observation and plane tables.")
3133

astroquery/esa/jwst/core.py

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
import shutil
1515
import tarfile
1616
import zipfile
17-
from urllib.parse import urlencode, quote_plus
1817
from builtins import isinstance
1918
from datetime import datetime
2019

@@ -23,27 +22,26 @@
2322
from astropy.coordinates import SkyCoord
2423
from astropy.table import vstack
2524
from astropy.units import Quantity
26-
from astroquery.exceptions import RemoteServiceError
2725
from requests.exceptions import ConnectionError
28-
from astroquery.utils import send_request
2926

30-
from astroquery.query import BaseQuery
27+
from astroquery.exceptions import RemoteServiceError
3128
from astroquery.ipac.ned import Ned
29+
from astroquery.query import BaseQuery
3230
from astroquery.simbad import Simbad
3331
from astroquery.utils import commons
3432
from astroquery.utils.tap import TapPlus
3533
from astroquery.vizier import Vizier
3634
from . import conf
3735
from .data_access import JwstDataHandler
3836

39-
4037
__all__ = ['Jwst', 'JwstClass']
4138

4239

4340
class JwstClass(BaseQuery):
4441

4542
"""
4643
Proxy class to default TapPlus object (pointing to JWST Archive)
44+
THIS MODULE IS NOT OPERATIVE YET. METHODS WILL NOT WORK UNTIL eJWST ARCHIVE IS OFFICIALLY RELEASED
4745
"""
4846

4947
JWST_DEFAULT_COLUMNS = ['observationid', 'calibrationlevel', 'public',
@@ -60,7 +58,7 @@ class JwstClass(BaseQuery):
6058
CAL_LEVELS = ['ALL', 1, 2, 3, -1]
6159
REQUESTED_OBSERVATION_ID = "Missing required argument: 'observation_id'"
6260

63-
def __init__(self, tap_plus_handler=None, data_handler=None):
61+
def __init__(self, *, tap_plus_handler=None, data_handler=None):
6462
if tap_plus_handler is None:
6563
self.__jwsttap = TapPlus(url=conf.JWST_TAP_SERVER,
6664
data_context='data')
@@ -70,9 +68,9 @@ def __init__(self, tap_plus_handler=None, data_handler=None):
7068
if data_handler is None:
7169
self.__jwstdata = JwstDataHandler(
7270
base_url=conf.JWST_DATA_SERVER)
73-
# self.__jwstdata = self.__jwsttap;
7471
else:
7572
self.__jwstdata = data_handler
73+
print("THIS MODULE IS NOT OPERATIVE YET. METHODS WILL NOT WORK UNTIL eJWST ARCHIVE IS OFFICIALLY RELEASED")
7674

7775
def load_tables(self, *, only_names=False, include_shared_tables=False,
7876
verbose=False):
@@ -677,7 +675,7 @@ def set_token(self, token):
677675
token: str, mandatory
678676
MAST token to have access to propietary data
679677
"""
680-
subContext = "jwstToken"
678+
subContext = conf.JWST_TOKEN
681679
args = {"token": token}
682680
connHandler = self.__jwsttap._TapPlus__getconnhandler()
683681
data = connHandler.url_encode(args)
@@ -689,6 +687,19 @@ def set_token(self, token):
689687
else:
690688
print("MAST token has been set successfully")
691689

690+
def get_status_messages(self):
691+
"""Retrieve the messages to inform users about
692+
the status of JWST TAP
693+
"""
694+
695+
subContext = conf.JWST_MESSAGES
696+
connHandler = self.__jwsttap._TapPlus__getconnhandler()
697+
response = connHandler.execute_tapget(subContext, False)
698+
if response.status == 200:
699+
for line in response:
700+
string_message = line.decode("utf-8")
701+
print(string_message[string_message.index('=')+1:])
702+
692703
def get_product_list(self, *, observation_id=None,
693704
cal_level="ALL",
694705
product_type=None):

astroquery/esa/jwst/tests/test_jwstdata.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,7 @@ def get_product_mock(params, *args, **kwargs):
3131

3232
@pytest.fixture(autouse=True)
3333
def get_product_request(request):
34-
try:
35-
mp = request.getfixturevalue("monkeypatch")
36-
except AttributeError: # pytest < 3
37-
mp = request.getfuncargvalue("monkeypatch")
34+
mp = request.getfixturevalue("monkeypatch")
3835
mp.setattr(JwstClass, '_query_get_product', get_product_mock)
3936
return mp
4037

@@ -43,14 +40,13 @@ class TestData:
4340

4441
def test_get_product(self):
4542
dummyTapHandler = DummyTapHandler()
46-
jwst = JwstClass(dummyTapHandler)
43+
jwst = JwstClass(tap_plus_handler=dummyTapHandler)
4744
# default parameters
4845
parameters = {}
4946
parameters['artifact_id'] = None
5047
with pytest.raises(ValueError) as err:
5148
jwst.get_product()
5249
assert "Missing required argument: 'artifact_id'" in err.value.args[0]
53-
# dummyDataHandler.check_call('get_product', parameters)
5450
# test with parameters
5551
dummyTapHandler.reset()
5652
parameters = {}
@@ -59,8 +55,7 @@ def test_get_product(self):
5955
params_dict['DATA_RETRIEVAL_ORIGIN'] = 'ASTROQUERY'
6056
params_dict['ARTIFACTID'] = '00000000-0000-0000-8740-65e2827c9895'
6157
parameters['params_dict'] = params_dict
62-
parameters['output_file'] = 'jw00617023001_02102_00001_nrcb4_'\
63-
'uncal.fits'
58+
parameters['output_file'] = 'jw00617023001_02102_00001_nrcb4_uncal.fits'
6459
parameters['verbose'] = False
6560
jwst.get_product(artifact_id='00000000-0000-0000-8740-65e2827c9895')
6661
dummyTapHandler.check_call('load_data', parameters)

0 commit comments

Comments
 (0)