Commit 22dc274b authored by Nicolas Wavrant's avatar Nicolas Wavrant

improve call to rsync

parent be10ba69
......@@ -85,13 +85,13 @@ def rsync(rsync_binary, source, destination, extra_args=None, dry=False):
return
try:
subprocess.check_call(arg_list)
subprocess.check_output(arg_list)
except subprocess.CalledProcessError as e:
# All rsync errors are not to be considered as errors
allowed_error_message_regex = \
allowed_error_message_list = \
'^(file has vanished: |rsync warning: some files vanished before they could be transferred)'
if e.returncode not in (0, 24) or \
re.match(allowed_error_message_regex, e.output) is not None:
if e.returncode != 24 or \
re.search(allowed_error_message_regex, e.output, re.M) is None:
raise e
......
......@@ -125,8 +125,8 @@ class TestRunnerExporter(unittest.TestCase):
)
@mock.patch('subprocess.check_call')
def test_synchroniseRunnerConfigurationDirectory(self, check_call_mock):
@mock.patch('subprocess.check_output')
def test_synchroniseRunnerConfigurationDirectory(self, check_output_mock):
self._setUpFakeInstanceFolder()
config = Config()
config.rsync_binary = 'rsync'
......@@ -135,14 +135,14 @@ class TestRunnerExporter(unittest.TestCase):
runner_exporter.synchroniseRunnerConfigurationDirectory(
config, 'backup/runner/etc/'
)
self.assertEqual(check_call_mock.call_count, 1)
check_call_mock.assert_any_call(
self.assertEqual(check_output_mock.call_count, 1)
check_output_mock.assert_any_call(
['rsync', '-rlptgov', '--stats', '--safe-links', '--ignore-missing-args', '--delete', '--delete-excluded', 'config.json', '.parameters.xml', '.project', 'backup/runner/etc/']
)
@mock.patch('subprocess.check_call')
def test_synchroniseRunnerWorkingDirectory(self, check_call_mock):
@mock.patch('subprocess.check_output')
def test_synchroniseRunnerWorkingDirectory(self, check_output_mock):
self._setUpFakeInstanceFolder()
config = Config()
config.rsync_binary = 'rsync'
......@@ -152,8 +152,8 @@ class TestRunnerExporter(unittest.TestCase):
config, 'backup/runner/runner'
)
self.assertEqual(check_call_mock.call_count, 1)
check_call_mock.assert_any_call(
self.assertEqual(check_output_mock.call_count, 1)
check_output_mock.assert_any_call(
['rsync', '-rlptgov', '--stats', '--safe-links', '--ignore-missing-args', '--delete', '--delete-excluded', '--exclude=*.sock', '--exclude=*.socket', '--exclude=*.pid', '--exclude=.installed*.cfg', '--exclude=srv/backup/**', '--exclude=instance/slappart0/etc/nicolas.txt', '--exclude=instance/slappart0/etc/rafael.txt', '--exclude=srv/exporter.exclude', 'instance', 'project', 'public', 'proxy.db', 'backup/runner/runner']
)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment