@type: bool
'''
+ self.has_changed = False
+ '''
+ @ivar: flag, whether something has changed and needs to be written
+ @type: bool
+ '''
+
self.logger = logger
'''
@ivar: logger object
self._read(must_exists = False)
self._check_permissions()
+ #-------------------------------------------------------
+ def __del__(self):
+ '''
+ Destructor.
+ Enforce saving of status file, if something has changed.
+ '''
+
+ _ = self.t.lgettext
+ msg = _("Status file object will destroyed.")
+ self.logger.debug(msg)
+
+ if self.has_changed:
+ self.write()
+
#-------------------------------------------------------
def as_dict(self):
'''
res['logger'] = self.logger
res['file_state'] = self.file_state
res['was_read'] = self.was_read
+ res['has_changed'] = self.has_changed
return res
% {'file': logfile, 'date': date_utc.isoformat(' ') }
self.logger.debug(msg)
- self._read(must_exists = False)
+ #self._read(must_exists = False)
self.file_state[logfile] = date_utc
+ self.has_changed = True
- self._write()
+ #self.write()
return date_utc
#------------------------------------------------------------
- def _write(self):
+ def write(self):
'''
Writes the content of self.file_state in the state file.
fd.close()
fd = None
+ self.has_changed = False
return True
#------------------------------------------------------------
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
+#:LogRotateStatusFile.py:223
+msgid "Status file object will destroyed."
+msgstr "Statusdatei-Objekt wird zerstört."
+
#: LogRotateStatusFile.py:275
#, python-format
msgid "Setting rotation date of '%(file)s' to '%(date)s' ..."
"Content-Type: text/plain; charset=CHARSET\n"
"Content-Transfer-Encoding: 8bit\n"
+#:LogRotateStatusFile.py:223
+msgid "Status file object will destroyed."
+msgstr ""
+
#: LogRotateStatusFile.py:275
#, python-format
msgid "Setting rotation date of '%(file)s' to '%(date)s' ..."