From 2faaa9d3af943ac6e4751d16fefa24599cb5cb76 Mon Sep 17 00:00:00 2001 From: Taylor Helsper Date: Fri, 24 Jan 2020 12:07:03 -0600 Subject: [PATCH] Add button to show upgrade logs after a failure --- rootfs/standard/var/www/mynode/device_info.py | 15 +++++++++++++++ rootfs/standard/var/www/mynode/settings.py | 1 + .../var/www/mynode/templates/settings.html | 7 +++++++ 3 files changed, 23 insertions(+) diff --git a/rootfs/standard/var/www/mynode/device_info.py b/rootfs/standard/var/www/mynode/device_info.py index b7e4dbd8..b84792dc 100644 --- a/rootfs/standard/var/www/mynode/device_info.py +++ b/rootfs/standard/var/www/mynode/device_info.py @@ -91,6 +91,21 @@ def upgrade_device(): def did_upgrade_fail(): return os.path.isfile("/mnt/hdd/mynode/settings/upgrade_error") +def get_recent_upgrade_logs(): + logs="" + current_version = get_current_version() + for i in range(1,6): + filename = "/home/admin/upgrade_logs/upgrade_log_{}_post_{}.txt".format(current_version, i) + try: + with open(filename, "r") as f: + logs = logs + "===========================================================\n" + logs = logs + "=== Upgrade Attempt #{}\n".format(i) + logs = logs + "===========================================================\n\n\n" + logs = logs + f.read().decode("utf8") + except: + pass + return logs + #================================== # Device Info diff --git a/rootfs/standard/var/www/mynode/settings.py b/rootfs/standard/var/www/mynode/settings.py index 24ba6047..753e6fd1 100644 --- a/rootfs/standard/var/www/mynode/settings.py +++ b/rootfs/standard/var/www/mynode/settings.py @@ -128,6 +128,7 @@ def page_settings(): "current_version": current_version, "latest_version": latest_version, "upgrade_error": did_upgrade_fail(), + "upgrade_logs": get_recent_upgrade_logs(), "serial_number": serial_number, "device_type": device_type, "product_key": product_key, diff --git a/rootfs/standard/var/www/mynode/templates/settings.html b/rootfs/standard/var/www/mynode/templates/settings.html index efc0573a..b4858fbe 100644 --- a/rootfs/standard/var/www/mynode/templates/settings.html +++ b/rootfs/standard/var/www/mynode/templates/settings.html @@ -214,6 +214,11 @@ $("#mempoolspace_status").show(); }); + $("#show_upgrade_status").on("click", function() { + $("#show_upgrade_status").hide(0); + $("#upgrade_status").show(); + }); + $("#show_mynode_changelog").on("click", function() { if (showChangelog) { @@ -349,6 +354,8 @@ {% elif not product_key_skipped and upgrade_error %}

It appears a recent upgrade may not have fully completed.

+ + {% endif %}