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

Multiple exclude flags are supported 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: 4150
SVN UUID:     67feda4a-a26e-11df-9d6e-31afc202ad0c
parent 1f0fd2d8
......@@ -32,6 +32,7 @@
#
# REVISIONS and CHANGES
# 11/09/2011 V0.1 Daniel Armbruster
# 14/09/2011 V0.8 Now multiple exclude flags in CONFIGFILE are supported
#
# =============================================================================
......@@ -42,7 +43,7 @@ import pwd
import string
from datetime import datetime
version="cscron2back V0.1"
version="cscron2back V0.8"
license="GPL"
......@@ -149,57 +150,66 @@ class Processor():
res = []
for line_dict in self.__sLines:
# check flags
flags = {}
flags = dict.fromkeys(self.__flags, False)
if self.__keylist[2] in line_dict:
flags = self.__chkflags(line_dict[self.__keylist[2]])
s = line_dict[self.__keylist[0]] + " "
# handle exclude flags
if flags[self.__flags[3]]:
e_flags = flags[self.__flags[3]].split()
else:
e_flags = []
if self.__keylist[3] in line_dict:
# backup is desired - use rsync
s += "csbackgen"
if flags[self.__flags[3]]:
s += " " + self.__flags[3] + " '" + flags[self.__flags[3]] + "'"
s += " '" + line_dict[self.__keylist[1]] + "'; rsync"
if flags[self.__flags[3]]:
s += " --exclude= '" + flags[self.__flags[3]] + "'"
s += " '" + line_dict[self.__keylist[1]] + "' '" +\
line_dict[self.__keylist[3]] + "'"
for f in e_flags:
s += " " + self.__flags[3] + " '" + f + "'"
s += " " + line_dict[self.__keylist[1]] + "; rsync"
for f in e_flags:
s += " --exclude '" + f + "'"
s += " " + line_dict[self.__keylist[1]] + " " +\
line_dict[self.__keylist[3]]
# check of integrity is desired
if not flags[self.__flags[2]]:
s += "; csbackchk"
if flags[self.__flags[1]]:
s += " " + __flags[1]
if flags[self.__flags[3]]:
s += " " + self.__flags[3] + " '" + flags[self.__flags[3]] + "'"
s += " '" + line_dict[self.__keylist[3]] + "'"
for f in e_flags:
s += " " + self.__flags[3] + " '" + f + "'"
s += " " + line_dict[self.__keylist[3]]
if flags[self.__flags[0]]:
s += " '" + line_dict[self.__keylist[1]] + "'"
s += " " + line_dict[self.__keylist[1]]
s += "\n"
else:
# test only
s += 'csbackchk'
if self.__flags[1] in flags and flags[self.__flags[1]]:
if flags[self.__flags[1]]:
s += " " + self.__flags[1]
if self.__flags[3] in flags and flags[self.__flags[3]]:
s += " " + self.__flags[3] + " '" + flags[self.__flags[3]] + "'"
s += " '" + line_dict[self.__keylist[1]] + "'\n"
for f in e_flags:
s += " " + self.__flags[3] + " '" + f + "'"
s += " " + line_dict[self.__keylist[1]] + "\n"
res.append(s)
# email report
if self.__sendmail:
# TODO: variable time
s = "0 12 * * * csbackmail '" + self.__addresses + "'\n"
s = "0 12 * * * csbackmail " + self.__addresses + "\n"
res.append(s)
return res
def __chkflags(self, flags):
res = dict.fromkeys(self.__flags, False)
res[self.__flags[3]] = ''
l = flags.split()
for f in self.__flags[:3]:
if str(f) in l:
res[f] = True
# handle exclude flag
if self.__flags[3] in l and \
l[l.index(self.__flags[3])+1] not in self.__flags:
res[self.__flags[3]] = l[l.index(self.__flags[3])+1]
# handle exclude flags
for e_flag in l:
if e_flag == self.__flags[3] and \
l[l.index(e_flag)+1] not in self.__flags:
res[self.__flags[3]] += l[l.index(self.__flags[3])+1] + " "
l[l.index(self.__flags[3])] = ''
res[self.__flags[3]] = res[self.__flags[3]].rstrip()
return res
def __isdir(self, dir):
......
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