Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions patchwork/transfers.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ def rsync(
c,
source,
target,
from_local=True,
exclude=(),
delete=False,
strict_host_keys=True,
Expand Down Expand Up @@ -59,7 +60,9 @@ def rsync(
``source`` will be created inside of it. So ``rsync(c, "foldername",
"/home/username")`` would create a new directory
``/home/username/foldername`` (if needed) and place the files there.

:param bool from_local:
Optional, indicates if the copy should be done from local to remote or
the other way around. The default is from local to remote.
:param exclude:
Optional, may be a single string or an iterable of strings, and is
used to pass one or more ``--exclude`` options to ``rsync``.
Expand Down Expand Up @@ -126,8 +129,14 @@ def rsync(
if host.count(":") > 1:
# Square brackets are mandatory for IPv6 rsync address,
# even if port number is not specified
cmd = "rsync {} {} [{}@{}]:{}"
cmd_remote = '[{}@{}]'
else:
cmd_remote = '{}@{}'

if from_local:
cmd = "rsync {} {} " + cmd_remote + ":{}"
cmd = cmd.format(options, source, user, host, target)
else:
cmd = "rsync {} {} {}@{}:{}"
cmd = cmd.format(options, source, user, host, target)
cmd = "rsync {} " + cmd_remote + ":{} {}"
cmd = cmd.format(options, user, host, source, target)
return c.local(cmd)