-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #34 from erasche/rsync
SSH Transport Implemented
- Loading branch information
Showing
6 changed files
with
187 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import subprocess | ||
import logging | ||
log = logging.getLogger(__name__) | ||
|
||
|
||
def rsync_get_file(uri_from, uri_to, user, host, port, key): | ||
cmd = [ | ||
'rsync', | ||
'-e', | ||
'ssh -i %s -p %s -o StrictHostKeyChecking=no' % (key, port), | ||
'%s@%s:%s' % (user, host, uri_from), | ||
uri_to, | ||
] | ||
exit_code = subprocess.check_call(cmd) | ||
if exit_code != 0: | ||
raise Exception("Rsync exited with code %s" % exit_code) | ||
|
||
|
||
def rsync_post_file(uri_from, uri_to, user, host, port, key): | ||
cmd = [ | ||
'rsync', | ||
'-e', | ||
'ssh -i %s -p %s -o StrictHostKeyChecking=no' % (key, port), | ||
uri_from, | ||
'%s@%s:%s' % (user, host, uri_to), | ||
] | ||
exit_code = subprocess.check_call(cmd) | ||
if exit_code != 0: | ||
raise Exception("Rsync exited with code %s" % exit_code) | ||
|
||
|
||
def scp_get_file(uri_from, uri_to, user, host, port, key): | ||
cmd = [ | ||
'scp', | ||
'-P', str(port), | ||
'-i', key, | ||
'-o', 'StrictHostKeyChecking=no', | ||
'%s@%s:%s' % (user, host, uri_from), | ||
uri_to, | ||
] | ||
exit_code = subprocess.check_call(cmd) | ||
if exit_code != 0: | ||
raise Exception("scp exited with code %s" % exit_code) | ||
|
||
|
||
def scp_post_file(uri_from, uri_to, user, host, port, key): | ||
cmd = [ | ||
'scp', | ||
'-P', str(port), | ||
'-i', key, | ||
'-o', 'StrictHostKeyChecking=no', | ||
uri_from, | ||
'%s@%s:%s' % (user, host, uri_to), | ||
] | ||
exit_code = subprocess.check_call(cmd) | ||
if exit_code != 0: | ||
raise Exception("scp exited with code %s" % exit_code) | ||
|
||
|
||
___all__ = [rsync_post_file, rsync_get_file, scp_post_file, scp_get_file] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters