From 856d27569723521f7a4462e10ffafe3db40f7815 Mon Sep 17 00:00:00 2001 From: Valentin Lorentz Date: Mon, 7 Dec 2015 16:32:46 +0100 Subject: [PATCH] Status: Fix output of @cpu if the amount of memory is unknown. --- plugins/Status/plugin.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/plugins/Status/plugin.py b/plugins/Status/plugin.py index 7e9ac2b1b..5847a1dd8 100644 --- a/plugins/Status/plugin.py +++ b/plugins/Status/plugin.py @@ -160,7 +160,7 @@ class Status(callbacks.Plugin): 'running.', (world.threadsSpawned, 'thread'), activeThreads) if self.registryValue('cpu.memory', target): - mem = 'an unknown amount' + mem = None pid = os.getpid() plat = sys.platform try: @@ -180,8 +180,11 @@ class Status(callbacks.Plugin): mem = int(out.splitlines()[1]) elif sys.platform.startswith('netbsd'): mem = int(os.stat('/proc/%s/mem' % pid)[7]) - response += format(_(' I\'m taking up %S of memory.'), - mem*1024) + if mem: + response += format(_(' I\'m taking up %S of memory.'), + mem*1024) + else: + response += _(' I\'m taking up an unknown amount of memory.') except Exception: self.log.exception('Uncaught exception in cpu.memory:') irc.reply(utils.str.normalizeWhitespace(response))