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 7f99f4a9..0ab82e79 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 @@ -471,7 +471,6 @@ class PatchList(object): sys.exit(2) if fix and (rc2 > MINOR_DIFF): new_status = self.get_status() - old_status = prd.get_status() # TODO should we update status prd.set_status(new_status) rc2 = prd.compare(self.patch_data[prd.patch_id]) @@ -897,7 +896,7 @@ class RecipeData(object): extra_arg = "--prebuilt" if os.path.isfile(path): - rc = issue_cmd_rc("%s %s %s >> %s/%s.log" % (path, self.name, extra_arg, os.environ['DEST'], os.environ['PREFIX'])) + issue_cmd_rc("%s %s %s >> %s/%s.log" % (path, self.name, extra_arg, os.environ['DEST'], os.environ['PREFIX'])) def build_patch(self, pf, fatal=True): for package in self.packages: @@ -1265,13 +1264,11 @@ class PatchRecipeData(object): def _read_rpm_db(self, patch_id): release_map = {} - rpm_db_dir = "export/patch_data" rpm_db = self._get_rpm_db_path(patch_id) with open(rpm_db) as f: for line in f: words = line.split() if len(words) == 3: - arch = words[0] rpm = words[1] release = words[2] release_map[rpm] = release[1:] @@ -1933,45 +1930,31 @@ def make_patch(): print("invalid patch file path: '%s'" % patch) make_patch_usage() - if 'MY_REPO' in os.environ: - MY_REPO = os.path.normpath(os.path.join(cwd, os.path.expanduser(os.environ['MY_REPO']))) - else: + if 'MY_REPO' not in os.environ: print("ERROR: environment variable 'MY_REPO' is not defined") sys.exit(1) - if 'MY_WORKSPACE' in os.environ: - MY_WORKSPACE = os.path.normpath(os.path.join(cwd, os.path.expanduser(os.environ['MY_WORKSPACE']))) - else: + if 'MY_WORKSPACE' not in os.environ: print("ERROR: environment variable 'MY_REPO' is not defined") sys.exit(1) - if 'PROJECT' in os.environ: - PROJECT = os.path.normpath(os.path.join(cwd, os.path.expanduser(os.environ['PROJECT']))) - else: + if 'PROJECT' not in os.environ: print("ERROR: environment variable 'PROJECT' is not defined") sys.exit(1) - if 'SRC_BUILD_ENVIRONMENT' in os.environ: - SRC_BUILD_ENVIRONMENT = os.path.normpath(os.path.join(cwd, os.path.expanduser(os.environ['SRC_BUILD_ENVIRONMENT']))) - else: + if 'SRC_BUILD_ENVIRONMENT' not in os.environ: print("ERROR: environment variable 'SRC_BUILD_ENVIRONMENT' is not defined") sys.exit(1) - if 'MY_SRC_RPM_BUILD_DIR' in os.environ: - MY_SRC_RPM_BUILD_DIR = os.path.normpath(os.path.join(cwd, os.path.expanduser(os.environ['MY_SRC_RPM_BUILD_DIR']))) - else: + if 'MY_SRC_RPM_BUILD_DIR' not in os.environ: print("ERROR: environment variable 'MY_SRC_RPM_BUILD_DIR' is not defined") sys.exit(1) - if 'MY_BUILD_CFG' in os.environ: - MY_BUILD_CFG = os.path.normpath(os.path.join(cwd, os.path.expanduser(os.environ['MY_BUILD_CFG']))) - else: + if 'MY_BUILD_CFG' not in os.environ: print("ERROR: environment variable 'MY_BUILD_CFG' is not defined") sys.exit(1) - if 'MY_BUILD_DIR' in os.environ: - MY_BUILD_DIR = os.path.normpath(os.path.join(cwd, os.path.expanduser(os.environ['MY_BUILD_DIR']))) - else: + if 'MY_BUILD_DIR' not in os.environ: print("ERROR: environment variable 'MY_BUILD_DIR' is not defined") sys.exit(1) 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 f76c5394..fc7ea909 100644 --- a/cgcs-patch/cgcs-patch/cgcs_patch/api/controllers/root.py +++ b/cgcs-patch/cgcs-patch/cgcs_patch/api/controllers/root.py @@ -134,7 +134,7 @@ class PatchAPIController(object): @expose('json') def upload_dir(self, **kwargs): files = [] - for key, path in kwargs.items(): + for path in kwargs.values(): LOG.info("upload-dir: Retrieving patches from %s" % path) for f in glob.glob(path + '/*.patch'): if os.path.isfile(f): diff --git a/cgcs-patch/cgcs-patch/cgcs_patch/patch_agent.py b/cgcs-patch/cgcs-patch/cgcs_patch/patch_agent.py index 86276fb8..cafc6d54 100644 --- a/cgcs-patch/cgcs-patch/cgcs_patch/patch_agent.py +++ b/cgcs-patch/cgcs-patch/cgcs_patch/patch_agent.py @@ -993,7 +993,7 @@ class PatchAgent(PatchService): break try: - datachk = json.loads(data) + json.loads(data) break except ValueError: # Message is incomplete diff --git a/cgcs-patch/cgcs-patch/cgcs_patch/patch_client.py b/cgcs-patch/cgcs-patch/cgcs_patch/patch_client.py index 32fd1223..3e821522 100644 --- a/cgcs-patch/cgcs-patch/cgcs_patch/patch_client.py +++ b/cgcs-patch/cgcs-patch/cgcs_patch/patch_client.py @@ -994,8 +994,6 @@ def host_install_async(debug, args): def drop_host(debug, args): - force = False - if len(args) != 1: print_help() diff --git a/cgcs-patch/cgcs-patch/cgcs_patch/patch_controller.py b/cgcs-patch/cgcs-patch/cgcs_patch/patch_controller.py index efb9d6eb..04479eaa 100644 --- a/cgcs-patch/cgcs-patch/cgcs_patch/patch_controller.py +++ b/cgcs-patch/cgcs-patch/cgcs_patch/patch_controller.py @@ -743,13 +743,10 @@ class PatchController(PatchService): self.patch_data.metadata[patch_id]["patchstate"] = \ self.patch_data.metadata[patch_id]["repostate"] - any_out_of_date = False for ip in self.hosts.keys(): if not self.hosts[ip].out_of_date: continue - any_out_of_date = True - for pkg in self.hosts[ip].installed.keys(): for patch_id in self.patch_data.content_versions.keys(): if pkg not in self.patch_data.content_versions[patch_id]: @@ -920,8 +917,6 @@ class PatchController(PatchService): LOG.info(msg) audit_log_info(msg) - repo_changed = False - for patch in patch_list: msg = "Importing patch: %s" % patch LOG.info(msg) @@ -978,8 +973,6 @@ class PatchController(PatchService): msg_error += msg + "\n" continue - repo_changed = True - try: thispatch = PatchFile.extract_patch(patch, metadata_dir=avail_dir, @@ -1804,8 +1797,6 @@ class PatchController(PatchService): LOG.exception(msg) raise PatchFail(msg) - release = None - patch_added = False failure = False recursive = True @@ -2007,7 +1998,7 @@ class PatchController(PatchService): rc = False self.hosts_lock.acquire() - for ip, host in self.hosts.items(): + for host in self.hosts.values(): if host.state == constants.PATCH_AGENT_STATE_INSTALLING: rc = True break @@ -2467,7 +2458,7 @@ class PatchControllerMainThread(threading.Thread): if data == '': break try: - datachk = json.loads(data) + json.loads(data) break except ValueError: # Message is incomplete diff --git a/cgcs-patch/cgcs-patch/cgcs_patch/patch_functions.py b/cgcs-patch/cgcs-patch/cgcs_patch/patch_functions.py index 22c75055..eb4ba770 100644 --- a/cgcs-patch/cgcs-patch/cgcs_patch/patch_functions.py +++ b/cgcs-patch/cgcs-patch/cgcs_patch/patch_functions.py @@ -154,7 +154,7 @@ def write_xml_file(top, def parse_rpm_filename(filename): # Drop the extension - (basename, ext) = os.path.splitext(os.path.basename(filename)) + basename = os.path.splitext(os.path.basename(filename))[0] # RPM name format is: # [:]--. @@ -244,7 +244,7 @@ class BasePackageData(object): continue self.pkgs[sw_rel] = {} - for root, dirs, files in os.walk("%s/Packages" % reldir): + for root, dirs, files in os.walk("%s/Packages" % reldir): # pylint: disable=unused-variable for name in files: if name.endswith(".rpm"): try: @@ -612,7 +612,7 @@ class PatchData(object): write_xml_file(top, fname) def gen_groups_xml(self): - for ver, rdir in repo_dir.items(): + for ver in repo_dir: self.gen_release_groups_xml(ver) def query_line(self, diff --git a/cgcs-patch/cgcs-patch/cgcs_patch/patch_verify.py b/cgcs-patch/cgcs-patch/cgcs_patch/patch_verify.py index 94d9eabf..72f6c0af 100644 --- a/cgcs-patch/cgcs-patch/cgcs_patch/patch_verify.py +++ b/cgcs-patch/cgcs-patch/cgcs_patch/patch_verify.py @@ -33,12 +33,12 @@ cert_type_all = [cert_type_dev_str, cert_type_formal_str] def verify_hash(data_hash, signature_bytes, certificate_list): """ - Checkes that a hash's signature can be validates against an approved + Checks that a hash's signature can be validated against an approved certificate :param data_hash: A hash of the data to be validated :param signature_bytes: A pre-generated signature (typically, the hash encrypted with a private key) - :param certifcate_list: A list of approved certificates or public keys + :param certificate_list: A list of approved certificates or public keys which the signature is validated against :return: True if the signature was validated against a certificate """ @@ -47,7 +47,7 @@ def verify_hash(data_hash, signature_bytes, certificate_list): if verified: break pub_key = read_RSA_key(cert) - x = pub_key.exportKey() + pub_key.exportKey() # PSS is the recommended signature scheme, but some tools (like OpenSSL) # use the older v1_5 scheme. We try to validate against both. @@ -58,14 +58,14 @@ def verify_hash(data_hash, signature_bytes, certificate_list): verifier = PKCS1_PSS.new(pub_key) try: verified = verifier.verify(data_hash, signature_bytes) # pylint: disable=not-callable - except ValueError as e: + except ValueError: verified = False if not verified: verifier = PKCS1_v1_5.new(pub_key) try: verified = verifier.verify(data_hash, signature_bytes) - except ValueError as e: + except ValueError: verified = False return verified diff --git a/cgcs-patch/cgcs-patch/cgcs_patch/tests/test_patch_agent.py b/cgcs-patch/cgcs-patch/cgcs_patch/tests/test_patch_agent.py index 901c73f6..c953e4f5 100644 --- a/cgcs-patch/cgcs-patch/cgcs_patch/tests/test_patch_agent.py +++ b/cgcs-patch/cgcs-patch/cgcs_patch/tests/test_patch_agent.py @@ -19,4 +19,5 @@ import cgcs_patch.patch_agent # noqa: E402 class CgcsPatchAgentTestCase(testtools.TestCase): def test_cgcs_patch_agent_instantiate(self): - pc = cgcs_patch.patch_agent.PatchAgent() + # pylint: disable=unused-variable + pc = cgcs_patch.patch_agent.PatchAgent() # noqa: F841 diff --git a/cgcs-patch/cgcs-patch/cgcs_patch/tests/test_patch_controller.py b/cgcs-patch/cgcs-patch/cgcs_patch/tests/test_patch_controller.py index db001202..d11623fe 100644 --- a/cgcs-patch/cgcs-patch/cgcs_patch/tests/test_patch_controller.py +++ b/cgcs-patch/cgcs-patch/cgcs_patch/tests/test_patch_controller.py @@ -20,4 +20,5 @@ class CgcsPatchControllerTestCase(testtools.TestCase): @mock.patch('six.moves.builtins.open') def test_cgcs_patch_controller_instantiate(self, mock_open): - pc = cgcs_patch.patch_controller.PatchController() + # pylint: disable=unused-variable + pc = cgcs_patch.patch_controller.PatchController() # noqa: F841 diff --git a/cgcs-patch/cgcs-patch/pylint.rc b/cgcs-patch/cgcs-patch/pylint.rc index 36c3243b..dc20bb07 100644 --- a/cgcs-patch/cgcs-patch/pylint.rc +++ b/cgcs-patch/cgcs-patch/pylint.rc @@ -45,7 +45,7 @@ symbols=no # no Warning level messages displayed, use"--disable=all --enable=classes # --disable=W" #disable= -disable=C, R, W0603, W0612, W0613, W0702, W0703, W1201 +disable=C, R, W0603, W0613, W0702, W0703, W1201 [REPORTS] diff --git a/cgcs-patch/cgcs-patch/tox.ini b/cgcs-patch/cgcs-patch/tox.ini index 03b6727b..f8ccb55c 100644 --- a/cgcs-patch/cgcs-patch/tox.ini +++ b/cgcs-patch/cgcs-patch/tox.ini @@ -67,7 +67,7 @@ commands = {[testenv:stestr]commands} # F841 local variable 'XXXXXX' is assigned to but never used show-source = True #ignore = H101,H102,H105,H306,H401,H404,H405,E501,F401,F841 -ignore = H101,H102,H105,H306,H401,H404,H405,E501,F401,F841 +ignore = H101,H102,H105,H306,H401,H404,H405,E501,F401 exclude = .venv,.git,.tox,dist,doc,*lib/python*,*egg,build,release-tag-* # H106: Don't put vim configuration in source files (off by default). # H203: Use assertIs(Not)None to check for None (off by default). diff --git a/pylint.rc b/pylint.rc index c9319b64..9c1847f5 100755 --- a/pylint.rc +++ b/pylint.rc @@ -27,12 +27,11 @@ load-plugins= # multiple time (only on the command line, not in the configuration file where # it should appear only once). # W0603 Using the global statement warning -# W0612 Unused variable warning # W0613 Unused argument warning # W0702 bare-except # W0703 broad except warning # W1201 logging-not-lazy -disable=C, R, W0603, W0612, W0613, W0702, W0703, W1201 +disable=C, R, W0603, W0613, W0702, W0703, W1201 [REPORTS] diff --git a/tsconfig/tsconfig/tsconfig/tests/test_basics.py b/tsconfig/tsconfig/tsconfig/tests/test_basics.py index 68f507e3..215dd849 100644 --- a/tsconfig/tsconfig/tsconfig/tests/test_basics.py +++ b/tsconfig/tsconfig/tsconfig/tests/test_basics.py @@ -114,7 +114,7 @@ vswitch_type=ovs-dpdk # 1st: /etc/build.info # 2nd: /etc/platform/platform.conf mock_open.return_value = io.StringIO(self.mock_malformed_build) - from tsconfig import tsconfig + from tsconfig import tsconfig # pylint: disable=unused-variable mock_logging_exception.assert_called_once() # This tests the behaviour when the platform.conf is missing @@ -129,7 +129,7 @@ vswitch_type=ovs-dpdk # 1st: /etc/build.info # 2nd: /etc/platform/platform.conf mock_open.return_value = io.StringIO(self.mock_19_01_build) - from tsconfig import tsconfig + from tsconfig import tsconfig # pylint: disable=unused-variable mock_logging_exception.assert_called_once() # This tests the behaviour when the platform.conf is empty @@ -145,7 +145,7 @@ vswitch_type=ovs-dpdk # 2nd: /etc/platform/platform.conf mock_open.side_effect = [io.StringIO(self.mock_19_01_build), io.StringIO(self.mock_platform_conf_empty)] - from tsconfig import tsconfig + from tsconfig import tsconfig # pylint: disable=unused-variable mock_logging_exception.assert_called_once() # This tests the behaviour when the platform.conf has the minimal entries