From c5bb1f42e2327f488a81998c92156298e9c4a8cd Mon Sep 17 00:00:00 2001 From: amcmanu3 Date: Sat, 18 Mar 2023 15:27:08 -0400 Subject: [PATCH 1/2] Add try/except around disk data --- app/classes/minecraft/stats.py | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/app/classes/minecraft/stats.py b/app/classes/minecraft/stats.py index 3d4cf483..c336612a 100644 --- a/app/classes/minecraft/stats.py +++ b/app/classes/minecraft/stats.py @@ -191,21 +191,25 @@ class Stats: # ENOENT, pop-up a Windows GUI error for a non-ready # partition or just hang. continue - usage = psutil.disk_usage(part.mountpoint) - disk_data.append( - { - "device": part.device, - "total_raw": usage.total, - "total": Helpers.human_readable_file_size(usage.total), - "used_raw": usage.used, - "used": Helpers.human_readable_file_size(usage.used), - "free_raw": usage.free, - "free": Helpers.human_readable_file_size(usage.free), - "percent_used": usage.percent, - "fs": part.fstype, - "mount": part.mountpoint, - } - ) + try: + usage = psutil.disk_usage(part.mountpoint) + disk_data.append( + { + "device": part.device, + "total_raw": usage.total, + "total": Helpers.human_readable_file_size(usage.total), + "used_raw": usage.used, + "used": Helpers.human_readable_file_size(usage.used), + "free_raw": usage.free, + "free": Helpers.human_readable_file_size(usage.free), + "percent_used": usage.percent, + "fs": part.fstype, + "mount": part.mountpoint, + } + ) + except PermissionError: + logger.debug(f"Permission error accessing {part.mountpoint}") + continue return disk_data From fa87dcee1a4f01c0d72399c0f1e51958d5b9c083 Mon Sep 17 00:00:00 2001 From: Andrew Date: Sun, 12 Mar 2023 16:46:50 -0400 Subject: [PATCH 2/2] Fix traceback for users without disks --- app/frontend/templates/panel/dashboard.html | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/app/frontend/templates/panel/dashboard.html b/app/frontend/templates/panel/dashboard.html index 981a4163..a0927996 100644 --- a/app/frontend/templates/panel/dashboard.html +++ b/app/frontend/templates/panel/dashboard.html @@ -100,6 +100,7 @@ + {% if len(data['hosts_data']['disk_json']) > 0 %}
@@ -107,7 +108,7 @@
- {% for item in data.get('hosts_data').get('disk_json') %} + {% for item in data['hosts_data']['disk_json'] %} {% if item["mount"] in data["monitored"] %}

+ {% end %}
@@ -931,8 +933,8 @@ var storage_html = '
'; for (i = 0; i < hostStats.disk_usage.length; i++) { if (hostStats.mounts.includes(hostStats.disk_usage[i].mount)) { - storage_html += `
-

${hostStats.disk_usage[i].mount}

+ storage_html += `
+

${hostStats.disk_usage[i].mount}