Skip to content

Commit

Permalink
Fix bandit and doc failures
Browse files Browse the repository at this point in the history
  • Loading branch information
pllim committed Oct 31, 2023
1 parent 8540966 commit 1980806
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
12 changes: 9 additions & 3 deletions acstools/focus_diverse_epsfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def _validate_acs_ipsoot(line):
return isinstance(line, str) and len(line) == 9 and line.startswith("j")


def psf_retriever(ipsoot, download_location):
def psf_retriever(ipsoot, download_location, timeout=60):
"""Function to query API on AWS API Gateway for the ePSF FITS file that
corresponds to a given image rootname.
Expand All @@ -122,6 +122,9 @@ def psf_retriever(ipsoot, download_location):
Directory name where the file will be downloaded to.
It must exist and you must have write permission to it.
timeout : float
Seconds before query timeout.
Returns
-------
desired_filename : str or `None`
Expand All @@ -147,7 +150,7 @@ def psf_retriever(ipsoot, download_location):

# send up post request with ipsoot event
myobj = {'ipsoot': ipsoot}
result = requests.post(api_url, json=myobj, auth=auth)
result = requests.post(api_url, json=myobj, auth=auth, timeout=timeout)

if not result.ok:
LOG.error("Query failed: %d %s" % (result.status_code, result.reason))
Expand All @@ -159,6 +162,9 @@ def psf_retriever(ipsoot, download_location):

# grab url from result
url = result.text[1:-1]
if not url.startswith("http"):
LOG.error("URL is not HTTP.")
return
with urlopen(url) as remotefile:
# determine readable name for file
content_disposition = remotefile.info()['Content-Disposition']
Expand All @@ -175,7 +181,7 @@ def psf_retriever(ipsoot, download_location):
return

# download file
urlretrieve(url, filename=desired_filename)
urlretrieve(url, filename=desired_filename) # nosec (already checked above)

return desired_filename

Expand Down
2 changes: 1 addition & 1 deletion doc/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ To install the development version of this package::
satdet
findsat_mrt
polarization_tools
focus_diverse_epsf
focus_diverse_epsfs
utils_calib

******************
Expand Down

0 comments on commit 1980806

Please sign in to comment.