[svn r38028] make rsync configurable regarding its output
(verbose option and overridable method) --HG-- branch : trunk
This commit is contained in:
parent
ef43218016
commit
4369d430c8
|
@ -15,10 +15,11 @@ class RSync(object):
|
||||||
symlinks will be just copied (regardless of existance of such
|
symlinks will be just copied (regardless of existance of such
|
||||||
a path on remote side).
|
a path on remote side).
|
||||||
"""
|
"""
|
||||||
def __init__(self, callback=None, **options):
|
def __init__(self, callback=None, verbose=True, **options):
|
||||||
for name in options:
|
for name in options:
|
||||||
assert name in ('delete')
|
assert name in ('delete')
|
||||||
self._options = options
|
self._options = options
|
||||||
|
self._verbose = verbose
|
||||||
assert callback is None or callable(callback)
|
assert callback is None or callable(callback)
|
||||||
self._callback = callback
|
self._callback = callback
|
||||||
self._channels = {}
|
self._channels = {}
|
||||||
|
@ -84,11 +85,13 @@ class RSync(object):
|
||||||
# ! there is a reason for the interning:
|
# ! there is a reason for the interning:
|
||||||
# sharing multiple copies of the file's data
|
# sharing multiple copies of the file's data
|
||||||
data = intern(data)
|
data = intern(data)
|
||||||
print '%s <= %s' % (
|
self._report_send_file(channel.gateway, modified_rel_path)
|
||||||
channel.gateway.remoteaddress,
|
|
||||||
modified_rel_path)
|
|
||||||
channel.send(data)
|
channel.send(data)
|
||||||
|
|
||||||
|
def _report_send_file(self, gateway, modified_rel_path):
|
||||||
|
if self._verbose:
|
||||||
|
print '%s <= %s' % (gateway.remoteaddress, modified_rel_path)
|
||||||
|
|
||||||
def send(self, sourcedir):
|
def send(self, sourcedir):
|
||||||
""" Sends a sourcedir to all added targets.
|
""" Sends a sourcedir to all added targets.
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -69,6 +69,31 @@ class TestRSync(DirSetup):
|
||||||
assert self.dest2.join('hello').check()
|
assert self.dest2.join('hello').check()
|
||||||
py.test.raises(IOError, "rsync.send(self.source)")
|
py.test.raises(IOError, "rsync.send(self.source)")
|
||||||
|
|
||||||
|
def test_rsync_default_reporting(self):
|
||||||
|
source = self.source
|
||||||
|
source.ensure("hello")
|
||||||
|
cap = py.io.StdCapture()
|
||||||
|
try:
|
||||||
|
rsync = RSync()
|
||||||
|
rsync.add_target(gw, self.dest1)
|
||||||
|
rsync.send(self.source)
|
||||||
|
finally:
|
||||||
|
out, err = cap.reset()
|
||||||
|
assert out.find("hello") != -1
|
||||||
|
|
||||||
|
def test_rsync_non_verbose(self):
|
||||||
|
source = self.source
|
||||||
|
source.ensure("hello")
|
||||||
|
cap = py.io.StdCapture()
|
||||||
|
try:
|
||||||
|
rsync = RSync(verbose=False)
|
||||||
|
rsync.add_target(gw, self.dest1)
|
||||||
|
rsync.send(self.source)
|
||||||
|
finally:
|
||||||
|
out, err = cap.reset()
|
||||||
|
assert not out
|
||||||
|
assert not err
|
||||||
|
|
||||||
def test_symlink_rsync(self):
|
def test_symlink_rsync(self):
|
||||||
if py.std.sys.platform == 'win32':
|
if py.std.sys.platform == 'win32':
|
||||||
py.test.skip("symlinks are unsupported on Windows.")
|
py.test.skip("symlinks are unsupported on Windows.")
|
||||||
|
|
Loading…
Reference in New Issue