From 2f8ea00ec3a82eb17c5472829694b3f16aee65a7 Mon Sep 17 00:00:00 2001 From: Dmitri Popov Date: Wed, 28 Mar 2018 19:12:21 +0200 Subject: [PATCH] Add free disk space on /storage --- rc/rc.py | 12 +++++++++--- rc/rc.tpl | 3 ++- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/rc/rc.py b/rc/rc.py index 78d49a4..1a8afb2 100755 --- a/rc/rc.py +++ b/rc/rc.py @@ -19,8 +19,14 @@ import os @route('/') @route('/', method='POST') def remote_control(): - st = os.statvfs("/home") - free = "%.2f" % float((st.f_bavail * st.f_frsize)/1.073741824e9) + st_home = os.statvfs("/home") + free_home = "%.2f" % float((st_home.f_bavail * st_home.f_frsize)/1.073741824e9) + if os.path.isdir("/media/storage"): + st_storage = os.statvfs("/media/storage") + free_storage = "%.2f" % float((st_storage.f_bavail * st_storage.f_frsize)/1.073741824e9) + else: + free_storage="N/A" + if (request.POST.get("cardbackup")): os.system("sudo /home/pi/little-backup-box/scripts/card-backup.sh") return ('Backup started. You can close this page.') @@ -34,7 +40,7 @@ def remote_control(): if (request.POST.get("shutdown")): os.system("sudo shutdown -h now") return ('Shutdown request sent. You can close this page.') - return template('rc.tpl', freespace=free) + return template('rc.tpl', freespace_home=free_home, freespace_storage=free_storage) @route('/static/:path#.+#', name='static') def static(path): diff --git a/rc/rc.tpl b/rc/rc.tpl index 03f6240..8fa5711 100644 --- a/rc/rc.tpl +++ b/rc/rc.tpl @@ -46,7 +46,8 @@
-

Free disk space on /home: {{freespace}} GB

+

Free disk space on /home: {{freespace_home}} GB

+

Free disk space on /storage: {{freespace_storage}} GB


Back up a storage card connected via a card reader