Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Combine export_selected and export_all #857

Merged
merged 1 commit into from
Jan 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 3 additions & 33 deletions auto_rx/autorx/web.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,15 +335,16 @@ def flask_get_log_by_serial_detail():
return json.dumps(read_log_by_serial(_serial, skewt_decimation=_decim))


@app.route("/export_all_log_files")
@app.route("/export_log_files/<serialb64>")
def flask_export_selected_log_files(serialb64):
def flask_export_log_files(serialb64=None):
"""
Zip and download a set of log files.
The list of log files is provided in the URL as a base64-encoded JSON list.
"""

try:
_serial_list = json.loads(base64.b64decode(serialb64))
_serial_list = json.loads(base64.b64decode(serialb64)) if serialb64 else None

_zip = zip_log_files(_serial_list)

Expand All @@ -368,37 +369,6 @@ def flask_export_selected_log_files(serialb64):
logging.error("Web - Error handling Zip request:" + str(e))
abort(400)


@app.route("/export_all_log_files")
def flask_export_all_log_files():
"""
Zip and download all log files. This may take some time.
"""

try:
_zip = zip_log_files()

_ts = datetime.datetime.strftime(datetime.datetime.utcnow(), "%Y%m%d-%H%M%SZ")

response = make_response(
flask.send_file(
_zip,
mimetype="application/zip",
as_attachment=True,
download_name=f"autorx_logfiles_{autorx.config.global_config['habitat_uploader_callsign']}_{_ts}.zip",
)
)

# Add header asking client not to cache the download
response.headers["Cache-Control"] = "no-cache, no-store, must-revalidate"
response.headers["Pragma"] = "no-cache"

return response

except Exception as e:
logging.error("Web - Error handling Zip request:" + str(e))
abort(400)

#
# Control Endpoints.
#
Expand Down