Skip to content

Commit

Permalink
error handling on empty return on data
Browse files Browse the repository at this point in the history
  • Loading branch information
avialxee committed Oct 13, 2023
1 parent e472111 commit 3c93566
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 10 deletions.
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = rgbmaker
version = 0.0.5.3
version = 0.0.5.4
author = Avinash Kumar
author_email = [email protected]
description = A python package which communicates to different astronomical services and fetches fits and numerical data.
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setup(
name = 'rgbmaker',
version = '0.0.5.3',
version = '0.0.5.4',
url='https://github.com/avialxee/rgbmaker',
author='Avinash Kumar',
author_email='[email protected]',
Expand Down
19 changes: 12 additions & 7 deletions src/rgbmaker/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,16 @@ def submit_query(self):
self.name, self.c, self.r = self._inp_sanitize()
if self.c is not None :
self._getNVAS(self.archives)

try:
hdu_d_list, error = self.getdd(_input_svys, _input_sampler)
if error:self.otext.append(error)
except:
if self.c :
if self.imagesopt == 1 or self.imagesopt == 2 or self.imagesopt == 3:
self.status, self.info = 'info', 'error fetching data from skyview'
self.server_down=True
self.status, self.info = 'info', 'error fetching data from SkyView, contact developer'

else:
self.status, self.info = 'info', 'No images to return'
return self.throw_output()
Expand Down Expand Up @@ -157,7 +160,7 @@ def getdd(self, input_svys, sampler):
_imgls, _error = self._run_imgl(
self.c, self.r, input_svys, sampler)
for i in range(len(_imgls)):
if _imgls[i] == 0:
if _imgls[i] == 0 or len(_imgls[i])==0:
_imglt.insert(
i, [np.zeros((int(self.px), int(self.px))), None])
else:
Expand Down Expand Up @@ -190,18 +193,19 @@ def _run_imgl(self, c, r, _in_svys, sam):
returns a list of hdul and errors requested by getdd.
"""
result = [0]*len(_in_svys)
imglt, _error = [None]*2
imglt, _error = None, {"survey_err":[],"exception":[]}
_sam = sam
try:
#print(_in_svys)
try:
for ind in range(len(_in_svys)):
imglt = self._get_imgl_pool(
[c, _in_svys[ind], r, result, ind, _sam[ind]])
except:
_error = "problem with survey: " + str(_in_svys)
if len(imglt[ind])==0:_error["survey_err"].append(str(_in_svys[ind]))
except Exception as e:
_error["exception"].append(f"{str(e)}")
except Exception as e:
_error = e
_error["exception"].append(f"{str(e)}")
return imglt, _error

def _get_imgl_pool(self, cals):
Expand All @@ -218,7 +222,8 @@ def _get_imgl_pool(self, cals):
queue[ind] = imglr
except requests.exceptions.ConnectionError as e:
self.server_down = True
self.info = e
self.status, self.info = 'warning', 'SkyView is down!'

except Exception as e:
# --- if file not found/doesn't exist. Program will continue.
print("{} not found ".format(svy))
Expand Down
1 change: 0 additions & 1 deletion src/rgbmaker/fetch.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ def query(name="", position="", radius=float(0.12), archives=1,
level_contour=4

if fetch_q.server_down:
fetch_q.status, fetch_q.info = 'warning', 'SkyView is down!'
return fetch_q.throw_output()

else:
Expand Down

0 comments on commit 3c93566

Please sign in to comment.