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

smaller enhancements and corrections

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: 4362
SVN UUID:     67feda4a-a26e-11df-9d6e-31afc202ad0c
parent e5f3f9af
......@@ -180,8 +180,8 @@ class BackupConverter(Converter):
self.line = self.sectionDict['cronexpr']+' rsync -aq'
for regex in self.sectionDict['exclude']:
self.line += " --exclude='"+regex+"'"
self.line += self.sectionDict['srcdir']+' '+self.sectionDict['targetdir']+ \
'; csbackgen'
self.line += ' '+self.sectionDict['srcdir']+' '+ \
self.sectionDict['targetdir']+'; csbackgen'
if self.sectionDict['logging']:
self.line += ' -l'
if not self.sectionDict['recursive']:
......@@ -272,7 +272,10 @@ class Processor():
backup['cronexpr'] = self.config.get(key, 'cronexpr').strip()
backup['srcdir'] = self.config.get(key, 'srcdir').strip()
backup['targetdir'] = self.config.get(key, 'targetdir').strip()
backup['exclude'] = self.config.get(key, 'exclude',raw=1).split(", ")
if self.config.has_option(key, 'exclude'):
backup['exclude'] = self.config.get(key, 'exclude',raw=1).split(", ")
else:
backup['exclude'] = []
backup['recursive'] = self.config.getboolean(key, 'recursive')
backup['logging'] = self.config.getboolean(key, 'logging')
backup['followlinks'] = self.config.getboolean(key, 'followlinks')
......@@ -290,36 +293,37 @@ class Processor():
self.backups = {}
# fetch tests section
try:
testKeys = dict(self.config.items('tests'))
if 'keys' in testKeys:
tests = set(testKeys['keys'].split(","))
tests = ['test_'+key.strip() for key in tests]
# fetch every test section
for key in tests:
if not self.config.has_section(key):
raise Error("Section {0} in configfile not defined.".format(key))
test = {'id': key}
try:
test['cronexpr'] = self.config.get(key, 'cronexpr').strip()
test['dir'] = self.config.get(key, 'dir').strip()
if self.config.has_option(key, 'srcdir'):
test['srcdir'] = self.config.get(key, 'srcdir').strip()
else:
test['srcdir'] = test['dir']
testKeys = self.config.get('tests', 'keys')
testKeys = set(testKeys.split(","))
testKeys = ['test_'+key.strip() for key in testKeys]
# fetch every test section
for key in testKeys:
if not self.config.has_section(key):
raise Error("Section {0} in configfile not defined.".format(key))
test = {'id': key}
try:
test['cronexpr'] = self.config.get(key, 'cronexpr').strip()
test['dir'] = self.config.get(key, 'dir').strip()
if self.config.has_option(key, 'srcdir'):
test['srcdir'] = self.config.get(key, 'srcdir').strip()
else:
test['srcdir'] = test['dir']
if self.config.has_option(key, 'exclude'):
test['exclude'] = self.config.get(key, 'exclude', raw=1).split(", ")
test['recursive'] = self.config.getboolean(key, 'recursive')
test['logging'] = self.config.getboolean(key, 'logging')
test['followlinks'] = self.config.getboolean(key, 'followlinks')
test['tolerant'] = self.config.getboolean(key, 'tolerant')
except NoOptionError as err:
raise Error("{0}".format(err.message))
except ValueError:
raise Error("Argument error in [{0}] section.".format(key))
else:
self.tests.append(test)
else:
raise Error(\
"Key 'keys' in configfile section [tests] not defined.")
test['exclude'] = []
test['recursive'] = self.config.getboolean(key, 'recursive')
test['logging'] = self.config.getboolean(key, 'logging')
test['followlinks'] = self.config.getboolean(key, 'followlinks')
test['tolerant'] = self.config.getboolean(key, 'tolerant')
except NoOptionError as err:
raise Error("{0}".format(err.message))
except ValueError:
raise Error("Argument error in [{0}] section.".format(key))
else:
self.tests.append(test)
except NoOptionError as err:
raise Error("{0}".format(err.message))
except NoSectionError:
self.tests = {}
if self.__verbose:
......@@ -359,7 +363,8 @@ class Processor():
"""
# header lines
output = ['# This is <' + self.crontabfile + '>\n',
'# Generated with csback2cron.\n',
'# Generated with csback2cron '+__version__+'.\n',
'# '+__subversion__+'\n'
'# '+datetime.now().strftime("%Y-%m-%d %H:%M:%S")+'\n',
'# -------------------------------------------------------------\n\n']
output.extend(self.result)
......@@ -373,7 +378,7 @@ class Processor():
sys.stdout.write("csback2cron: " + self.crontabfile + " written.\n")
DEFAULTS = {'logging': 'yes', 'recursive': 'yes', 'followlinks': 'false', \
'tolerant': 'no', 'test': 'yes', 'exclude': ''}
'tolerant': 'no', 'test': 'yes'}
# -----------------------------------------------------------------------------
def main(argv=None):
......
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