Skip to content

Commit d997058

Browse files
committed
remove try/except clauses in more show messages, and set show_messages to false by default at import time
1 parent 4f4f5ec commit d997058

File tree

3 files changed

+31
-40
lines changed

3 files changed

+31
-40
lines changed

astroquery/esa/euclid/core.py

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -605,23 +605,20 @@ def get_status_messages(self, verbose=False):
605605
flag to display information about the process
606606
607607
"""
608-
try:
609-
sub_context = self.EUCLID_MESSAGES
610-
conn_handler = self._TapPlus__getconnhandler()
611-
response = conn_handler.execute_tapget(sub_context, verbose=verbose)
612-
if response.status == 200:
613-
if isinstance(response, Iterable):
614-
for line in response:
615-
616-
try:
617-
print(line.decode("utf-8").split('=', 1)[1])
618-
except ValueError as e:
619-
print(e)
620-
except IndexError:
621-
print("Archive down for maintenance")
622-
623-
except OSError:
624-
print("Status messages could not be retrieved")
608+
sub_context = self.EUCLID_MESSAGES
609+
conn_handler = self._TapPlus__getconnhandler()
610+
response = conn_handler.execute_tapget(sub_context, verbose=verbose)
611+
if response.status == 200:
612+
if isinstance(response, Iterable):
613+
for line in response:
614+
615+
try:
616+
print(line.decode("utf-8").split('=', 1)[1])
617+
except ValueError as e:
618+
print(e)
619+
except IndexError:
620+
print("Archive down for maintenance")
621+
625622

626623
@staticmethod
627624
def __set_dirs(output_file, observation_id):
@@ -1443,4 +1440,4 @@ def get_scientific_product_list(self, *, observation_id=None, tile_index=None, c
14431440
return job.get_results()
14441441

14451442

1446-
Euclid = EuclidClass()
1443+
Euclid = EuclidClass(show_server_messages=False)

astroquery/esa/hubble/core.py

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -940,16 +940,13 @@ def get_status_messages(self):
940940
the status of eHST TAP
941941
"""
942942

943-
try:
944-
subContext = conf.EHST_MESSAGES
945-
connHandler = self._tap._TapPlus__getconnhandler()
946-
response = connHandler.execute_tapget(subContext, verbose=False)
947-
if response.status == 200:
948-
for line in response:
949-
string_message = line.decode("utf-8")
950-
print(string_message[string_message.index('=') + 1:])
951-
except OSError:
952-
print("Status messages could not be retrieved")
943+
subContext = conf.EHST_MESSAGES
944+
connHandler = self._tap._TapPlus__getconnhandler()
945+
response = connHandler.execute_tapget(subContext, verbose=False)
946+
if response.status == 200:
947+
for line in response:
948+
string_message = line.decode("utf-8")
949+
print(string_message[string_message.index('=') + 1:])
953950

954951
def get_columns(self, table_name, *, only_names=True, verbose=False):
955952
"""Get the available columns for a table in EHST TAP service
@@ -1061,4 +1058,4 @@ def get_datalabs_path(self, filename, default_volume=None):
10611058
return full_path
10621059

10631060

1064-
ESAHubble = ESAHubbleClass()
1061+
ESAHubble = ESAHubbleClass(show_messages=False)

astroquery/esa/jwst/core.py

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -694,16 +694,13 @@ def get_status_messages(self):
694694
the status of JWST TAP
695695
"""
696696

697-
try:
698-
subContext = conf.JWST_MESSAGES
699-
connHandler = self.__jwsttap._TapPlus__getconnhandler()
700-
response = connHandler.execute_tapget(subContext, verbose=False)
701-
if response.status == 200:
702-
for line in response:
703-
string_message = line.decode("utf-8")
704-
print(string_message[string_message.index('=') + 1:])
705-
except OSError:
706-
print("Status messages could not be retrieved")
697+
subContext = conf.JWST_MESSAGES
698+
connHandler = self.__jwsttap._TapPlus__getconnhandler()
699+
response = connHandler.execute_tapget(subContext, verbose=False)
700+
if response.status == 200:
701+
for line in response:
702+
string_message = line.decode("utf-8")
703+
print(string_message[string_message.index('=') + 1:])
707704

708705
def get_product_list(self, *, observation_id=None,
709706
cal_level="ALL",
@@ -1275,4 +1272,4 @@ def get_decoded_string(str):
12751272
return str
12761273

12771274

1278-
Jwst = JwstClass()
1275+
Jwst = JwstClass(show_messages=False)

0 commit comments

Comments
 (0)