Status: Fix output of @cpu if the amount of memory is unknown.

This commit is contained in:
Valentin Lorentz 2015-12-07 16:32:46 +01:00
parent b0ee589702
commit 856d275697

View File

@ -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))