summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorDaniil Baturin <daniil@vyos.io>2021-03-30 22:12:17 +0700
committerGitHub <noreply@github.com>2021-03-30 22:12:17 +0700
commit62369cef4df5a5e781b42e38ef15231b4f5c0f0d (patch)
tree77cc679f0e4c370873c155a4dae8d23b68080bf9 /python
parent0c13a4fa454926f9891450b12ffc34ef7c54d523 (diff)
parenta32d5e824df9e16d4e6c9198f093fd9f1baffcc6 (diff)
downloadvyos-1x-62369cef4df5a5e781b42e38ef15231b4f5c0f0d.tar.gz
vyos-1x-62369cef4df5a5e781b42e38ef15231b4f5c0f0d.zip
Merge pull request #794 from erkin/current
T3354: Handle user break and prematurely closed stdin in strip-private
Diffstat (limited to 'python')
-rw-r--r--python/vyos/remote.py9
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)