summaryrefslogtreecommitdiffstats
path: root/src/lib/Server/Plugins/Statistics.py
diff options
context:
space:
mode:
authorSol Jerome <solj@ices.utexas.edu>2009-10-07 14:46:08 +0000
committerSol Jerome <solj@ices.utexas.edu>2009-10-07 14:46:08 +0000
commiteac52c270b8b3b10e461bc46502b64c5f898bd7d (patch)
tree96da2e78af41305b445de23596b75bf754eedbbc /src/lib/Server/Plugins/Statistics.py
parente686d3b69600441e943c2913542e5477af528d87 (diff)
downloadbcfg2-eac52c270b8b3b10e461bc46502b64c5f898bd7d.tar.gz
bcfg2-eac52c270b8b3b10e461bc46502b64c5f898bd7d.tar.bz2
bcfg2-eac52c270b8b3b10e461bc46502b64c5f898bd7d.zip
Pylint/PEP 8 Code cleanups
Signed-off-by: Sol Jerome <solj@ices.utexas.edu> git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@5477 ce84e21b-d406-0410-9b95-82705330c041
Diffstat (limited to 'src/lib/Server/Plugins/Statistics.py')
-rw-r--r--src/lib/Server/Plugins/Statistics.py19
1 files changed, 12 insertions, 7 deletions
diff --git a/src/lib/Server/Plugins/Statistics.py b/src/lib/Server/Plugins/Statistics.py
index 90860e3e4..492e06e9c 100644
--- a/src/lib/Server/Plugins/Statistics.py
+++ b/src/lib/Server/Plugins/Statistics.py
@@ -1,13 +1,18 @@
'''This file manages the statistics collected by the BCFG2 Server'''
__revision__ = '$Revision$'
+import binascii
+import copy
+import difflib
+import logging
from lxml.etree import XML, SubElement, Element, XMLSyntaxError
+import lxml.etree
+import os
from time import asctime, localtime, time, strptime, mktime
-import binascii, difflib, logging, lxml.etree, os, copy
-
import Bcfg2.Server.Plugin
+
class StatisticsStore(object):
'''Manages the memory and file copy of statistics collected about client runs'''
__min_write_delay__ = 0
@@ -23,7 +28,7 @@ class StatisticsStore(object):
def WriteBack(self, force=0):
'''Write statistics changes back to persistent store'''
# FIXME switch to a thread writer
- if (self.dirty and (self.lastwrite + self.__min_write_delay__ <= time()) ) \
+ if (self.dirty and (self.lastwrite + self.__min_write_delay__ <= time())) \
or force:
try:
fout = open(self.filename + '.new', 'w')
@@ -53,11 +58,11 @@ class StatisticsStore(object):
def updateStats(self, xml, client):
'''Updates the statistics of a current node with new data'''
- # Current policy:
+ # Current policy:
# - Keep anything less than 24 hours old
# - Keep latest clean run for clean nodes
# - Keep latest clean and dirty run for dirty nodes
- newstat = xml.find('Statistics')
+ newstat = xml.find('Statistics')
if newstat.get('state') == 'clean':
node_dirty = 0
@@ -98,7 +103,6 @@ class StatisticsStore(object):
self.dirty = 1
self.WriteBack(force=1)
-
def isOlderThan24h(self, testTime):
'''Helper function to determine if <time> string is older than 24 hours'''
now = time()
@@ -107,6 +111,7 @@ class StatisticsStore(object):
return (now-utime) > secondsPerDay
+
class Statistics(Bcfg2.Server.Plugin.Plugin,
Bcfg2.Server.Plugin.Statistics,
Bcfg2.Server.Plugin.PullSource):
@@ -129,7 +134,7 @@ class Statistics(Bcfg2.Server.Plugin.Plugin,
in rt.findall('Statistics')])
return [stat for stat in rt.findall('Statistics') \
if strptime(stat.get('time')) == maxtime][0]
-
+
def GetExtra(self, client):
return [(entry.tag, entry.get('name')) for entry \
in self.FindCurrent(client).xpath('.//Extra/*')]