Skip to content

Commit 3990021

Browse files
mhsarmientobsipocz
authored andcommitted
Moved GAIA_MESSAGES from __init__.py to core.py.
Renamed "show_messages" by "show_server_messages" Corrected test case as it was not contemplating the user case in which Gaia archive is down for maintenance.
1 parent 9397b78 commit 3990021

File tree

3 files changed

+19
-20
lines changed

3 files changed

+19
-20
lines changed

astroquery/gaia/__init__.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,6 @@ class Conf(_config.ConfigNamespace):
3939
'MCMC_GSPPHOT',
4040
'MCMC_MSC']
4141

42-
GAIA_MESSAGES = _config.ConfigItem("notification?action=GetNotifications", "Gaia Messages")
43-
4442

4543
conf = Conf()
4644

astroquery/gaia/core.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,15 @@ class GaiaClass(TapPlus):
4545
MAIN_GAIA_TABLE_DEC = conf.MAIN_GAIA_TABLE_DEC
4646
ROW_LIMIT = conf.ROW_LIMIT
4747
VALID_DATALINK_RETRIEVAL_TYPES = conf.VALID_DATALINK_RETRIEVAL_TYPES
48+
GAIA_MESSAGES = "notification?action=GetNotifications"
4849

4950
def __init__(self, tap_plus_conn_handler=None,
5051
datalink_handler=None,
5152
gaia_tap_server='https://gea.esac.esa.int/',
5253
gaia_data_server='https://gea.esac.esa.int/',
5354
tap_server_context="tap-server",
5455
data_server_context="data-server",
55-
verbose=False, show_messages=True):
56+
verbose=False, show_server_messages=True):
5657
super(GaiaClass, self).__init__(url=gaia_tap_server,
5758
server_context=tap_server_context,
5859
tap_context="tap",
@@ -76,7 +77,7 @@ def __init__(self, tap_plus_conn_handler=None,
7677
self.__gaiadata = datalink_handler
7778

7879
# Enable notifications
79-
if show_messages:
80+
if show_server_messages:
8081
self.get_status_messages()
8182

8283
def login(self, user=None, password=None, credentials_file=None,
@@ -921,18 +922,18 @@ def get_status_messages(self):
921922
the status of Gaia TAP
922923
"""
923924
try:
924-
print("parsing notification messages")
925-
subContext = conf.GAIA_MESSAGES
925+
subContext = self.GAIA_MESSAGES
926926
connHandler = self._TapPlus__getconnhandler()
927927
response = connHandler.execute_tapget(subContext, False)
928928
if response.status == 200:
929929
if isinstance(response, Iterable):
930930
for line in response:
931+
931932
try:
932933
print(line.decode("utf-8").split('=', 1)[1])
933934
except ValueError as e:
934935
print(e)
935-
except IndexError as e:
936+
except IndexError:
936937
print("Archive down for maintenance")
937938

938939
except OSError:

astroquery/gaia/tests/test_gaiatap.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,12 @@ def test_show_message(self):
5656
headers=None)
5757
connHandler.set_default_response(dummy_response)
5858

59-
# show_messages
59+
# show_server_messages
6060
tableRequest = 'notification?action=GetNotifications'
6161
connHandler.set_response(tableRequest, dummy_response)
6262

6363
tapplus = TapPlus("http://test:1111/tap", connhandler=connHandler)
64-
tap = GaiaClass(connHandler, tapplus, show_messages=True)
64+
tap = GaiaClass(connHandler, tapplus, show_server_messages=True)
6565

6666
def test_query_object(self):
6767
conn_handler = DummyConnHandler()
@@ -79,12 +79,12 @@ def test_query_object(self):
7979
headers=None)
8080
conn_handler.set_default_response(dummy_response)
8181

82-
# show_messages
82+
# show_server_messages
8383
tableRequest = 'notification?action=GetNotifications'
8484
conn_handler.set_response(tableRequest, dummy_response)
8585

8686
tapplus = TapPlus("http://test:1111/tap", connhandler=conn_handler)
87-
tap = GaiaClass(conn_handler, tapplus, show_messages=True)
87+
tap = GaiaClass(conn_handler, tapplus, show_server_messages=True)
8888
# Launch response: we use default response because the query contains
8989
# decimals
9090
response_launch_job = DummyResponse()
@@ -165,7 +165,7 @@ def test_query_object(self):
165165
def test_query_object_async(self):
166166
conn_handler = DummyConnHandler()
167167
tapplus = TapPlus("http://test:1111/tap", connhandler=conn_handler)
168-
tap = GaiaClass(conn_handler, tapplus, show_messages=False)
168+
tap = GaiaClass(conn_handler, tapplus, show_server_messages=False)
169169
jobid = '12345'
170170
# Launch response
171171
response_launch_job = DummyResponse()
@@ -260,7 +260,7 @@ def test_query_object_async(self):
260260
def test_cone_search_sync(self):
261261
conn_handler = DummyConnHandler()
262262
tapplus = TapPlus("http://test:1111/tap", connhandler=conn_handler)
263-
tap = GaiaClass(conn_handler, tapplus, show_messages=False)
263+
tap = GaiaClass(conn_handler, tapplus, show_server_messages=False)
264264
# Launch response: we use default response because the query contains
265265
# decimals
266266
response_launch_job = DummyResponse()
@@ -313,7 +313,7 @@ def test_cone_search_sync(self):
313313
def test_cone_search_async(self):
314314
conn_handler = DummyConnHandler()
315315
tapplus = TapPlus("http://test:1111/tap", connhandler=conn_handler)
316-
tap = GaiaClass(conn_handler, tapplus, show_messages=False)
316+
tap = GaiaClass(conn_handler, tapplus, show_server_messages=False)
317317
jobid = '12345'
318318
# Launch response
319319
response_launch_job = DummyResponse()
@@ -420,7 +420,7 @@ def __check_results_column(self, results, column_name, description, unit,
420420

421421
def test_load_data(self):
422422
dummy_handler = DummyTapHandler()
423-
tap = GaiaClass(dummy_handler, dummy_handler, show_messages=False)
423+
tap = GaiaClass(dummy_handler, dummy_handler, show_server_messages=False)
424424

425425
ids = "1,2,3,4"
426426
retrieval_type = "epoch_photometry"
@@ -459,7 +459,7 @@ def test_load_data(self):
459459

460460
def test_get_datalinks(self):
461461
dummy_handler = DummyTapHandler()
462-
tap = GaiaClass(dummy_handler, dummy_handler, show_messages=False)
462+
tap = GaiaClass(dummy_handler, dummy_handler, show_server_messages=False)
463463
ids = ["1", "2", "3", "4"]
464464
verbose = True
465465
parameters = {}
@@ -471,7 +471,7 @@ def test_get_datalinks(self):
471471
def test_xmatch(self):
472472
conn_handler = DummyConnHandler()
473473
tapplus = TapPlus("http://test:1111/tap", connhandler=conn_handler)
474-
tap = GaiaClass(conn_handler, tapplus, show_messages=False)
474+
tap = GaiaClass(conn_handler, tapplus, show_server_messages=False)
475475
jobid = '12345'
476476
# Launch response
477477
response_launch_job = DummyResponse()
@@ -619,7 +619,7 @@ def test_xmatch(self):
619619
def test_login(self, mock_login):
620620
conn_handler = DummyConnHandler()
621621
tapplus = TapPlus("http://test:1111/tap", connhandler=conn_handler)
622-
tap = GaiaClass(conn_handler, tapplus, show_messages=False)
622+
tap = GaiaClass(conn_handler, tapplus, show_server_messages=False)
623623
tap.login("user", "password")
624624
assert (mock_login.call_count == 2)
625625
mock_login.side_effect = HTTPError("Login error")
@@ -631,7 +631,7 @@ def test_login(self, mock_login):
631631
def test_login_gui(self, mock_login_gui, mock_login):
632632
conn_handler = DummyConnHandler()
633633
tapplus = TapPlus("http://test:1111/tap", connhandler=conn_handler)
634-
tap = GaiaClass(conn_handler, tapplus, show_messages=False)
634+
tap = GaiaClass(conn_handler, tapplus, show_server_messages=False)
635635
tap.login_gui()
636636
assert (mock_login_gui.call_count == 1)
637637
mock_login_gui.side_effect = HTTPError("Login error")
@@ -642,7 +642,7 @@ def test_login_gui(self, mock_login_gui, mock_login):
642642
def test_logout(self, mock_logout):
643643
conn_handler = DummyConnHandler()
644644
tapplus = TapPlus("http://test:1111/tap", connhandler=conn_handler)
645-
tap = GaiaClass(conn_handler, tapplus, show_messages=False)
645+
tap = GaiaClass(conn_handler, tapplus, show_server_messages=False)
646646
tap.logout()
647647
assert (mock_logout.call_count == 2)
648648
mock_logout.side_effect = HTTPError("Login error")

0 commit comments

Comments
 (0)