Ejemplo n.º 1
0
class RsyncSynchronizer(Synchronizer):
    """
    Special Synchronzer class that uses rsyncmatch.GlobChain
    for include/exclude logic.
    """
    def __init__(self, *args, **kwargs):
        Synchronizer.__init__(self, *args, **kwargs)
        self.globchain = GlobChain()

    def exclude(self, dir, name, isdir):
        path = self.io_s.path.join(dir, name)
        if isdir:
            path = path + "/"
        
        gl = self.globchain.match(path)
        return gl == EXCLUDE
Ejemplo n.º 2
0
class RsyncSynchronizer(Synchronizer):
    """
    Special Synchronzer class that uses rsyncmatch.GlobChain
    for include/exclude logic.
    """
    def __init__(self, *args, **kwargs):
        Synchronizer.__init__(self, *args, **kwargs)
        self.globchain = GlobChain()

    def exclude(self, dir, name, isdir):
        path = self.io_s.path.join(dir, name)
        if isdir:
            path = path + "/"

        gl = self.globchain.match(path)
        return gl == EXCLUDE
Ejemplo n.º 3
0
class _Params:
    """
    Class representing options and arguments for do_sync().
    """
    class UsageError(Exception):
        pass

    known = (list(GlobChain().options()) + [
        "delete", "delete-excluded", "dry-run", "verbose", "quiet", "debug",
        "trace=", "cache-expire=", "cache-size="
    ])

    def usage(self):
        sys.stderr.write("""\
Usage: %s [options] host source-dir target-dir
Known options: %s
""" % (sys.argv[0], ", ".join(["--" + x for x in self.known])))
        raise self.UsageError()

    def _setlevel(self, level, option=True):
        if self.level == -1:
            self.level = level
        elif option:
            sys.stderr.write(
                "Only one of --quiet, --debug, --verbose may be specified\n")
            self.usage()

    def __init__(self):
        self.level = -1
        self.dry_run = False
        self.delete = False
        self.delete_excluded = False
        self.logfile = ""
        self.expire = 300
        self.size = 2000

        try:
            (opts, args) = getopt.gnu_getopt(sys.argv[1:], "", self.known)
        except getopt.GetoptError:
            print_err()
            self.usage()

        for (o, v) in opts:
            if o == "--delete":
                self.delete = True
            elif o == "--delete-excluded":
                self.delete_excluded = True
            elif o == "--dry-run":
                self.dry_run = True
            elif o == "--verbose":
                self._setlevel(loggingclass.INFO)
            elif o == "--debug":
                self._setlevel(loggingclass.DEBUG)
            elif o == "--quiet":
                self._setlevel(loggingclass.WARNING)
            elif o == "--trace":
                self.logfile = v
            elif o == "--cache-expire":
                self.expire = int(v)
            elif o == "--cache-size":
                self.size = int(v)

        self._setlevel(loggingclass.NOTICE, option=False)
        if len(args) != 3:
            self.usage()

        (self.host, self.source, self.target) = args
        self.opts = opts
Ejemplo n.º 4
0
 def __init__(self, *args, **kwargs):
     Synchronizer.__init__(self, *args, **kwargs)
     self.globchain = GlobChain()
Ejemplo n.º 5
0
 def __init__(self, *args, **kwargs):
     Synchronizer.__init__(self, *args, **kwargs)
     self.globchain = GlobChain()