summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Breunig <christian@breunig.cc>2023-12-09 21:36:40 +0100
committerGitHub <noreply@github.com>2023-12-09 21:36:40 +0100
commit6c6dae5179b17f9253c38d973dfa7e5cdaa0491e (patch)
tree31885f1b09da701b9f6dc44dbad7aa90461c99f8
parentff3ecc1b4d4ede0fb4ca15484a9655c628f4354f (diff)
parent078c491b6f1df81176a57d71b8095a2d6c29b153 (diff)
downloadvyos-1x-6c6dae5179b17f9253c38d973dfa7e5cdaa0491e.tar.gz
vyos-1x-6c6dae5179b17f9253c38d973dfa7e5cdaa0491e.zip
Merge pull request #2599 from vyos/mergify/bp/sagitta/pr-2541
remote: T5773: Fix for broken config download (backport #2541)
-rw-r--r--python/vyos/remote.py30
1 files changed, 13 insertions, 17 deletions
diff --git a/python/vyos/remote.py b/python/vyos/remote.py
index 8b90e4530..8928cce67 100644
--- a/python/vyos/remote.py
+++ b/python/vyos/remote.py
@@ -46,17 +46,6 @@ from vyos.version import get_version
CHUNK_SIZE = 8192
-@contextmanager
-def umask(mask: int):
- """
- Context manager that temporarily sets the process umask.
- """
- oldmask = os.umask(mask)
- try:
- yield
- finally:
- os.umask(oldmask)
-
class InteractivePolicy(MissingHostKeyPolicy):
"""
Paramiko policy for interactively querying the user on whether to proceed
@@ -88,6 +77,17 @@ class SourceAdapter(HTTPAdapter):
num_pools=connections, maxsize=maxsize,
block=block, source_address=self._source_pair)
+@contextmanager
+def umask(mask: int):
+ """
+ Context manager that temporarily sets the process umask.
+ """
+ import os
+ oldmask = os.umask(mask)
+ try:
+ yield
+ finally:
+ os.umask(oldmask)
def check_storage(path, size):
"""
@@ -436,26 +436,22 @@ def urlc(urlstring, *args, **kwargs):
except KeyError:
raise ValueError(f'Unsupported URL scheme: "{scheme}"')
-def download(local_path, urlstring, progressbar=False, raise_error=False, check_space=False,
+def download(local_path, urlstring, progressbar=False, check_space=False,
source_host='', source_port=0, timeout=10.0):
try:
progressbar = progressbar and is_interactive()
urlc(urlstring, progressbar, check_space, source_host, source_port, timeout).download(local_path)
except Exception as err:
- if raise_error:
- raise
print_error(f'Unable to download "{urlstring}": {err}')
except KeyboardInterrupt:
print_error('\nDownload aborted by user.')
-def upload(local_path, urlstring, progressbar=False, raise_error=False,
+def upload(local_path, urlstring, progressbar=False,
source_host='', source_port=0, timeout=10.0):
try:
progressbar = progressbar and is_interactive()
urlc(urlstring, progressbar, source_host, source_port, timeout).upload(local_path)
except Exception as err:
- if raise_error:
- raise
print_error(f'Unable to upload "{urlstring}": {err}')
except KeyboardInterrupt:
print_error('\nUpload aborted by user.')