From 1bf7a50758171184e6f2ebceabe7a47e5c9150a1 Mon Sep 17 00:00:00 2001 From: Alexander Sulfrian Date: Thu, 31 Aug 2017 15:44:21 +0200 Subject: [PATCH 1/5] travis-ci: Enforce Python3 support --- .travis.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index af365b9d94..18234c5967 100644 --- a/.travis.yml +++ b/.travis.yml @@ -44,9 +44,6 @@ matrix: apt: packages: *build_deps_optional - allow_failures: - - python: "3.5" - fast_finish: true before_install: From 3f2f5eba3b8670c95c320899932c25db47273a10 Mon Sep 17 00:00:00 2001 From: Alexander Sulfrian Date: Thu, 31 Aug 2017 17:33:18 +0200 Subject: [PATCH 2/5] testsuite: Allow pylint to load some c extensions --- testsuite/pylintrc.conf | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/testsuite/pylintrc.conf b/testsuite/pylintrc.conf index ce7e407dfc..019adafc22 100644 --- a/testsuite/pylintrc.conf +++ b/testsuite/pylintrc.conf @@ -21,6 +21,10 @@ persistent=no # usually to register additional checkers. load-plugins=ext.exception_messages,ext.ssl_protocols,ext.pylint_compat +# A comma-separated list of package or module names from where C extensions may +# be loaded. Extensions are loading into the active Python interpreter and may +# run arbitrary code +extension-pkg-whitelist=lxml,posix1e [MESSAGES CONTROL] From a37e7c9cd773edf4699e07618b26436f7362719a Mon Sep 17 00:00:00 2001 From: Alexander Sulfrian Date: Fri, 3 Nov 2017 18:36:16 +0100 Subject: [PATCH 3/5] Python3: Fix "unsupported operand type(s) for +: 'dict_keys' and 'list'" dict.keys returns a dictionary view in Python 3. --- src/lib/Bcfg2/Server/Plugins/TemplateHelper.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib/Bcfg2/Server/Plugins/TemplateHelper.py b/src/lib/Bcfg2/Server/Plugins/TemplateHelper.py index ff67571fad..201ac17361 100644 --- a/src/lib/Bcfg2/Server/Plugins/TemplateHelper.py +++ b/src/lib/Bcfg2/Server/Plugins/TemplateHelper.py @@ -31,9 +31,9 @@ def __init__(self, name, core): self.defaults = [] default_prov = DefaultTemplateDataProvider() - self.reserved_defaults = default_prov.get_template_data( + self.reserved_defaults = list(default_prov.get_template_data( lxml.etree.Element("Path", name="/dummy"), - None, None).keys() + ["path"] + None, None)) + ["path"] def HandleEvent(self, event=None): """ HandleEvent is called whenever the FAM registers an event. From de40679d8f45a4065440c86cafc2d78b0f3f0114 Mon Sep 17 00:00:00 2001 From: Alexander Sulfrian Date: Fri, 3 Nov 2017 18:37:35 +0100 Subject: [PATCH 4/5] Pylint: Do not call keys() for iterating over dictionaries This should fix the pylint warning: > Consider iterating the dictionary directly instead of calling .keys() --- src/lib/Bcfg2/Client/Tools/SELinux.py | 4 ++-- src/lib/Bcfg2/Server/Core.py | 2 +- src/lib/Bcfg2/Server/Lint/Validate.py | 2 +- src/lib/Bcfg2/Server/MultiprocessingCore.py | 2 +- src/lib/Bcfg2/Server/Plugin/helpers.py | 2 +- src/lib/Bcfg2/Server/Plugins/PuppetENC.py | 2 +- src/lib/Bcfg2/Server/Plugins/Trigger.py | 2 +- 7 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/lib/Bcfg2/Client/Tools/SELinux.py b/src/lib/Bcfg2/Client/Tools/SELinux.py index 7b5ff78139..240d152e87 100644 --- a/src/lib/Bcfg2/Client/Tools/SELinux.py +++ b/src/lib/Bcfg2/Client/Tools/SELinux.py @@ -754,7 +754,7 @@ def all_records(self): self._all[mod] = (version, 1) # get other (disabled) modules from the filesystem - for mod in self._all_records_from_filesystem().keys(): + for mod in self._all_records_from_filesystem(): if mod not in self._all: self._all[mod] = ('', 0) else: @@ -902,7 +902,7 @@ def FindExtra(self): specified = [self._key(e) for e in self.tool.getSupportedEntries()] rv = [] - for module in self._all_records_from_filesystem().keys(): + for module in self._all_records_from_filesystem(): if module not in specified: rv.append(self.key2entry(module)) return rv diff --git a/src/lib/Bcfg2/Server/Core.py b/src/lib/Bcfg2/Server/Core.py index 445bc17b5b..b63907b7e8 100644 --- a/src/lib/Bcfg2/Server/Core.py +++ b/src/lib/Bcfg2/Server/Core.py @@ -1072,7 +1072,7 @@ def listMethods(self, address): # pylint: disable=W0613 for name, func in inspect.getmembers(self, callable) if (getattr(func, "exposed", False) and self.check_acls(address, name))] - methods.extend([m for m in self._get_rmi().keys() + methods.extend([m for m in self._get_rmi() if self.check_acls(address, m)]) return methods diff --git a/src/lib/Bcfg2/Server/Lint/Validate.py b/src/lib/Bcfg2/Server/Lint/Validate.py index d6f18afbbd..6139c84d31 100644 --- a/src/lib/Bcfg2/Server/Lint/Validate.py +++ b/src/lib/Bcfg2/Server/Lint/Validate.py @@ -210,7 +210,7 @@ def get_filelists(self): values are lists of the full paths to all files in the Bcfg2 repository (or given with ``bcfg2-lint --stdin``) that match the glob.""" - for path in self.filesets.keys(): + for path in self.filesets: if '/**/' in path: if self.files is not None: self.filelists[path] = self.list_matching_files(path) diff --git a/src/lib/Bcfg2/Server/MultiprocessingCore.py b/src/lib/Bcfg2/Server/MultiprocessingCore.py index 4bf3e4a273..1ea6589562 100644 --- a/src/lib/Bcfg2/Server/MultiprocessingCore.py +++ b/src/lib/Bcfg2/Server/MultiprocessingCore.py @@ -404,7 +404,7 @@ def _get_rmi(self): "%s.%s" % (pname, childname) rmi = BuiltinCore._get_rmi(self) - for method in rmi.keys(): + for method in rmi: if method in child_rmi: rmi[method] = self._child_rmi_wrapper(method, rmi[method], diff --git a/src/lib/Bcfg2/Server/Plugin/helpers.py b/src/lib/Bcfg2/Server/Plugin/helpers.py index 762d018ebc..725ad9fe4e 100644 --- a/src/lib/Bcfg2/Server/Plugin/helpers.py +++ b/src/lib/Bcfg2/Server/Plugin/helpers.py @@ -1743,7 +1743,7 @@ def _current_data(self): and ``unknown`` for all callable values. """ rv = dict() - for key in self._getters.keys(): + for key in self._getters: if callable(self._getters[key]): rv[key] = 'unknown' else: diff --git a/src/lib/Bcfg2/Server/Plugins/PuppetENC.py b/src/lib/Bcfg2/Server/Plugins/PuppetENC.py index e2d8a058f3..30dcc00652 100644 --- a/src/lib/Bcfg2/Server/Plugins/PuppetENC.py +++ b/src/lib/Bcfg2/Server/Plugins/PuppetENC.py @@ -41,7 +41,7 @@ def __init__(self, core): def _run_encs(self, metadata): """ Run all Puppet ENCs """ cache = dict(groups=[], params=dict()) - for enc in self.entries.keys(): + for enc in self.entries: epath = os.path.join(self.data, enc) self.debug_log("PuppetENC: Running ENC %s for %s" % (enc, metadata.hostname)) diff --git a/src/lib/Bcfg2/Server/Plugins/Trigger.py b/src/lib/Bcfg2/Server/Plugins/Trigger.py index 12672de7d9..cc1c2a2d11 100644 --- a/src/lib/Bcfg2/Server/Plugins/Trigger.py +++ b/src/lib/Bcfg2/Server/Plugins/Trigger.py @@ -46,6 +46,6 @@ def async_run(self, args): def end_client_run(self, metadata): args = [metadata.hostname, '-p', metadata.profile, '-g', ':'.join([g for g in metadata.groups])] - for notifier in self.entries.keys(): + for notifier in self.entries: npath = os.path.join(self.data, notifier) self.async_run([npath] + args) From b2f8338945b99ba6c99453b2598dccfe9ecdb71b Mon Sep 17 00:00:00 2001 From: Alexander Sulfrian Date: Fri, 22 Jan 2021 17:24:54 +0100 Subject: [PATCH 5/5] travis: Use Python 3.9 This is the default python version in bullseye. --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 18234c5967..48ca472084 100644 --- a/.travis.yml +++ b/.travis.yml @@ -38,7 +38,7 @@ matrix: apt: packages: [*build_deps_optional, python-gamin, python-selinux] - - python: "3.5" + - python: "3.9" env: WITH_OPTIONAL_DEPS=yes addons: apt: