From b6185c4b33717583effde1fadd24a02d4af6294f Mon Sep 17 00:00:00 2001 From: Jeremy Fincher Date: Thu, 16 Oct 2003 11:27:45 +0000 Subject: [PATCH] Fixed problems with cpustats on Windows; at least now an error is reported. --- plugins/Status.py | 8 +++++++- test/test_Status.py | 1 - 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/plugins/Status.py b/plugins/Status.py index 53839602e..1d39d428c 100644 --- a/plugins/Status.py +++ b/plugins/Status.py @@ -164,7 +164,13 @@ class Status(callbacks.Privmsg): Returns some interesting CPU-related statistics on the bot. """ (user, system, childUser, childSystem, elapsed) = os.times() - timeRunning = time.time() - world.startedAt + now = time.time() + timeRunning = now - world.startedAt + if user+system > timeRunning: + irc.error(msg, 'I seem to be running on a platform without an ' + 'accurate way of determining how long I\'ve been ' + 'running.') + return activeThreads = threading.activeCount() response = 'I have taken %s seconds of user time and %s seconds of '\ 'system time, for a total of %s seconds of CPU time. My '\ diff --git a/test/test_Status.py b/test/test_Status.py index ecd8f2e43..638def31d 100644 --- a/test/test_Status.py +++ b/test/test_Status.py @@ -45,7 +45,6 @@ class StatusTestCase(PluginTestCase, PluginDocumentation): self.assertNotError('netstats') def testCpustats(self): - self.assertNotError('cpustats') try: original = world.startedAt world.startedAt = time.time()