From 15b08bc42392bda2346087faf13c21154391ce60 Mon Sep 17 00:00:00 2001 From: Narayan Desai Date: Sat, 10 Jun 2006 03:59:42 +0000 Subject: 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 --- src/lib/Server/Statistics.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'src') 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''' -- cgit v1.2.3-1-g7c22