Skip to content

Commit

Permalink
do not move tokens around all the time, simply set them in the enviro…
Browse files Browse the repository at this point in the history
…nment if provided
  • Loading branch information
Theodlz committed Mar 14, 2024
1 parent 7673daf commit 11d0ed0
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
7 changes: 1 addition & 6 deletions frigate/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,7 @@ def str_to_bool(value):
print("Getting candidates from SkyPortal using the following groupIDs:")
print(args.groupids)
candids_per_filter, err = get_candids_per_filter_from_skyportal(
args.start,
args.end,
args.groupids,
args.filterids,
saved=False,
token=args.sp_token,
args.start, args.end, args.groupids, args.filterids, saved=False
)
if err or candids_per_filter is None:
print(err)
Expand Down
9 changes: 9 additions & 0 deletions frigate/utils/parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,15 @@ def main_parser_args():
# if provided, we add the token in the environment instead
os.environ["KOWALSKI_TOKEN"] = args.k_token

if not args.sp_token:
# we try to get the token from the environment if it is not provided here
sp_token_env = os.environ.get("SKYPORTAL_TOKEN")
if sp_token_env:
args.sp_token = sp_token_env
else:
# if provided, we add the token in the environment instead
os.environ["SKYPORTAL_TOKEN"] = args.sp_token

# validate the output options
try:
validate_output_options(
Expand Down
7 changes: 2 additions & 5 deletions frigate/utils/skyportal.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,9 @@ def get_skyportal_token():
raise ValueError(f"Failed to get SkyPortal token: {e}")


def get_candids_per_filter_from_skyportal(
t_i, t_f, groupIDs, filterIDs, saved=False, token=None
):
token = get_skyportal_token() if token is None else token
def get_candids_per_filter_from_skyportal(t_i, t_f, groupIDs, filterIDs, saved=False):
host = "https://fritz.science/api/candidates_filter"
headers = {"Authorization": f"token {token}"}
headers = {"Authorization": f"token {get_skyportal_token()}"}
# compute the isoformat of the start and end dates
start_date = Time(t_i, format="jd").iso
end_date = Time(t_f, format="jd").iso
Expand Down

0 comments on commit 11d0ed0

Please sign in to comment.