Commit 0be4a203 authored by Daniel Armbruster's avatar Daniel Armbruster Committed by thomas.forbriger
Browse files

Debugged. Does its job now.

This is a legacy commit from before 2015-05-18.
It may be incomplete as well as inconsistent.
See COPYING.legacy and README.history for details.


SVN Path:     http://gpitrsvn.gpi.uni-karlsruhe.de/repos/TFSoftware/trunk
SVN Revision: 4346
SVN UUID:     67feda4a-a26e-11df-9d6e-31afc202ad0c
parent c0e11ab5
......@@ -128,7 +128,7 @@ def main(argv=None):
"verbose", "debug", "logging", "receiver=", "sender=", "port=", \
"host=", "username=", "password="])
except getopt.GetoptError as err:
raise Usage(130,err.msg)
raise Usage(131,err.msg)
verbose = False
debugMode = False
receivers = []
......@@ -182,22 +182,20 @@ def main(argv=None):
else:
raise Usage(183,"Invalid argument(s).")
print(logFilePathes)
logger.getLogger().debug("Checking email addresses.")
if 0 == len(sender):
raise Usage(189, "Email address of sender missing.")
raise Usage(187, "Email address of sender missing.")
if None == re.match( \
'^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$', sender):
raise Error(192, "Email address of sender not valid.")
raise Error(190, "Email address of sender not valid.")
if 0 == len(receivers):
raise Usage(194, "Email address of receiver missing.")
raise Usage(192, "Email address of receiver missing.")
for add in receivers:
if None == re.match( \
'^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$', add):
raise Error(198, "Email address of receiver not valid.")
raise Error(196, "Email address of receiver not valid.")
infoDequeue = deque(maxlen=5)
infoDequeue = deque(maxlen=10)
warningDequeue = deque(maxlen=10)
errorList = []
criticalList = []
......@@ -217,11 +215,11 @@ def main(argv=None):
else:
logger.getLogger().info("Illegal line in logfile found.")
except IOError as err:
raise Error(220, "Error while reading logfiles.")
raise Error(218, "Error while reading logfiles.")
logger.getLogger().debug("Finished reading logfile(s).")
# prepare email
logger.getLogger().info("Preparing email content ...")
logger.getLogger().debug("Preparing email content ...")
msg = '============================\n'
msg += 'csbackmail.py logfile status\n'
msg += '============================\n'
......@@ -232,7 +230,7 @@ def main(argv=None):
logger.getLogger().debug("Adding INFO logfile lines to mail content.")
subject = 'csback report - severity: INFO'
msg += '--------------------------\n'
msg += 'INFO entries (last 5):\n'
msg += 'INFO entries (last {0}):\n'.format(len(infoList))
msg += '--------------------------\n'
for line in infoList:
msg += line
......@@ -242,7 +240,7 @@ def main(argv=None):
"Adding WARNING logfile lines to mail content.")
subject = 'csback report - severity: WARNING'
msg += '--------------------------\n'
msg += 'WARNING entries (last 10):\n'
msg += 'WARNING entries (last {0}):\n'.format(len(warningList))
msg += '--------------------------\n'
for line in warningList:
msg += line
......@@ -269,7 +267,7 @@ def main(argv=None):
mail['From'] = 'csback <'+sender+'>'
mail['To'] = receivers[0]
if 1 < len(receivers):
mail['CC'] += ', '.join(receiver[1:])
mail['CC'] = ', '.join(receivers[1:])
logger.getLogger().debug("Finished preparation of email content.")
# send mail
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment