From 94079dbae3ae08f74283ef90e15c2cb3be541d78 Mon Sep 17 00:00:00 2001 From: Alexandre Strube Date: Mon, 11 Jan 2021 12:02:46 +0100 Subject: [PATCH] Fix for DF info Subprocess returns a byte array in python3, and the output is processed as a string - therefore, we need to convert df's output into a string before we work with it. --- source/webserver3.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/webserver3.py b/source/webserver3.py index ff199a7..bbc4952 100644 --- a/source/webserver3.py +++ b/source/webserver3.py @@ -94,7 +94,7 @@ def df(drive_mnt): ''' try: df = subprocess.Popen(["df", "-h", drive_mnt], stdout=subprocess.PIPE) - output = df.communicate()[0] + output = df.communicate()[0].decode('utf-8') device, size, used, available, percent, mountpoint = output.split("\n")[1].split() drive_status = ("Drive [ %s ] Mount_Point [ %s ] Space_Used [ %s %s of %s ] Space_Avail [ %s ]" % (device, mountpoint, percent, used, size, available)) @@ -269,4 +269,4 @@ def list_directory(self, path): httpd.shutdown() httpd.socket.close() except IOError as e: - print("I/O error({0}): {1}".format(e.errno, e.strerror)) \ No newline at end of file + print("I/O error({0}): {1}".format(e.errno, e.strerror))