[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[or-cvs] r24063: {arm} Patch by Fabian to properly parse the ps field when displayi (arm/trunk/src/util)
Author: atagar
Date: 2011-01-12 04:48:18 +0000 (Wed, 12 Jan 2011)
New Revision: 24063
Modified:
arm/trunk/src/util/sysTools.py
arm/trunk/src/util/uiTools.py
Log:
Patch by Fabian to properly parse the ps field when displaying decimal seconds.
Modified: arm/trunk/src/util/sysTools.py
===================================================================
--- arm/trunk/src/util/sysTools.py 2011-01-11 18:49:17 UTC (rev 24062)
+++ arm/trunk/src/util/sysTools.py 2011-01-12 04:48:18 UTC (rev 24063)
@@ -479,8 +479,15 @@
newValues["memUsagePercentage"] = float(memUsage) / totalMemory
else:
# the ps call formats results as:
- # %CPU RSS %MEM ELAPSED
- # 0.3 14096 1.3 29:51
+ #
+ # TIME ELAPSED RSS %MEM
+ # 3-08:06:32 21-00:00:12 121844 23.5
+ #
+ # or if Tor has only recently been started:
+ #
+ # TIME ELAPSED RSS %MEM
+ # 0:04.40 37:57 18772 0.9
+
psCall = call("ps -p %s -o cputime,etime,rss,%%mem" % self.processPid)
isSuccessful = False
Modified: arm/trunk/src/util/uiTools.py
===================================================================
--- arm/trunk/src/util/uiTools.py 2011-01-11 18:49:17 UTC (rev 24062)
+++ arm/trunk/src/util/uiTools.py 2011-01-12 04:48:18 UTC (rev 24063)
@@ -333,7 +333,7 @@
"""
Provides the number of seconds corresponding to the formatting used for the
cputime and etime fields of ps:
- [[dd-]hh:]mm:ss
+ [[dd-]hh:]mm:ss or hh:mm.ss
If the input entry is malformed then this raises a ValueError.
@@ -349,6 +349,9 @@
days = int(timeEntry[:dateDivider])
timeEntry = timeEntry[dateDivider+1:]
+ # normalise the seconds delimiter
+ timeEntry = timeEntry.replace(".", ":")
+
timeComp = timeEntry.split(":")
if len(timeComp) == 3:
hours, minutes, seconds = timeComp