Commit 8e0b087e authored by thomas.forbriger's avatar thomas.forbriger Committed by Checksum Backup @bromo

csbackgen, csfile: capture regex syntax errors

parent 2de76cab
...@@ -39,6 +39,7 @@ ...@@ -39,6 +39,7 @@
# 28/02/2013 V0.7 improve error handling; use error codes # 28/02/2013 V0.7 improve error handling; use error codes
# 26/10/2013 V0.8 dry-run flag introduced # 26/10/2013 V0.8 dry-run flag introduced
# 09/11/2013 V0.8.1 adjusted help text # 09/11/2013 V0.8.1 adjusted help text
# 01/08/2019 V0.8.2 (thof): provide additional debug output
# #
# ============================================================================= # =============================================================================
...@@ -294,6 +295,7 @@ def main(argv=None): ...@@ -294,6 +295,7 @@ def main(argv=None):
# generate checksumfiles for subdirectories (recursive mode) # generate checksumfiles for subdirectories (recursive mode)
# so collect all available subdirectories here (excluding subdirectories) # so collect all available subdirectories here (excluding subdirectories)
if not notRecursive: if not notRecursive:
logger.getLogger().debug("collect subdirectories\n srcpath: %s\n regexes: %s\n followlinks: %s" % (srcpath, regexes, followlinks))
dirs.extend(csfile.getSubDirectories(srcpath, regexes, followlinks)) dirs.extend(csfile.getSubDirectories(srcpath, regexes, followlinks))
# if a target directory had been passed extend the list of # if a target directory had been passed extend the list of
# target directories replacing the trunk of the source directory with the # target directories replacing the trunk of the source directory with the
......
...@@ -51,6 +51,8 @@ ...@@ -51,6 +51,8 @@
# files based on time stamp values) for open time windows # files based on time stamp values) for open time windows
# (like all younger than 3 days), we use datetime.max as # (like all younger than 3 days), we use datetime.max as
# the end time # the end time
# 01/08/2019 V0.6.6 (thof) let getSubDirectories produce a reasonable error
# message, if application of a regex fails
# #
# ============================================================================= # =============================================================================
""" CsFile module to handle checksumfiles. """ """ CsFile module to handle checksumfiles. """
...@@ -68,7 +70,7 @@ from datetime import date ...@@ -68,7 +70,7 @@ from datetime import date
import csbacklog import csbacklog
import csbackErrorCodes as eCodes import csbackErrorCodes as eCodes
__version__ = "V0.6.5" __version__ = "V0.6.6"
__subversion__ = "$Id$" __subversion__ = "$Id$"
__license__ = "GPLv2+" __license__ = "GPLv2+"
__author__ = "Daniel Armbruster" __author__ = "Daniel Armbruster"
...@@ -102,7 +104,10 @@ def getSubDirectories(path, regexes, followLinks=False): ...@@ -102,7 +104,10 @@ def getSubDirectories(path, regexes, followLinks=False):
subDirs.add(os.path.join(root, dir)) subDirs.add(os.path.join(root, dir))
# exclude directories matching regexes # exclude directories matching regexes
for regex in regexes: for regex in regexes:
matching = set(dir for dir in subDirs if None != re.match(regex, dir)) try:
matching = set(dir for dir in subDirs if None != re.match(regex, dir))
except:
raise CsFileError("application of exclude regex %s failed!" % regex, eCodes.CSFILE_CollectingSubDirs)
subDirs -= matching subDirs -= matching
except OSError as err: except OSError as err:
raise CsFileError("[Errno "+str(err.errno)+"] "+err.strerror+": " \ raise CsFileError("[Errno "+str(err.errno)+"] "+err.strerror+": " \
......
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