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

implementation of converters - proceeding

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: 4358
SVN UUID:     67feda4a-a26e-11df-9d6e-31afc202ad0c
parent 0f5f3833
......@@ -138,22 +138,58 @@ class MailConverter(Converter):
Class which implements a mail section dictionary converter
"""
def convertDict(self):
line =
self.line =
self.line = self.sectionDict['cronexpr']+' csbackmail'
if self.sectionDict['logging']:
self.line += ' -l'
self.line += ' -H '+self.sectionDict['host']+' -P '+ \
self.sectionDict['port']+' -u '+self.sectionDict['username']+' -p ' \
+ self.sectionDict['password']+' -s '+self.sectionDict['sender']
for receiver in self.sectionDict['receivers']:
self.line += ' -r ' + receiver
class BackupConverter(Converter):
class TestConverter(Converter):
"""
Class which implements a backup section dictionary converter
Class which implements a test section dictionary converter
"""
def convertDict(self):
self.line = self.sectionDict['cronexpr']+' csbackchk'
if self.sectionDict['logging']:
self.line += ' -l'
if not self.sectionDict['recursive']:
self.line += ' -R'
if self.sectionDict['followlinks']:
self.line += ' -f'
if self.sectionDict['tolerant']:
self.line += ' -t'
for regex in self.sectionDict['exclude']:
self.line += " -e '"+regex+"'"
self.line += ' '+self.sectionDict['srcdir']+' '+self.sectionDict['dir']
class TestConverter(Converter):
class BackupConverter(Converter):
"""
Class which implements a test section dictionary converter
Class which implements a backup section dictionary converter
"""
def convertDict(self):
line = self.sectionDict['cronexpr']+' rsync -aq'
for regex in self.sectionDict['exclude']
line += " --exclude='"+regex+"'"
line += self.sectionDict['srcdir']+' '+self.sectionDict['targetdir']+ \
'; csbackgen'
if self.sectionDict['logging']:
self.line += ' -l'
if not self.sectionDict['recursive']:
self.line += ' -R'
if self.sectionDict['followlinks']:
self.line += ' -f'
for regex in self.sectionDict['exclude']
line += " -e '"+regex+"'
line += ' -t '+self.sectionDict['targetdir']+' '+self.sectionDict['srcdir']
if self.sectionDict['test']:
# keep on going here
testConv = TestConverter()
# -----------------------------------------------------------------------------
class Processor():
......@@ -180,14 +216,15 @@ class Processor():
# fetch mail section
if self.config.has_section('mail'):
try:
self.mail['cronexpr'] = config.get('mail', 'cronexpr').strip()
self.mail['receivers'] = \
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')
self.mail['host'] = self.config.get('mail', 'host')
self.mail['username'] = self.config.get('mail', 'username')
self.mail['password'] = self.config.get('mail', 'password')
self.mail['sender'] = self.config.get('mail', 'sender').strip()
self.mail['host'] = self.config.get('mail', 'host').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', 'logging'):
self.mail['logging'] = self.config.getboolean('mail', 'logging')
else:
......@@ -210,9 +247,9 @@ class Processor():
raise Error("Section {0} in configfile not defined.".format(key))
backup = {'id': key}
try:
backup['cronexpr'] = config.get(key, 'cronexpr')
backup['srcdir'] = config.get(key, 'srcdir')
backup['targetdir'] = config.get(key, 'targetdir')
backup['cronexpr'] = config.get(key, 'cronexpr').strip()
backup['srcdir'] = config.get(key, 'srcdir').strip()
backup['targetdir'] = config.get(key, 'targetdir').strip()
backup['exclude'] = config.get(key, 'exclude').split(", ")
if self.config.has_option(key, 'recursive'):
backup['recursive'] = self.config.getboolean(key, 'recursive')
......@@ -247,12 +284,12 @@ class Processor():
raise Error("Section {0} in configfile not defined.".format(key))
test = {'id': key}
try:
test['cronexpr'] = config.get(key, 'cronexpr')
test['dir'] = config.get(key, 'dir')
test['cronexpr'] = config.get(key, 'cronexpr').strip()
test['dir'] = config.get(key, 'dir').strip()
if self.config.has_option(key, 'srcdir'):
test['srcdir'] = self.config.get(key, 'srcdir')
test['srcdir'] = self.config.get(key, 'srcdir').strip()
else:
test['srcdir'] = test['dir']
test['srcdir'] = test['dir']
test['exclude'] = config.get(key, 'exclude').split(", ")
if self.config.has_option(key, 'recursive'):
test['recursive'] = self.config.getboolean(key, 'recursive')
......
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