Generate display before serialization (avoid errors when generation raise exception and database partially saved (months but not meta))

This commit is contained in:
Gregory Soutade 2015-01-11 18:05:09 +01:00
parent a67ed82c74
commit 588b3179d5

View File

@ -578,6 +578,8 @@ class IWLA(object):
if os.path.exists(path): if os.path.exists(path):
os.remove(path) os.remove(path)
self._generateDisplay()
self.logger.info("==> Serialize to %s" % (path)) self.logger.info("==> Serialize to %s" % (path))
self._serialize(self.current_analysis, path) self._serialize(self.current_analysis, path)
@ -590,7 +592,8 @@ class IWLA(object):
self.meta_infos['stats'][year] = {} self.meta_infos['stats'][year] = {}
self.meta_infos['stats'][year][month] = duplicated_stats self.meta_infos['stats'][year][month] = duplicated_stats
self._generateDisplay() self.logger.info("==> Serialize to %s" % (conf.META_PATH))
self._serialize(self.meta_infos, conf.META_PATH)
def _generateDayStats(self): def _generateDayStats(self):
visits = self.current_analysis['visits'] visits = self.current_analysis['visits']
@ -700,7 +703,6 @@ class IWLA(object):
self._generateDayStats() self._generateDayStats()
self._generateMonthStats() self._generateMonthStats()
del self.meta_infos['start_analysis_time'] del self.meta_infos['start_analysis_time']
self._serialize(self.meta_infos, conf.META_PATH)
else: else:
self.logger.info('==> Analyse not started : nothing new') self.logger.info('==> Analyse not started : nothing new')