diff options
author | Daniil Baturin <daniil@vyos.io> | 2021-03-30 22:34:28 +0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-30 22:34:28 +0700 |
commit | f2633dcbdbf108804acff61964c0b418ba25d645 (patch) | |
tree | 204e0815f31e2a31bd3863b8e4806c688cf75ad1 /python/vyos | |
parent | 60e28c57d6b8e811c57ded53dbc5f9ac2e308e90 (diff) | |
parent | 052080ef66bd8a8082226562b4d8bd9e331fe0a4 (diff) | |
download | vyos-1x-f2633dcbdbf108804acff61964c0b418ba25d645.tar.gz vyos-1x-f2633dcbdbf108804acff61964c0b418ba25d645.zip |
Merge pull request #795 from erkin/equuleus
T3356, T3284: Backport remote.py fixes to Equuleus
Diffstat (limited to 'python/vyos')
-rw-r--r-- | python/vyos/remote.py | 9 |
1 files changed, 2 insertions, 7 deletions
diff --git a/python/vyos/remote.py b/python/vyos/remote.py index ad9706a82..18e772cc8 100644 --- a/python/vyos/remote.py +++ b/python/vyos/remote.py @@ -57,11 +57,11 @@ def download_sftp(local_path, hostname, remote_path,\ def upload_tftp(local_path, hostname, remote_path, port=69): with open(local_path, 'rb') as file: - cmd(f'curl -s -T - tftp://{hostname}:{port}/{remote_path}', stderr=None, input=file.read()) + cmd(f'curl -s -T - tftp://{hostname}:{port}/{remote_path}', stderr=None, input=file.read()).encode() def download_tftp(local_path, hostname, remote_path, port=69): with open(local_path, 'wb') as file: - file.write(cmd(f'curl -s tftp://{hostname}:{port}/{remote_path}', stderr=None)) + file.write(cmd(f'curl -s tftp://{hostname}:{port}/{remote_path}', stderr=None).encode()) def download_http(urlstring, local_path): with open(local_path, 'wb') as file: @@ -79,10 +79,6 @@ def download(local_path, urlstring): username = url.username if url.username else 'anonymous' download_ftp(local_path, url.hostname, url.path, username, url.password) elif url.scheme == 'sftp' or url.scheme == 'scp': - # None means we don't want to use password authentication. - # An empty string (what urlparse returns when a password doesn't - # exist in the URL) means the password is an empty string. - password = url.password if url.password else None download_sftp(local_path, url.hostname, url.path, url.username, password) elif url.scheme == 'tftp': download_tftp(local_path, url.hostname, url.path) @@ -98,7 +94,6 @@ def upload(local_path, urlstring): username = url.username if url.username else 'anonymous' upload_ftp(local_path, url.hostname, url.path, username, url.password) elif url.scheme == 'sftp' or url.scheme == 'scp': - password = url.password if url.password else None upload_sftp(local_path, url.hostname, url.path, url.username, password) elif url.scheme == 'tftp': upload_tftp(local_path, url.hostname, url.path) |