From c45b184d4c43b736fb8ffcb2f0f89eb7dcef005f Mon Sep 17 00:00:00 2001 From: Bartek Grzybowski Date: Wed, 29 Jul 2020 15:36:15 +0200 Subject: Fix linting issues in Python scripts Change-Id: I198340670f808d42aa6fb16de573db4a65005985 Issue-ID: INT-1667 Signed-off-by: Bartek Grzybowski --- ansible/library/rancher_k8s_environment.py | 1 - build/download/__init__.py | 1 - build/download/clean_docker_images.py | 1 - build/download/pypi_downloader.py | 2 +- build/download/rpm_downloader.py | 2 +- tools/helm_deployment_status.py | 30 +++++++++++++++--------------- tools/remove_runtime_images.py | 1 - 7 files changed, 17 insertions(+), 21 deletions(-) diff --git a/ansible/library/rancher_k8s_environment.py b/ansible/library/rancher_k8s_environment.py index d3d8ac02..00bb7d49 100644 --- a/ansible/library/rancher_k8s_environment.py +++ b/ansible/library/rancher_k8s_environment.py @@ -338,4 +338,3 @@ def run_module(): if __name__ == '__main__': run_module() - diff --git a/build/download/__init__.py b/build/download/__init__.py index b1ef8d99..4f259ea7 100644 --- a/build/download/__init__.py +++ b/build/download/__init__.py @@ -17,4 +17,3 @@ # limitations under the License. # COPYRIGHT NOTICE ENDS HERE - diff --git a/build/download/clean_docker_images.py b/build/download/clean_docker_images.py index 186bfd60..42157490 100755 --- a/build/download/clean_docker_images.py +++ b/build/download/clean_docker_images.py @@ -68,4 +68,3 @@ def main(): if __name__ == '__main__': main() - diff --git a/build/download/pypi_downloader.py b/build/download/pypi_downloader.py index 10ac7b9f..aa2a46e0 100755 --- a/build/download/pypi_downloader.py +++ b/build/download/pypi_downloader.py @@ -47,7 +47,7 @@ class PyPiDownloader(CommandDownloader): log.warning('Check mode for pypi is not implemented.') return '' - def _is_missing(self, item): + def _is_missing(self, item): # pylint: disable=W0613 """ Check if item is missing :param item: item to check diff --git a/build/download/rpm_downloader.py b/build/download/rpm_downloader.py index 415f9483..2b94e167 100755 --- a/build/download/rpm_downloader.py +++ b/build/download/rpm_downloader.py @@ -66,7 +66,7 @@ class RpmDownloader(CommandDownloader): self._missing[dst].add(item) return self._missing - def _is_missing(self, item): + def _is_missing(self, item): # pylint: disable=W0613 """ Check if item is missing :param item: item to check diff --git a/tools/helm_deployment_status.py b/tools/helm_deployment_status.py index 8917e992..f92773db 100755 --- a/tools/helm_deployment_status.py +++ b/tools/helm_deployment_status.py @@ -111,20 +111,20 @@ def exec_healthcheck(hp_script, namespace, hp_mode): return hc.returncode def check_readiness(k8s, verbosity): - k8s_controllers, not_ready_controllers = get_k8s_controllers(k8s) - - # check pods only when it is explicitly wanted (judging readiness by deployment status) - if verbosity > 1: - pods = k8s.get_resources('api/v1', 'pods') - unready_pods = chain.from_iterable( - get_names(not_ready_pods( - pods_by_parent(pods, x))) - for x in not_ready_controllers) - else: - unready_pods = [] + k8s_controllers, not_ready_controllers = get_k8s_controllers(k8s) + + # check pods only when it is explicitly wanted (judging readiness by deployment status) + if verbosity > 1: + pods = k8s.get_resources('api/v1', 'pods') + unready_pods = chain.from_iterable( + get_names(not_ready_pods( + pods_by_parent(pods, x))) + for x in not_ready_controllers) + else: + unready_pods = [] - print_status(verbosity, k8s_controllers, unready_pods) - return not not_ready_controllers + print_status(verbosity, k8s_controllers, unready_pods) + return not not_ready_controllers def check_in_loop(k8s, max_time, sleep_time, verbosity): max_end_time = datetime.datetime.now() + datetime.timedelta(minutes=max_time) @@ -224,7 +224,7 @@ class Kubernetes: req = requests.get(url, verify=False) else: req = requests.get(url, verify=self.crt_tmp_file.name, cert=self.crt_tmp_file.name) - except requests.exceptions.ConnectionError as err: + except requests.exceptions.ConnectionError: sys.exit('Error: Could not connect to {}'.format(self.url)) if req.status_code == 200: json = req.json() @@ -264,7 +264,7 @@ class Kubernetes: config['users'][0]['user']['client-certificate-data']))) certs.update(dict(client_key=b64decode( config['users'][0]['user']['client-key-data']))) - except KeyError as err: + except KeyError: print('Warning: could not get Kubernetes config for certificates. ' \ 'Turning off SSL authentication.') self.no_ssl_auth = True diff --git a/tools/remove_runtime_images.py b/tools/remove_runtime_images.py index 67d732bb..40f38eb1 100755 --- a/tools/remove_runtime_images.py +++ b/tools/remove_runtime_images.py @@ -76,4 +76,3 @@ def run_cli(): if __name__ == '__main__': run_cli() - -- cgit 1.2.3-korg