[svn r38176] make delete a per-host option (internally it is anyway)
--HG-- branch : trunk
This commit is contained in:
parent
c18ab8fd7e
commit
7fccd77b8a
|
@ -3,23 +3,16 @@ from Queue import Queue
|
|||
|
||||
|
||||
class RSync(object):
|
||||
""" This class allows to synchronise files and directories
|
||||
with one or multiple remote filesystems.
|
||||
|
||||
An RSync instance allows to dynamically add remote targets
|
||||
and then synchronizes the remote filesystems with
|
||||
any provided source directory.
|
||||
""" This class allows to send a directory structure (recursively)
|
||||
to one or multiple remote filesystems.
|
||||
|
||||
There is limited support for symlinks, which means that symlinks
|
||||
pointing to the sourcetree will be send "as is" while external
|
||||
symlinks will be just copied (regardless of existance of such
|
||||
a path on remote side).
|
||||
"""
|
||||
def __init__(self, sourcedir, callback=None, verbose=True, **options):
|
||||
for name in options:
|
||||
assert name in ('delete')
|
||||
def __init__(self, sourcedir, callback=None, verbose=True):
|
||||
self._sourcedir = str(sourcedir)
|
||||
self._options = options
|
||||
self._verbose = verbose
|
||||
assert callback is None or callable(callback)
|
||||
self._callback = callback
|
||||
|
@ -135,16 +128,19 @@ class RSync(object):
|
|||
else:
|
||||
assert "Unknown command %s" % command
|
||||
|
||||
def add_target(self, gateway, destdir, finishedcallback=None):
|
||||
def add_target(self, gateway, destdir,
|
||||
finishedcallback=None, **options):
|
||||
""" Adds a remote target specified via a 'gateway'
|
||||
and a remote destination directory.
|
||||
"""
|
||||
assert finishedcallback is None or callable(finishedcallback)
|
||||
for name in options:
|
||||
assert name in ('delete',)
|
||||
def itemcallback(req):
|
||||
self._receivequeue.put((channel, req))
|
||||
channel = gateway.remote_exec(REMOTE_SOURCE)
|
||||
channel.setcallback(itemcallback, endmarker = None)
|
||||
channel.send((str(destdir), self._options))
|
||||
channel.send((str(destdir), options))
|
||||
self._channels[channel] = finishedcallback
|
||||
|
||||
def _broadcast(self, msg):
|
||||
|
|
|
@ -50,12 +50,12 @@ class TestRSync(DirSetup):
|
|||
rsync.send()
|
||||
assert dest.join('subdir', 'file1').check(file=1)
|
||||
assert dest2.join('subdir', 'file1').check(file=1)
|
||||
rsync = RSync(source, delete=True)
|
||||
rsync = RSync(source)
|
||||
rsync.add_target(gw, dest, delete=True)
|
||||
rsync.add_target(gw2, dest2)
|
||||
rsync.add_target(gw, dest)
|
||||
rsync.send()
|
||||
assert not dest.join('subdir', 'file1').check()
|
||||
assert not dest2.join('subdir', 'file1').check()
|
||||
assert dest2.join('subdir', 'file1').check()
|
||||
|
||||
def test_dirsync_twice(self):
|
||||
source = self.source
|
||||
|
|
|
@ -77,7 +77,6 @@ class HostRSync(py.execnet.RSync):
|
|||
if 'ignores' in kwargs:
|
||||
ignores = kwargs.pop('ignores')
|
||||
self._ignores = ignores or []
|
||||
kwargs['delete'] = True
|
||||
super(HostRSync, self).__init__(source, **kwargs)
|
||||
|
||||
def filter(self, path):
|
||||
|
@ -106,7 +105,9 @@ class HostRSync(py.execnet.RSync):
|
|||
remotepath = os.path.join(remotepath, destrelpath)
|
||||
super(HostRSync, self).add_target(gw,
|
||||
remotepath,
|
||||
finishedcallback)
|
||||
finishedcallback,
|
||||
delete=True,
|
||||
)
|
||||
return remotepath
|
||||
|
||||
class HostManager(object):
|
||||
|
|
Loading…
Reference in New Issue