Add button to show upgrade logs after a failure

This commit is contained in:
Taylor Helsper 2020-01-24 12:07:03 -06:00
parent 76539365d3
commit 2faaa9d3af
3 changed files with 23 additions and 0 deletions

View File

@ -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

View File

@ -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,

View File

@ -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 %}
<p style="color: red;">It appears a recent upgrade may not have fully completed.</p>
<button id="upgrade" class="ui-button ui-widget ui-corner-all settings_button">Retry Upgrade</button>
<button id="show_upgrade_status" class="ui-button ui-widget ui-corner-all settings_button">Show Upgrade Logs</button>
<div id="upgrade_status" style='text-align: left; font-size: 12px; width: 800px; display: none;'><pre>{{upgrade_logs}}</pre></div>
{% endif %}
<div class="divider"></div>