summaryrefslogtreecommitdiffstats
path: root/src/lib/Server/Statistics.py
diff options
context:
space:
mode:
authorNarayan Desai <desai@mcs.anl.gov>2007-02-10 02:59:20 +0000
committerNarayan Desai <desai@mcs.anl.gov>2007-02-10 02:59:20 +0000
commit16b4e38d338cf9fb0c36ae32e193177405844677 (patch)
tree9bbc6e8fd504a56894e7b56b190ad25b48c194d4 /src/lib/Server/Statistics.py
parenta195b9bf6ca1713305f95a3db9d2c3352f568eba (diff)
downloadbcfg2-16b4e38d338cf9fb0c36ae32e193177405844677.tar.gz
bcfg2-16b4e38d338cf9fb0c36ae32e193177405844677.tar.bz2
bcfg2-16b4e38d338cf9fb0c36ae32e193177405844677.zip
Write statistics into a temporary location
git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@2798 ce84e21b-d406-0410-9b95-82705330c041
Diffstat (limited to 'src/lib/Server/Statistics.py')
-rw-r--r--src/lib/Server/Statistics.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/lib/Server/Statistics.py b/src/lib/Server/Statistics.py
index ac46f13e8..3304bab40 100644
--- a/src/lib/Server/Statistics.py
+++ b/src/lib/Server/Statistics.py
@@ -4,7 +4,7 @@ __revision__ = '$Revision$'
from lxml.etree import XML, SubElement, Element, XMLSyntaxError
from time import asctime, localtime, time
-import logging, lxml.etree
+import logging, lxml.etree, os
class Statistics(object):
'''Manages the memory and file copy of statistics collected about client runs'''
@@ -24,7 +24,7 @@ class Statistics(object):
or force:
#syslog(LOG_INFO, "Statistics: Updated statistics.xml")
try:
- fout = open(self.filename, 'w')
+ fout = open(self.filename + '.new', 'w')
except IOError, ioerr:
self.logger.error("Failed to open %s for writing: %s" % (self.filename, ioerr))
else:
@@ -32,6 +32,7 @@ class Statistics(object):
fout.close()
self.dirty = 0
self.lastwrite = time()
+ os.rename(self.filename + '.new', self.filename)
def ReadFromFile(self):
'''Reads current state regarding statistics'''