diff --git a/cgcs-patch/cgcs-patch/cgcs_make_patch/make_patch_functions.py b/cgcs-patch/cgcs-patch/cgcs_make_patch/make_patch_functions.py index 6cec6f36..7cab3573 100644 --- a/cgcs-patch/cgcs-patch/cgcs_make_patch/make_patch_functions.py +++ b/cgcs-patch/cgcs-patch/cgcs_make_patch/make_patch_functions.py @@ -17,6 +17,7 @@ import getopt import subprocess import time import re +import six from cgcs_patch.patch_functions import PatchFile # import twisted.python.lockfile @@ -1258,7 +1259,7 @@ class PatchRecipeData(object): rpm_dir = "%s/%s/%s" % (workdir, build_type, RPM_DIR) rpm_db = self._get_rpm_db_path(self.patch_id) issue_cmd("echo > %s" % rpm_db) - for subdir in os.walk(rpm_dir).next()[1]: + for subdir in six.next(os.walk(rpm_dir))[1]: rpm_sub_dir = "%s/%s" % (rpm_dir, subdir) issue_cmd("rpm -qp --dbpath %s --queryformat '%s %%{NAME} %%{RELEASE}\n' %s/*rpm >> %s 2> /dev/null" % (temp_rpm_db_dir, subdir, rpm_sub_dir, rpm_db)) diff --git a/cgcs-patch/cgcs-patch/cgcs_patch/api/controllers/root.py b/cgcs-patch/cgcs-patch/cgcs_patch/api/controllers/root.py index 883b58d5..ecce3472 100644 --- a/cgcs-patch/cgcs-patch/cgcs_patch/api/controllers/root.py +++ b/cgcs-patch/cgcs-patch/cgcs_patch/api/controllers/root.py @@ -30,7 +30,7 @@ class PatchAPIController(object): try: pd = pc.patch_query_cached(**kwargs) except PatchError as e: - return dict(error="Error: %s" % e.message) + return dict(error="Error: %s" % str(e)) return dict(pd=pd) @@ -40,7 +40,7 @@ class PatchAPIController(object): try: result = pc.patch_query_specific_cached(list(args)) except PatchError as e: - return dict(error="Error: %s" % e.message) + return dict(error="Error: %s" % str(e)) return result @@ -53,7 +53,7 @@ class PatchAPIController(object): try: result = pc.patch_apply_api(list(args), **kwargs) except PatchError as e: - return dict(error="Error: %s" % e.message) + return dict(error="Error: %s" % str(e)) pc.patch_sync() @@ -68,7 +68,7 @@ class PatchAPIController(object): try: result = pc.patch_remove_api(list(args), **kwargs) except PatchError as e: - return dict(error="Error: %s" % e.message) + return dict(error="Error: %s" % str(e)) pc.patch_sync() @@ -80,7 +80,7 @@ class PatchAPIController(object): try: result = pc.patch_delete_api(list(args)) except PatchError as e: - return dict(error="Error: %s" % e.message) + return dict(error="Error: %s" % str(e)) pc.patch_sync() @@ -123,7 +123,7 @@ class PatchAPIController(object): result = pc.patch_import_api([fn]) except PatchError as e: os.remove(fn) - return dict(error=e.message) + return dict(error=str(e)) os.remove(fn) @@ -146,7 +146,7 @@ class PatchAPIController(object): try: result = pc.patch_import_api(sorted(files)) except PatchError as e: - return dict(error=e.message) + return dict(error=str(e)) pc.patch_sync() @@ -160,7 +160,7 @@ class PatchAPIController(object): try: result = pc.patch_init_release_api(list(args)[0]) except PatchError as e: - return dict(error=e.message) + return dict(error=str(e)) pc.patch_sync() @@ -174,7 +174,7 @@ class PatchAPIController(object): try: result = pc.patch_del_release_api(list(args)[0]) except PatchError as e: - return dict(error=e.message) + return dict(error=str(e)) pc.patch_sync() @@ -191,7 +191,7 @@ class PatchAPIController(object): try: result = pc.patch_query_what_requires(list(args)) except PatchError as e: - return dict(error="Error: %s" % e.message) + return dict(error="Error: %s" % str(e)) return result @@ -212,7 +212,7 @@ class PatchAPIController(object): try: result = pc.patch_host_install(list(args)[0], force, async_req=True) except PatchError as e: - return dict(error="Error: %s" % e.message) + return dict(error="Error: %s" % str(e)) return result @@ -225,7 +225,7 @@ class PatchAPIController(object): try: result = pc.drop_host(list(args)[0]) except PatchError as e: - return dict(error="Error: %s" % e.message) + return dict(error="Error: %s" % str(e)) return result @@ -234,7 +234,7 @@ class PatchAPIController(object): try: result = pc.patch_query_dependencies(list(args), **kwargs) except PatchError as e: - return dict(error=e.message) + return dict(error=str(e)) return result @@ -243,7 +243,7 @@ class PatchAPIController(object): try: result = pc.patch_commit(list(args)) except PatchError as e: - return dict(error=e.message) + return dict(error=str(e)) pc.patch_sync() @@ -254,7 +254,7 @@ class PatchAPIController(object): try: result = pc.patch_commit(list(args), dry_run=True) except PatchError as e: - return dict(error=e.message) + return dict(error=str(e)) return result @@ -271,7 +271,7 @@ class PatchAPIController(object): try: result = pc.report_app_dependencies(list(args), **kwargs) except PatchError as e: - return dict(status=500, error=e.message) + return dict(status=500, error=str(e)) pc.patch_sync() diff --git a/cgcs-patch/cgcs-patch/cgcs_patch/patch_client.py b/cgcs-patch/cgcs-patch/cgcs_patch/patch_client.py index 0b6ec3de..441a8e7b 100644 --- a/cgcs-patch/cgcs-patch/cgcs_patch/patch_client.py +++ b/cgcs-patch/cgcs-patch/cgcs_patch/patch_client.py @@ -1351,7 +1351,7 @@ def get_auth_token_and_endpoint(region_name): interface='internal', region_name=region_name) except (exceptions.http.Unauthorized, exceptions.EndpointNotFound) as e: - print(e.message) + print(str(e)) exit(-1) return token, endpoint diff --git a/cgcs-patch/cgcs-patch/cgcs_patch/patch_controller.py b/cgcs-patch/cgcs-patch/cgcs_patch/patch_controller.py index f2b24c82..ad233596 100644 --- a/cgcs-patch/cgcs-patch/cgcs_patch/patch_controller.py +++ b/cgcs-patch/cgcs-patch/cgcs_patch/patch_controller.py @@ -984,8 +984,8 @@ class PatchController(PatchService): continue except PatchValidationFailure as e: msg = "Patch validation failed for %s" % patch_id - if e.message is not None and e.message != '': - msg += ":\n%s" % e.message + if str(e) is not None and str(e) != '': + msg += ":\n%s" % str(e) LOG.exception(msg) msg_error += msg + "\n" continue @@ -1019,8 +1019,8 @@ class PatchController(PatchService): self.patch_data.metadata[patch_id]["patchstate"] = constants.UNKNOWN except PatchValidationFailure as e: msg = "Patch validation failed for %s" % patch_id - if e.message is not None and e.message != '': - msg += ":\n%s" % e.message + if str(e) is not None and str(e) != '': + msg += ":\n%s" % str(e) LOG.exception(msg) msg_error += msg + "\n" continue diff --git a/cgcs-patch/cgcs-patch/cgcs_patch/patch_functions.py b/cgcs-patch/cgcs-patch/cgcs_patch/patch_functions.py index d76eba59..0acb10f4 100644 --- a/cgcs-patch/cgcs-patch/cgcs_patch/patch_functions.py +++ b/cgcs-patch/cgcs-patch/cgcs_patch/patch_functions.py @@ -268,7 +268,7 @@ class BasePackageData(object): continue self.pkgs[sw_rel] = {} - for root, dirs, files in os.walk("%s/Packages" % reldir): # pylint: disable=unused-variable + for _root, _dirs, files in os.walk("%s/Packages" % reldir): # pylint: disable=unused-variable for name in files: if name.endswith(".rpm"): try: @@ -589,7 +589,7 @@ class PatchData(object): return self.package_versions[sw_ver][pkgname][arch][pkgver] def load_all_metadata(self, - loaddir=os.getcwd(), + loaddir, repostate=None): """ Parse all metadata files in the specified dir @@ -831,8 +831,7 @@ class PatchFile(object): self.semantics[action] = os.path.abspath(fname) - def gen_patch(self, - outdir=os.getcwd()): + def gen_patch(self, outdir): """ Generate the patch file, named PATCHID.patch :param outdir: Output directory for the patch @@ -1382,4 +1381,4 @@ def patch_build(): for rpmfile in remainder: pf.add_rpm(rpmfile) - pf.gen_patch() + pf.gen_patch(outdir=os.getcwd()) diff --git a/cgcs-patch/cgcs-patch/tox.ini b/cgcs-patch/cgcs-patch/tox.ini index dedb45e5..3402ebfe 100644 --- a/cgcs-patch/cgcs-patch/tox.ini +++ b/cgcs-patch/cgcs-patch/tox.ini @@ -104,6 +104,8 @@ max-line-length = 120 [testenv:flake8] basepython = python3 +deps = {[testenv]deps} + flake8-bugbear usedevelop = False #skip_install = True commands = diff --git a/patch-alarm/patch-alarm/tox.ini b/patch-alarm/patch-alarm/tox.ini index 653c1183..47499298 100644 --- a/patch-alarm/patch-alarm/tox.ini +++ b/patch-alarm/patch-alarm/tox.ini @@ -82,6 +82,8 @@ max-line-length = 120 [testenv:flake8] basepython = python3 +deps = {[testenv]deps} + flake8-bugbear usedevelop = False #skip_install = True commands =