From 429a45e7eca20d526f0a691ff177e914cf7a1d5a Mon Sep 17 00:00:00 2001 From: Seth Grover Date: Tue, 12 Nov 2024 14:02:57 -0700 Subject: [PATCH] for idaholab/Malcolm#361, some tweaks to the nginx conf to make sure query parameters get passed in --- nginx/nginx.conf | 3 ++- shared/bin/extracted_files_http_server.py | 22 +++++----------------- 2 files changed, 7 insertions(+), 18 deletions(-) diff --git a/nginx/nginx.conf b/nginx/nginx.conf index d837369dc..2de0a8b0f 100644 --- a/nginx/nginx.conf +++ b/nginx/nginx.conf @@ -194,7 +194,7 @@ http { # extracted file download location ~* ^/extracted-files\b(.*) { include /etc/nginx/nginx_auth_rt.conf; - proxy_pass http://extracted-file-http-server$1; + proxy_pass http://extracted-file-http-server$1$is_args$args; proxy_redirect off; proxy_set_header Host file-monitor.malcolm.local; } @@ -204,6 +204,7 @@ http { include /etc/nginx/nginx_auth_rt.conf; include /etc/nginx/nginx_system_resolver.conf; set $upstream $1:8006; + # TODO: check, do i need is_args/args here? rewrite ^/hh-extracted-files/([a-zA-Z0-9-\.]+)(.*)$ $2 break; proxy_pass https://$upstream; proxy_ssl_verify off; diff --git a/shared/bin/extracted_files_http_server.py b/shared/bin/extracted_files_http_server.py index ca42fdf25..6c8d6a2a8 100755 --- a/shared/bin/extracted_files_http_server.py +++ b/shared/bin/extracted_files_http_server.py @@ -50,12 +50,6 @@ malcolm_forward_header = 'X-Malcolm-Forward' -################################################################################################### -# a function for performing "natural" (case insensitive) sort -def natural_sort_key(s, _nsre=re.compile('([0-9]+)')): - return [int(text) if text.isdigit() else text.lower() for text in _nsre.split(s)] - - ################################################################################################### # return the names and flags for Zipping a list of files def LocalFilesForZip(names): @@ -146,7 +140,7 @@ def do_GET(self): for dirpath, dirnames, filenames in os.walk(fullpath): # list directories first - for dirname in sorted(dirnames, key=natural_sort_key): + for dirname in sorted(dirnames, key=str.casefold): try: child = os.path.join(dirpath, dirname) if args.links or (not os.path.islink(child)): @@ -154,7 +148,7 @@ def do_GET(self): except Exception as e: eprint(f'Error with directory "{dirname}"": {e}') # list files - for filename in sorted(filenames, key=natural_sort_key): + for filename in sorted(filenames, key=str.casefold): try: child = os.path.join(dirpath, filename) if args.links or (not os.path.islink(child)): @@ -236,9 +230,7 @@ def do_GET(self): timestamp = datetime.strptime(timestampStr, '%Y%m%d%H%M%S') timestampStr = timestamp.isoformat() timestampStartFilterStr = ( - (timestamp - timedelta(days=1)) - .isoformat() - .split('.')[0] + (timestamp - timedelta(days=1)).isoformat().split('.')[0] ) except Exception as te: if timestampStr: @@ -296,7 +288,7 @@ def do_GET(self): ), td(sizeof_fmt(os.path.getsize(child)), style="text-align: right"), ) - + # show special malcolm columns if requested if showMalcolmCols: if fmatch is not None: @@ -348,11 +340,7 @@ def do_GET(self): li(span('Previous', cls='page-link disabled'), cls='page-item') # add a space between text - li( - ' ', - cls='page-item spacer', - style='width: 10px;' - ) + li(' ', cls='page-item spacer', style='width: 10px;') # next page link if page < totalPages: