[py-svn] r38028 - in py/trunk/py/execnet: . testing

hpk at codespeak.net hpk at codespeak.net
Tue Feb 6 20:32:22 CET 2007


Author: hpk
Date: Tue Feb  6 20:32:21 2007
New Revision: 38028

Modified:
   py/trunk/py/execnet/rsync.py
   py/trunk/py/execnet/testing/test_rsync.py
Log:
make rsync configurable regarding its output
(verbose option and overridable method)



Modified: py/trunk/py/execnet/rsync.py
==============================================================================
--- py/trunk/py/execnet/rsync.py	(original)
+++ py/trunk/py/execnet/rsync.py	Tue Feb  6 20:32:21 2007
@@ -15,10 +15,11 @@
         symlinks will be just copied (regardless of existance of such
         a path on remote side). 
     """
-    def __init__(self, callback=None, **options):
+    def __init__(self, callback=None, verbose=True, **options):
         for name in options:
             assert name in ('delete')
         self._options = options
+        self._verbose = verbose 
         assert callback is None or callable(callback)
         self._callback = callback
         self._channels = {}
@@ -84,11 +85,13 @@
                 # ! there is a reason for the interning:
                 # sharing multiple copies of the file's data
                 data = intern(data)
-                print '%s <= %s' % (
-                    channel.gateway.remoteaddress, 
-                    modified_rel_path)
+                self._report_send_file(channel.gateway, modified_rel_path)
         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):
         """ Sends a sourcedir to all added targets. 
         """

Modified: py/trunk/py/execnet/testing/test_rsync.py
==============================================================================
--- py/trunk/py/execnet/testing/test_rsync.py	(original)
+++ py/trunk/py/execnet/testing/test_rsync.py	Tue Feb  6 20:32:21 2007
@@ -69,6 +69,31 @@
         assert self.dest2.join('hello').check()
         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):
         if py.std.sys.platform == 'win32':
             py.test.skip("symlinks are unsupported on Windows.")



More information about the pytest-commit mailing list