From 7c0ea388308bddd8f385e7f21b4e51192a940206 Mon Sep 17 00:00:00 2001 From: Atul Bagga Date: Fri, 17 Jan 2020 14:41:09 +0530 Subject: [PATCH] pylint flake8 fixes --- .../dev/aks/docker_helm_template.py | 2 +- deploy-aks/azext_aks_deploy/dev/aks/up.py | 1 - .../dev/common/azure_cli_resources.py | 2 +- .../dev/common/github_api_helper.py | 20 +++++++++---------- .../dev/common/github_azure_secrets.py | 1 - 5 files changed, 11 insertions(+), 15 deletions(-) diff --git a/deploy-aks/azext_aks_deploy/dev/aks/docker_helm_template.py b/deploy-aks/azext_aks_deploy/dev/aks/docker_helm_template.py index c8eb356..9edfa8d 100644 --- a/deploy-aks/azext_aks_deploy/dev/aks/docker_helm_template.py +++ b/deploy-aks/azext_aks_deploy/dev/aks/docker_helm_template.py @@ -49,7 +49,7 @@ def get_helm_charts(language, acr_details, port): # r=root, d=directories, f = files logger.debug("Checking in helm charts") for r, _d, f in os.walk(abs_pack_path): - if not 'charts' in r: + if 'charts' not in r: continue for file in f: if '__pycache__' not in r and '__init__.py' not in file: diff --git a/deploy-aks/azext_aks_deploy/dev/aks/up.py b/deploy-aks/azext_aks_deploy/dev/aks/up.py index 47e823f..2e6be5a 100644 --- a/deploy-aks/azext_aks_deploy/dev/aks/up.py +++ b/deploy-aks/azext_aks_deploy/dev/aks/up.py @@ -123,7 +123,6 @@ def aks_deploy(aks_cluster=None, acr=None, repository=None, port=None, branch_na print('Your app is deployed at: http://{ip}:{port}'.format(ip=deployment_ip, port=port)) return - def get_yaml_template_for_repo(cluster_details, acr_details): files_to_return = [] github_workflow_path = '.github/workflows/' diff --git a/deploy-aks/azext_aks_deploy/dev/common/azure_cli_resources.py b/deploy-aks/azext_aks_deploy/dev/common/azure_cli_resources.py index 8f2060d..976326c 100644 --- a/deploy-aks/azext_aks_deploy/dev/common/azure_cli_resources.py +++ b/deploy-aks/azext_aks_deploy/dev/common/azure_cli_resources.py @@ -145,7 +145,7 @@ def configure_aks_credentials(cluster_name, resource_group): subscription_id, subscription_name, tenant_id, environment_name = get_default_subscription_info() logger.warning("Using your default Azure subscription %s for getting AKS cluster credentials.", subscription_name) - aks_creds = subprocess.check_output( + _aks_creds = subprocess.check_output( 'az aks get-credentials -n {cluster_name} -g {group_name} -o json'.format( cluster_name=cluster_name, group_name=resource_group), shell=True) except Exception as ex: diff --git a/deploy-aks/azext_aks_deploy/dev/common/github_api_helper.py b/deploy-aks/azext_aks_deploy/dev/common/github_api_helper.py index 75f1aee..0e876ff 100644 --- a/deploy-aks/azext_aks_deploy/dev/common/github_api_helper.py +++ b/deploy-aks/azext_aks_deploy/dev/common/github_api_helper.py @@ -2,8 +2,8 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. # -------------------------------------------------------------------------------------------- -import requests import time +import requests from knack.log import get_logger from knack.util import CLIError from azext_aks_deploy.dev.common.prompting import prompt_not_empty @@ -147,13 +147,12 @@ def get_default_branch(repo): CLIError(ex) def commit_files_to_github_branch(files, repo_name, branch, message): - if files: - for file in files: - commit_sha = commit_file_to_github_branch(file.path, file.content, repo_name, branch, message) - # returning last commit sha - return commit_sha - else: + if not files: raise CLIError("No files to checkin.") + for file in files: + commit_sha = commit_file_to_github_branch(file.path, file.content, repo_name, branch, message) + # returning last commit sha + return commit_sha def check_file_exists(repo_name, file_path): """ @@ -201,10 +200,9 @@ def commit_file_to_github_branch(path_to_commit, content, repo_name, branch, mes if not response.status_code == _HTTP_CREATED_STATUS: raise CLIError('GitHub file checkin failed for file ({file}). Status Code ({code}).'.format( file=path_to_commit, code=response.status_code)) - else: - commit_obj = response.json()['commit'] - commit_sha = commit_obj['sha'] - return commit_sha + commit_obj = response.json()['commit'] + commit_sha = commit_obj['sha'] + return commit_sha else: raise CLIError('GitHub file checkin failed. File path or content is empty.') diff --git a/deploy-aks/azext_aks_deploy/dev/common/github_azure_secrets.py b/deploy-aks/azext_aks_deploy/dev/common/github_azure_secrets.py index 961aadf..7f862f3 100644 --- a/deploy-aks/azext_aks_deploy/dev/common/github_azure_secrets.py +++ b/deploy-aks/azext_aks_deploy/dev/common/github_azure_secrets.py @@ -45,4 +45,3 @@ def get_azure_credentials(): azure_creds_user_choice = prompt_user_friendly_choice_list( 'Have you copied the name and value for AZURE_CREDENTIALS, REGISTRY_USERNAME and REGISTRY_PASSWORD:', user_choice_list) - return