summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2008-03-25 10:41:44 -0300
committerArnaldo Carvalho de Melo <acme@redhat.com>2008-03-25 10:41:44 -0300
commit71174d4a6fe9bd6705e4c4fa4868e0b69acdcd0f (patch)
treef5e5bc920859547c0e47b3cf56c659b02d0dda4b
parent6da342f4382725ace479638cede4a3d8e6c4cae4 (diff)
downloadpython-linux-procfs-71174d4a6fe9bd6705e4c4fa4868e0b69acdcd0f.tar.gz
[PROCFS] cpustats: allow specifying a filename
So that we can experiment with files saved from different machines. Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rwxr-xr-xprocfs/procfs.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/procfs/procfs.py b/procfs/procfs.py
index 22f11f9..50993bf 100755
--- a/procfs/procfs.py
+++ b/procfs/procfs.py
@@ -376,10 +376,11 @@ class cpustat:
self.guest = int(fields[8])
class cpusstats:
- def __init__(self):
+ def __init__(self, filename = "/proc/stat"):
self.entries = []
self.time = None
self.hertz = os.sysconf(2)
+ self.filename = filename
self.reload()
def __iter__(self):
@@ -394,7 +395,7 @@ class cpusstats:
def reload(self):
last_entries = self.entries
self.entries = []
- f = file("/proc/stat")
+ f = file(self.filename)
for line in f.readlines():
fields = line.strip().split()
if fields[0][:3].lower() != "cpu":