Skip to content

Commit f45190a

Browse files
mhsarmientobsipocz
authored andcommitted
This new check-in implements GAIAPCR-1094: Astroquery Use TAP notifications service to notify users of service availability problems
1 parent 9526b6f commit f45190a

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

astroquery/gaia/__init__.py

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

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

4345
conf = Conf()
4446

astroquery/gaia/core.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def __init__(self, tap_plus_conn_handler=None,
5151
gaia_data_server='https://gea.esac.esa.int/',
5252
tap_server_context="tap-server",
5353
data_server_context="data-server",
54-
verbose=False):
54+
verbose=False, show_messages=True):
5555
super(GaiaClass, self).__init__(url=gaia_tap_server,
5656
server_context=tap_server_context,
5757
tap_context="tap",
@@ -74,6 +74,10 @@ def __init__(self, tap_plus_conn_handler=None,
7474
else:
7575
self.__gaiadata = datalink_handler
7676

77+
# Enable notifications
78+
if show_messages:
79+
self.get_status_messages()
80+
7781
def login(self, user=None, password=None, credentials_file=None,
7882
verbose=False):
7983
"""Performs a login.
@@ -911,5 +915,20 @@ def launch_job_async(self, query, name=None, output_file=None,
911915
upload_table_name=upload_table_name,
912916
autorun=autorun)
913917

918+
def get_status_messages(self):
919+
"""Retrieve the messages to inform users about
920+
the status of JWST TAP
921+
"""
922+
try:
923+
subContext = conf.GAIA_MESSAGES
924+
connHandler = self._TapPlus__getconnhandler()
925+
response = connHandler.execute_tapget(subContext, False)
926+
if response.status == 200:
927+
for line in response:
928+
string_message = line.decode("utf-8")
929+
print(string_message[string_message.index('=') + 1:])
930+
except OSError as e:
931+
print("Status messages could not be retrieved")
932+
914933

915934
Gaia = GaiaClass()

0 commit comments

Comments
 (0)