Fix issue where status page wouldn't load without drive attached

This commit is contained in:
Taylor Helsper 2021-11-19 20:39:47 -06:00
parent 1f74ae67c7
commit beef323e0b
2 changed files with 14 additions and 7 deletions

View File

@ -793,6 +793,12 @@ def reset_docker():
def get_docker_running_containers(): def get_docker_running_containers():
containers = [] containers = []
# If docker not running, return empty
if get_service_status_code("docker") != 0:
return containers
# TODO: switch to subprocess after switch to python3 for web ui (timeout doesn't work w/ subprocess32, causes issues)
try: try:
text = subprocess32.check_output("docker ps --format '{{.Names}}'", shell=True, timeout=3).decode("utf8") text = subprocess32.check_output("docker ps --format '{{.Names}}'", shell=True, timeout=3).decode("utf8")
containers = text.splitlines() containers = text.splitlines()

View File

@ -1,5 +1,6 @@
from config import * from config import *
from flask import Blueprint, render_template, session, abort, Markup, request, redirect, send_from_directory, url_for, flash, current_app from flask import Blueprint, render_template, session, abort, Markup, request, redirect, send_from_directory, url_for, flash
from flask import current_app as app
from bitcoinrpc.authproxy import AuthServiceProxy, JSONRPCException from bitcoinrpc.authproxy import AuthServiceProxy, JSONRPCException
from bitcoin import is_bitcoin_synced from bitcoin import is_bitcoin_synced
from bitcoin_info import using_bitcoin_custom_config from bitcoin_info import using_bitcoin_custom_config
@ -848,13 +849,13 @@ def reinstall_app_page():
return redirect("/settings") return redirect("/settings")
# Check application name is valid # Check application name is valid
app = request.args.get("app") app_name = request.args.get("app")
if not is_application_valid(app): if not is_application_valid(app_name):
flash("Application is invalid", category="error") flash("Application is invalid", category="error")
return redirect("/settings") return redirect("/settings")
# Re-install app # Re-install app
t = Timer(1.0, reinstall_app, [app]) t = Timer(1.0, reinstall_app, [app_name])
t.start() t.start()
# Display wait page # Display wait page
@ -877,13 +878,13 @@ def uninstall_app_page():
return redirect("/apps") return redirect("/apps")
# Check application name is valid # Check application name is valid
app = request.args.get("app") app_name = request.args.get("app")
if not is_application_valid(app): if not is_application_valid(app_name):
flash("Application is invalid", category="error") flash("Application is invalid", category="error")
return redirect("/apps") return redirect("/apps")
# Un-install app # Un-install app
uninstall_app(app) uninstall_app(app_name)
flash("Application Uninstalled", category="message") flash("Application Uninstalled", category="message")
return redirect("/apps") return redirect("/apps")