Merge lp:~hloeung/charm-helpers/rsync-stderrors into lp:charm-helpers

Proposed by Haw Loeung
Status: Merged
Merged at revision: 668
Proposed branch: lp:~hloeung/charm-helpers/rsync-stderrors
Merge into: lp:charm-helpers
Diff against target: 23 lines (+4/-2)
1 file modified
charmhelpers/core/host.py (+4/-2)
To merge this branch: bzr merge lp:~hloeung/charm-helpers/rsync-stderrors
Reviewer Review Type Date Requested Status
Stuart Bishop (community) Approve
Review via email: mp+312515@code.launchpad.net

Description of the change

Update rsync() to catch and report rsync errors. Current output below isn't very helpful:

| 2016-11-11 13:50:57 WARNING juju-log rsync failed(23): b''

Also add option to run rsync via 'timeout'.

To post a comment you must log in.
666. By Haw Loeung

core/host: Update rsync() adding option to specify how long rsync should run before it times out.

667. By Haw Loeung

[trivial] Fixed TypeError: sequence item 1: expected str instance, int found.

668. By Haw Loeung

Fixed stderr output of check_output().

Revision history for this message
Stuart Bishop (stub) wrote :

Fine. There is a failing tests, but it is trivial for me to fix.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'charmhelpers/core/host.py'
2--- charmhelpers/core/host.py 2016-11-09 11:15:25 +0000
3+++ charmhelpers/core/host.py 2016-12-13 06:23:23 +0000
4@@ -306,15 +306,17 @@
5 subprocess.check_call(cmd)
6
7
8-def rsync(from_path, to_path, flags='-r', options=None):
9+def rsync(from_path, to_path, flags='-r', options=None, timeout=None):
10 """Replicate the contents of a path"""
11 options = options or ['--delete', '--executability']
12 cmd = ['/usr/bin/rsync', flags]
13+ if timeout:
14+ cmd = ['timeout', str(timeout)] + cmd
15 cmd.extend(options)
16 cmd.append(from_path)
17 cmd.append(to_path)
18 log(" ".join(cmd))
19- return subprocess.check_output(cmd).decode('UTF-8').strip()
20+ return subprocess.check_output(cmd, stderr=subprocess.STDOUT).decode('UTF-8').strip()
21
22
23 def symlink(source, destination):

Subscribers

People subscribed via source and target branches