From c4dbbbc516b6c1c062dd82f5de94f6a393545f85 Mon Sep 17 00:00:00 2001 From: Bryan Hilbert Date: Wed, 6 Jul 2022 10:00:59 -0400 Subject: [PATCH 1/4] Use full path for download file --- jwql/website/apps/jwql/data_containers.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jwql/website/apps/jwql/data_containers.py b/jwql/website/apps/jwql/data_containers.py index c28e3d3fd..3b1be394a 100644 --- a/jwql/website/apps/jwql/data_containers.py +++ b/jwql/website/apps/jwql/data_containers.py @@ -378,7 +378,7 @@ def get_edb_components(request): comments.append(' ') result_table.write(path_for_download, format='ascii.fixed_width', overwrite=True, delimiter=',', bookend=False) - mnemonic_query_result.file_for_download = file_for_download + mnemonic_query_result.file_for_download = path_for_download # create forms for search fields not clicked mnemonic_name_search_form = MnemonicSearchForm(prefix='mnemonic_name_search') From 2a7900166aab598b902ba656e41942c525121135 Mon Sep 17 00:00:00 2001 From: Bryan Hilbert Date: Wed, 6 Jul 2022 10:06:53 -0400 Subject: [PATCH 2/4] Use a less generic name for output file --- jwql/website/apps/jwql/data_containers.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jwql/website/apps/jwql/data_containers.py b/jwql/website/apps/jwql/data_containers.py index 3b1be394a..ad599b357 100644 --- a/jwql/website/apps/jwql/data_containers.py +++ b/jwql/website/apps/jwql/data_containers.py @@ -361,7 +361,7 @@ def get_edb_components(request): # save file locally to be available for download static_dir = os.path.join(settings.BASE_DIR, 'static') ensure_dir_exists(static_dir) - file_name_root = 'mnemonic_query_result_table' + file_name_root = f'{mnemonic_identifier}_{start_time.isot}_{end_time.isot}' file_for_download = '{}.csv'.format(file_name_root) path_for_download = os.path.join(static_dir, file_for_download) From ec540debc53e2aa9864b0e14241a8432a1461606 Mon Sep 17 00:00:00 2001 From: Bryan Hilbert Date: Wed, 6 Jul 2022 11:14:48 -0400 Subject: [PATCH 3/4] Save dir and download dir are different from one another --- jwql/website/apps/jwql/data_containers.py | 8 ++++---- .../website/apps/jwql/templates/engineering_database.html | 1 + 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/jwql/website/apps/jwql/data_containers.py b/jwql/website/apps/jwql/data_containers.py index ad599b357..abb19980f 100644 --- a/jwql/website/apps/jwql/data_containers.py +++ b/jwql/website/apps/jwql/data_containers.py @@ -361,9 +361,9 @@ def get_edb_components(request): # save file locally to be available for download static_dir = os.path.join(settings.BASE_DIR, 'static') ensure_dir_exists(static_dir) - file_name_root = f'{mnemonic_identifier}_{start_time.isot}_{end_time.isot}' + file_name_root = f"{mnemonic_identifier}_{start_time.iso.split(' ')[0]}_{end_time.iso.split(' ')[0]}" file_for_download = '{}.csv'.format(file_name_root) - path_for_download = os.path.join(static_dir, file_for_download) + path_to_save = os.path.join(static_dir, file_for_download) # add meta data to saved table comments = [] @@ -376,9 +376,9 @@ def get_edb_components(request): comments.append('End time {}'.format(end_time.isot)) comments.append('Number of rows {}'.format(len(result_table))) comments.append(' ') - result_table.write(path_for_download, format='ascii.fixed_width', + result_table.write(path_to_save, format='ascii.fixed_width', overwrite=True, delimiter=',', bookend=False) - mnemonic_query_result.file_for_download = path_for_download + mnemonic_query_result.file_for_download = file_for_download # create forms for search fields not clicked mnemonic_name_search_form = MnemonicSearchForm(prefix='mnemonic_name_search') diff --git a/jwql/website/apps/jwql/templates/engineering_database.html b/jwql/website/apps/jwql/templates/engineering_database.html index 22967692d..9e74a5ead 100644 --- a/jwql/website/apps/jwql/templates/engineering_database.html +++ b/jwql/website/apps/jwql/templates/engineering_database.html @@ -114,6 +114,7 @@

Query for records of an EDB mnemonic

Query returned {{ edb_components['mnemonic_query_result'].data|length }} records: Download data + {% if edb_components['mnemonic_table_result'] %} {% autoescape off %} From 062e83f7ae23674c2ad80e05cb9299923aeeced7 Mon Sep 17 00:00:00 2001 From: Bryan Hilbert Date: Wed, 6 Jul 2022 11:16:22 -0400 Subject: [PATCH 4/4] Remove commented line --- jwql/website/apps/jwql/templates/engineering_database.html | 1 - 1 file changed, 1 deletion(-) diff --git a/jwql/website/apps/jwql/templates/engineering_database.html b/jwql/website/apps/jwql/templates/engineering_database.html index 9e74a5ead..22967692d 100644 --- a/jwql/website/apps/jwql/templates/engineering_database.html +++ b/jwql/website/apps/jwql/templates/engineering_database.html @@ -114,7 +114,6 @@

Query for records of an EDB mnemonic

Query returned {{ edb_components['mnemonic_query_result'].data|length }} records: Download data - {% if edb_components['mnemonic_table_result'] %} {% autoescape off %}