Skip to content

Commit

Permalink
passing token to the funciotn that builds the uploaded file url
Browse files Browse the repository at this point in the history
  • Loading branch information
burnout87 committed Nov 15, 2024
1 parent f3e0e20 commit 5ad751b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
13 changes: 8 additions & 5 deletions cdci_data_analysis/analysis/instrument.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ def parse_inputs_files(self,
bind_port,
request_files_dir,
decoded_token,
token=None,
sentry_dsn=None):
error_message = 'Error while {step} {temp_dir_content_msg}{additional}'
# TODO probably exception handling can be further improved and/or optmized
Expand Down Expand Up @@ -281,7 +282,8 @@ def parse_inputs_files(self,
uploaded_files_obj=uploaded_files_obj,
products_url=products_url,
bind_host=bind_host,
bind_port=bind_port)
bind_port=bind_port,
token=token)
step = 'updating ownership files'
self.update_ownership_files(uploaded_files_obj,
request_files_dir=request_files_dir,
Expand Down Expand Up @@ -708,16 +710,17 @@ def set_input_products_from_fronted(self, input_file_path, par_dic, verbose=Fals
else:
raise RuntimeError

def update_par_dic_with_uploaded_files(self, par_dic, uploaded_files_obj, products_url, bind_host, bind_port):
def update_par_dic_with_uploaded_files(self, par_dic, uploaded_files_obj, products_url, bind_host, bind_port, token=None):
if validators.url(products_url, simple_host=True):
# TODO remove the dispatch-data part, better to have it extracted from the configuration file
basepath = os.path.join(products_url, 'dispatch-data/download_file')
else:
basepath = os.path.join(f"http://{bind_host}:{bind_port}", 'download_file')
for f in uploaded_files_obj:
dpars = urlencode(dict(file_list=uploaded_files_obj[f],
_is_mmoda_url=True,
return_archive=False))
dict_args = dict(file_list=uploaded_files_obj[f], _is_mmoda_url=True, return_archive=False)
if token is not None:
dict_args['token'] = token
dpars = urlencode(dict_args)
download_file_url = f"{basepath}?{dpars}"
par_dic[f] = download_file_url

Expand Down
1 change: 1 addition & 0 deletions cdci_data_analysis/flask_app/dispatcher_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,7 @@ def __init__(self, app,
bind_host=bind_host,
bind_port=bind_port,
request_files_dir=self.request_files_dir,
token=self.token,
decoded_token=self.decoded_token,
sentry_dsn=self.sentry_dsn
)
Expand Down

0 comments on commit 5ad751b

Please sign in to comment.