Skip to content

Commit

Permalink
revert to old file version
Browse files Browse the repository at this point in the history
  • Loading branch information
simeonreusch committed May 31, 2023
1 parent a09e752 commit 2d7ee13
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions nuztf/ampel_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -683,11 +683,13 @@ def ampel_api_catalog(
return res


def get_preprocessed_results(file_basename: str) -> list:
def get_preprocessed_results(file_basename: str, logger=None) -> None | list:
"""
Access the DESY Cloud to look if there are precomputed results from an AMPEL run
there
"""
if logger is None:
logger = logging.getLogger(__name__)

desy_cloud_token = load_credentials("desy_cloud_token", token_based=True)

Expand All @@ -698,7 +700,12 @@ def get_preprocessed_results(file_basename: str) -> list:
headers={"X-Requested-With": "XMLHttpRequest"},
auth=(desy_cloud_token, "bla"),
)
res.raise_for_status()

if res.status_code != 200:
logger.warning(
"\n\n-------------------- !! -------------------\nSomething went wrong with your query.\nCheck your credentials and make sure Ampel\nhas run correctly at Desy.\n-------------------- !! -------------------\n\n"
)
return None

with open(f"{filename}", "wb") as f:
f.write(res.content)
Expand Down

0 comments on commit 2d7ee13

Please sign in to comment.