diff options
| author | John Estabrook <jestabro@vyos.io> | 2026-03-07 13:37:55 -0600 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-03-07 13:37:55 -0600 |
| commit | 36542e14afbbca59b643e3cb9959f235e92a11e9 (patch) | |
| tree | 2f84a96aeb624d7305a33dabdd6ca72ef5b7b469 /python | |
| parent | 479e3d78ba9280ccb30b8e42c1f12b9fc5ae0522 (diff) | |
| parent | 5b1b2b8d9a057731963a40bb3af2c8b9bc910e24 (diff) | |
| download | vyos-1x-36542e14afbbca59b643e3cb9959f235e92a11e9.tar.gz vyos-1x-36542e14afbbca59b643e3cb9959f235e92a11e9.zip | |
Merge pull request #5031 from c-po/pylint-t8347
T8347: enable pylint for all files under python/* path
Diffstat (limited to 'python')
| -rw-r--r-- | python/vyos/configverify.py | 2 | ||||
| -rw-r--r-- | python/vyos/debug.py | 3 | ||||
| -rw-r--r-- | python/vyos/remote.py | 22 | ||||
| -rwxr-xr-x | python/vyos/template.py | 6 |
4 files changed, 15 insertions, 18 deletions
diff --git a/python/vyos/configverify.py b/python/vyos/configverify.py index cc4419913..995c4ee83 100644 --- a/python/vyos/configverify.py +++ b/python/vyos/configverify.py @@ -501,7 +501,7 @@ def verify_pki_ca_certificate(config: dict, ca_name: str): pki_cert = config['pki']['ca'][ca_name] if 'certificate' not in pki_cert: - raise ConfigError(f'PEM CA certificate for "{cert_name}" missing in configuration!') + raise ConfigError(f'PEM CA certificate for "{ca_name}" missing in configuration!') def verify_pki_dh_parameters(config: dict, dh_name: str, min_key_size: int=0): """ diff --git a/python/vyos/debug.py b/python/vyos/debug.py index 5b6e8172e..1a6924ef5 100644 --- a/python/vyos/debug.py +++ b/python/vyos/debug.py @@ -38,13 +38,12 @@ def message(message, flag='', destination=sys.stdout): if not logfile: return enable + mask = os.umask(0o111) try: # at boot the file is created as root:vyattacfg # at runtime the file is created as user:vyattacfg # but the helper scripts are not run as this so it # need the default permission to be 666 (an not 660) - mask = os.umask(0o111) - with open(logfile, 'a') as f: f.write(_timed(_format('log', message))) finally: diff --git a/python/vyos/remote.py b/python/vyos/remote.py index b73f486c0..417f9d42c 100644 --- a/python/vyos/remote.py +++ b/python/vyos/remote.py @@ -35,7 +35,7 @@ from paramiko import MissingHostKeyPolicy from requests import Session from requests.adapters import HTTPAdapter -from requests.packages.urllib3 import PoolManager +from urllib3 import PoolManager from vyos.progressbar import Progressbar from vyos.utils.io import ask_yes_no @@ -220,23 +220,21 @@ class SshC: def upload(self, location: str): with self._establish() as ssh, ssh.open_sftp() as sftp: + # A file exists at this destination. We're simply going to clobber it. + # This is our default fallback + path = self.path try: # If the remote path is a directory, use the original filename. if stat.S_ISDIR(sftp.stat(self.path).st_mode): path = os.path.join(self.path, os.path.basename(location)) - # A file exists at this destination. We're simply going to clobber it. - else: - path = self.path - # This path doesn't point at any existing file. We can freely use this filename. except IOError: - path = self.path - finally: - if self.progressbar: - with Progressbar() as p: - sftp.put(location, path, callback=p.progress) - else: - sftp.put(location, path) + pass + if self.progressbar: + with Progressbar() as p: + sftp.put(location, path, callback=p.progress) + else: + sftp.put(location, path) class HttpC: def __init__(self, diff --git a/python/vyos/template.py b/python/vyos/template.py index 596f9e8c5..2a783bc74 100755 --- a/python/vyos/template.py +++ b/python/vyos/template.py @@ -274,9 +274,9 @@ def netmask_from_ipv4(address): Example: - 172.18.201.10 -> 255.255.255.128 """ - from netifaces import interfaces - from netifaces import ifaddresses - from netifaces import AF_INET + from netifaces import interfaces # pylint: disable = no-name-in-module + from netifaces import ifaddresses # pylint: disable = no-name-in-module + from socket import AF_INET for interface in interfaces(): tmp = ifaddresses(interface) if AF_INET in tmp: |
