Commit 10fbb7bd authored by thomas.forbriger's avatar thomas.forbriger

[FIX] (csback2cron): make mail options optional

All options in the mail section which are no longer mandatory to csbackntfy.py
are no longer expected by csback2cron.py but are just evaluated, if provided
in the config file. No consistency checks are performed. A such created
crontab entry still may be rejected by csbackntfy.py
parent 5e9e3785
......@@ -184,9 +184,16 @@ class MailConverter(Converter):
self.line += ' -l'
if self.sectionDict['statusfile']:
self.line += ' -S '+self.sectionDict['statusfile']
self.line += ' -H '+self.sectionDict['host']+' -P '+ \
self.sectionDict['port']+' -u '+self.sectionDict['username']+' -p ' \
+ self.sectionDict['password']+' -s '+self.sectionDict['sender']
if self.sectionDict['host']:
self.line += ' -H '+self.sectionDict['host']
if self.sectionDict['port']:
self.line += ' -P '+self.sectionDict['port']
if self.sectionDict['username']:
self.line += ' -u '+self.sectionDict['username']
if self.sectionDict['password']:
self.line += ' -u '+self.sectionDict['password']
if self.sectionDict['sender']:
self.line += ' -s '+self.sectionDict['sender']
for receiver in self.sectionDict['receivers']:
self.line += ' -r ' + receiver
......@@ -392,11 +399,26 @@ class Processor():
self.config.get('mail', 'receivers').split(',')
self.mail['receivers'] = [add.strip() \
for add in self.mail['receivers']]
self.mail['sender'] = self.config.get('mail', 'sender').strip()
self.mail['host'] = self.config.get('mail', 'host').strip()
self.mail['port'] = self.config.get('mail', 'port').strip()
self.mail['username'] = self.config.get('mail', 'username').strip()
self.mail['password'] = self.config.get('mail', 'password').strip()
if self.config.has_option('mail', 'sender'):
self.mail['sender'] = self.config.get('mail', 'sender').strip()
else:
self.mail['sender'] = ''
if self.config.has_option('mail', 'host'):
self.mail['host'] = self.config.get('mail', 'host').strip()
else:
self.mail['host'] = ''
if self.config.has_option('mail', 'port'):
self.mail['port'] = self.config.get('mail', 'port').strip()
else:
self.mail['port'] = ''
if self.config.has_option('mail', 'username'):
self.mail['username'] = self.config.get('mail', 'username').strip()
else:
self.mail['username'] = ''
if self.config.has_option('mail', 'password'):
self.mail['password'] = self.config.get('mail', 'password').strip()
else:
self.mail['password'] = ''
self.mail['logging'] = False
if self.config.has_option('mail', 'logging'):
self.mail['logging'] = self.config.getboolean('mail', 'logging')
......@@ -639,7 +661,6 @@ class Processor():
# header lines
output = ['# This is <' + self.crontabfile + '>\n',
'# Generated with csback2cron '+__version__+'.\n',
'# '+__subversion__+'\n'
'# '+datetime.now().strftime("%Y-%m-%d %H:%M:%S")+'\n',
'# -------------------------------------------------------------\n\n']
output.extend(self.result)
......
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