diff options
author | Narayan Desai <desai@mcs.anl.gov> | 2006-06-10 03:59:42 +0000 |
---|---|---|
committer | Narayan Desai <desai@mcs.anl.gov> | 2006-06-10 03:59:42 +0000 |
commit | 15b08bc42392bda2346087faf13c21154391ce60 (patch) | |
tree | 962f0fd25c352b5b3ef69b67e2d3b1056b0a13d5 /src/lib | |
parent | 79c62a02345661661a56f2a0028e9dadeaa522c9 (diff) | |
download | bcfg2-15b08bc42392bda2346087faf13c21154391ce60.tar.gz bcfg2-15b08bc42392bda2346087faf13c21154391ce60.tar.bz2 bcfg2-15b08bc42392bda2346087faf13c21154391ce60.zip |
Patch from Jos to handle statistics write errors more cleanly.
git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@1873 ce84e21b-d406-0410-9b95-82705330c041
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/Server/Statistics.py | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/src/lib/Server/Statistics.py b/src/lib/Server/Statistics.py index 64d6433a2..e13bd805e 100644 --- a/src/lib/Server/Statistics.py +++ b/src/lib/Server/Statistics.py @@ -39,11 +39,14 @@ class Statistics(object): if (self.dirty and (self.lastwrite + self.__min_write_delay__ <= time()) ) \ or force: #syslog(LOG_INFO, "Statistics: Updated statistics.xml") - fout = open(self.filename, 'w') - fout.write(self.pretty_print(self.element)) - fout.close() - self.dirty = 0 - self.lastwrite = time() + try: + fout = open(self.filename, 'w') + fout.write(self.pretty_print(self.element)) + fout.close() + self.dirty = 0 + self.lastwrite = time() + except IOError: + self.logger.error("Failed to open %s for writing" % (self.filename)) def ReadFromFile(self): '''Reads current state regarding statistics''' |