...
 
......@@ -40,6 +40,7 @@
# 26/10/2013 V0.8 dry-run flag introduced
# 09/11/2013 V0.8.1 adjusted help text
# 01/08/2019 V0.8.2 (thof): provide additional debug output
# 02/08/2019 V0.8.3 (thof): do not produce multiline log messages
#
# =============================================================================
......@@ -54,7 +55,7 @@ import csbacklog
import pidlock
import csbackErrorCodes as eCodes
__version__ = "V0.8.1"
__version__ = "V0.8.3"
__subversion__ = "$Id$"
__license__ = "GPLv2+"
__author__ = "Daniel Armbruster"
......@@ -295,7 +296,10 @@ def main(argv=None):
# generate checksumfiles for subdirectories (recursive mode)
# so collect all available subdirectories here (excluding subdirectories)
if not notRecursive:
logger.getLogger().debug("collect subdirectories\n srcpath: %s\n regexes: %s\n followlinks: %s" % (srcpath, regexes, followlinks))
logger.getLogger().debug("collect subdirectories")
logger.getLogger().debug(" srcpath: '%s'" % srcpath)
logger.getLogger().debug(" regexes: '%s'" % regexes)
logger.getLogger().debug(" followlinks: '%s'" % followlinks)
dirs.extend(csfile.getSubDirectories(srcpath, regexes, followlinks))
# if a target directory had been passed extend the list of
# target directories replacing the trunk of the source directory with the
......
......@@ -44,6 +44,10 @@
# 01/03/2013 V0.8 Improve error handling and use error codes
# 17/03/2013 V0.8.1 show number of critical and error entries in mail
# 01/09/2014 V0.9 (thof) use local mail transfer agent
# 02/08/2019 V0.10 (thof) print reasonable error meassage if non of the
# message level keywords is found
# (thof) catch parsing error in date section of log line
# V0.11 (thof) gracefully skip ill-formatted log lines
#
# =============================================================================
"""
......@@ -65,7 +69,7 @@ import csbackErrorCodes as eCodes
from email.mime.text import MIMEText
from collections import deque
__version__ = "V0.9"
__version__ = "V0.11"
__subversion__ = "$Id$"
__license__ = "GPLv2+"
__author__ = "Daniel Armbruster"
......@@ -269,21 +273,28 @@ def main(argv=None):
for path in logFilePathes:
for line in open(path, 'r').readlines():
# extract timestamp from log message
timeStamp=dt.datetime.strptime(str(now.year)+" "+" ".join(str(n) \
try:
timeStamp=dt.datetime.strptime(str(now.year)+" "+" ".join(str(n)
for n in line.split()[0:3]),"%Y %b %d %H:%M:%S")
if 'CRITICAL' in line:
if timeStamp > timeLimit:
criticalList.append("logfile: "+path+"\n"+line)
elif 'ERROR' in line:
if timeStamp > timeLimit:
errorList.append("logfile: "+path+"\n"+line)
elif 'WARNING' in line:
if timeStamp > timeLimit:
warningDeque.appendleft("logfile: "+path+"\n"+line)
elif 'INFO' in line:
infoDeque.appendleft("logfile: "+path+"\n"+line)
except:
logger.getLogger().error("Error while parsing log line: '%s'"
% line)
else:
logger.getLogger().info("Illegal line in logfile found: '"+line+"'")
if 'CRITICAL' in line:
if timeStamp > timeLimit:
criticalList.append("logfile: "+path+"\n"+line)
elif 'ERROR' in line:
if timeStamp > timeLimit:
errorList.append("logfile: "+path+"\n"+line)
elif 'WARNING' in line:
if timeStamp > timeLimit:
warningDeque.appendleft("logfile: "+path+"\n"+line)
elif 'INFO' in line:
infoDeque.appendleft("logfile: "+path+"\n"+line)
else:
logger.getLogger().info("Illegal line in logfile found")
logger.getLogger().info(" Line does not contain any of the csback message level keywords")
logger.getLogger().info(" The log line is: '%s'" % line)
except IOError as err:
raise Error("Error while reading logfiles: "+err.filename, \
eCodes.NTFY_IOError)
......
......@@ -55,6 +55,7 @@
# message, if application of a regex fails
# V0.6.7 (thof) capture problem with whitespace in file names
# which results in not accepted hash types
# 02/08/2019 V0.6.8 (thof) do not write newline to log entries
#
# =============================================================================
""" CsFile module to handle checksumfiles. """
......@@ -72,7 +73,7 @@ from datetime import date
import csbacklog
import csbackErrorCodes as eCodes
__version__ = "V0.6.7"
__version__ = "V0.6.8"
__subversion__ = "$Id$"
__license__ = "GPLv2+"
__author__ = "Daniel Armbruster"
......@@ -500,11 +501,11 @@ class CsLine:
try:
hashfunc = hashlib.new(self.hashfunc)
except:
raise CsFileError(("When evaluating checksum file entry\n in directory %s\n"
+" hash type '%s' as specified for file '%s' is not accepted\n"
+" consider a problem with whitespace in file names\n"
+" the respective checksum file entry is\n"
+" %s") % (self.srcdir, self.hashfunc, self.filename, self), eCodes.GLOBAL_UnhandledException)
self.logger.error("Start reading checksumfile '%s'",self.filename)
self.logger.error(" Checksum line: '%s'",self)
self.logger.error(" Hash is not accepted: '%s'",self.hasfunc)
raise CsFileError("Abort caused by ill-formatted checksum line '%'"
% self, eCodes.GLOBAL_UnhandledException)
blockSize = chunkSize * hashfunc.block_size
path = os.path.join(self.srcdir, self.filename)
try:
......