From 3e8c73e6c377eadb957e2309432f3027ce4b0acb Mon Sep 17 00:00:00 2001 From: Frank Brehm Date: Thu, 30 Jun 2011 16:40:11 +0000 Subject: [PATCH] delete_oldfiles() fertig git-svn-id: http://svn.brehm-online.com/svn/my-stuff/python/PyLogrotate/trunk@270 ec8d2aa5-1599-4edb-8739-2b3a1bc399aa --- LogRotateHandler.py | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/LogRotateHandler.py b/LogRotateHandler.py index 924b21c..63536bf 100755 --- a/LogRotateHandler.py +++ b/LogRotateHandler.py @@ -1657,7 +1657,33 @@ class LogrotateHandler(object): #------------------------------------------------------------ def delete_oldfiles(self): - pass + ''' + Deleting of all logfiles in self.files_delete + + @return: None + ''' + + _ = self.t.lgettext + + msg = _("Deletion of all superfluid logfiles ...") + self.logger.debug(msg) + + if not len(self.files_delete.keys()): + msg = _("No logfiles to delete found.") + self.logger.info(msg) + + for logfile in sorted(self.files_delete.keys(), key=str.lower): + msg = _("Deleting file '%s' ...") % (logfile) + self.logger.info(msg) + if not self.test: + try: + os.remove(logfile) + except OSError, e: + msg = _("Error on removing file '%(file)s': %(err)s") \ + % {'file': logfile, 'err': e.strerror} + self.logger.error(msg) + + return #------------------------------------------------------------ def compress(self): -- 2.39.5