From 0d3aacdec7dd27f7c4dd398cc27d3c853ff30283 Mon Sep 17 00:00:00 2001 From: arcan1s Date: Tue, 19 Nov 2013 18:17:59 +0400 Subject: [PATCH] Fixed zero swap and memory --- sources/contents/code/main.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/sources/contents/code/main.py b/sources/contents/code/main.py index 74309cb..444735a 100644 --- a/sources/contents/code/main.py +++ b/sources/contents/code/main.py @@ -186,8 +186,11 @@ class pyTextWidget(plasmascript.Applet): def memText(self): """function to set mem text""" full = self.mem_uf + self.mem_free - mem = 100 * self.mem_used / full - mem = "%5s" % (str(round(mem, 1))) + try: + mem = 100 * self.mem_used / full + mem = "%5s" % (str(round(mem, 1))) + except: + mem = " N\\A" if (self.memFormat.split('$mem')[0] != self.memFormat): line = self.memFormat.split('$mem')[0] + mem + self.memFormat.split('$mem')[1] else: @@ -199,8 +202,11 @@ class pyTextWidget(plasmascript.Applet): def swapText(self): """function to set swap text""" full = self.swap_used + self.swap_free - mem = 100 * self.swap_used / full - mem = "%5s" % (str(round(mem, 1))) + try: + mem = 100 * self.swap_used / full + mem = "%5s" % (str(round(mem, 1))) + except: + mem = " N\\A" if (self.swapFormat.split('$swap')[0] != self.swapFormat): line = self.swapFormat.split('$swap')[0] + mem + self.swapFormat.split('$swap')[1] else: