def print_matches(): """ Usage: rsyncmatch.py [--debug] [filter rules...] directory ... Print list of files below <directory> that match the given rules. Rules are specified with "--exclude=", "--include=", "--exclude-from=", "--include-from=", see rsync(1) for rule semantics. """ import getopt import logging loggingclass.init_logging() gl = GlobChain() (options, args) = getopt.gnu_getopt(sys.argv[1:], "", (gl._known_options) + ("debug",)) gl.getopt(options) for x in options: if x[0] == "--debug": GlobChain().set_log_level(loggingclass.DEBUG) RsyncGlob().set_log_level(loggingclass.DEBUG) for dir in args: ls = gl.recurse(dir) print "List of include files below %s:" % dir for x in ls: print " " + x
def print_matches(): """ Usage: rsyncmatch.py [--debug] [filter rules...] directory ... Print list of files below <directory> that match the given rules. Rules are specified with "--exclude=", "--include=", "--exclude-from=", "--include-from=", see rsync(1) for rule semantics. """ import getopt import logging loggingclass.init_logging() gl = GlobChain() (options, args) = getopt.gnu_getopt(sys.argv[1:], "", (gl._known_options) + ("debug", )) gl.getopt(options) for x in options: if x[0] == "--debug": GlobChain().set_log_level(loggingclass.DEBUG) RsyncGlob().set_log_level(loggingclass.DEBUG) for dir in args: ls = gl.recurse(dir) print "List of include files below %s:" % dir for x in ls: print " " + x
def start_logging(level, logfile): """ Initialize a useful logging environment with logging to stderr, slightly more verbose to a log file, and suitable log levels. """ loggingclass.init_logging(level) if level == loggingclass.DEBUG: # loggingclass.getLogger().setLevel(loggingclass.DEBUG) loggingclass.set_default_level(loggingclass.INFO) if logfile != "": loggingclass.init_logfile(logfile, level=loggingclass.DEBUG) loggingclass.set_class_level(RsyncSynchronizer, loggingclass.DEBUG) loggingclass.set_class_level(GlobChain, loggingclass.DEBUG) loggingclass.set_class_level(CachingFTPHost, loggingclass.INFO) else: if logfile != "": loggingclass.init_logfile(logfile, level=loggingclass.INFO) loggingclass.set_class_level(RsyncSynchronizer, loggingclass.INFO) loggingclass.set_class_level(CachingFTPHost, loggingclass.INFO)