From bba391a48c635d19aeb8e60fe9ebb6bb6725fa42 Mon Sep 17 00:00:00 2001 From: Benedict Jin Date: Sat, 7 Sep 2019 05:41:15 +0800 Subject: [PATCH] Fix alerts from LGTM about python files (#8383) --- distribution/bin/check-licenses.py | 1 - distribution/bin/find-missing-backports.py | 6 ++---- distribution/bin/generate-license-dependency-reports.py | 9 +++------ distribution/bin/jar-notice-lister.py | 6 +++--- 4 files changed, 8 insertions(+), 14 deletions(-) diff --git a/distribution/bin/check-licenses.py b/distribution/bin/check-licenses.py index ea480581e80..45538782e1d 100755 --- a/distribution/bin/check-licenses.py +++ b/distribution/bin/check-licenses.py @@ -16,7 +16,6 @@ # limitations under the License. import yaml -import json import os import sys from html.parser import HTMLParser diff --git a/distribution/bin/find-missing-backports.py b/distribution/bin/find-missing-backports.py index 6802eef8aa9..60f374d4949 100755 --- a/distribution/bin/find-missing-backports.py +++ b/distribution/bin/find-missing-backports.py @@ -20,7 +20,6 @@ import re import requests import subprocess import sys -import time def extract_pr_title_from_commit_message(commit_msg): @@ -48,7 +47,7 @@ def extract_pr_title(pr_json): def find_missing_backports(pr_jsons, release_pr_subjects): for pr in pr_jsons: if pr['milestone'] is not None: - if pr['milestone']['number'] is milestone_number: + if pr['milestone']['number'] == milestone_number: for pr_title_candidate in extract_pr_title(pr): if pr_title_candidate in release_pr_subjects: return @@ -65,8 +64,7 @@ def find_next_url(links): else: url_holder = match_result.group(0) return url_holder[1:-1] - else: - return None + return None if len(sys.argv) != 5: diff --git a/distribution/bin/generate-license-dependency-reports.py b/distribution/bin/generate-license-dependency-reports.py index c691578c50f..461dc2ae482 100755 --- a/distribution/bin/generate-license-dependency-reports.py +++ b/distribution/bin/generate-license-dependency-reports.py @@ -18,11 +18,8 @@ import os import shutil import subprocess -import sys import argparse import concurrent.futures -import time -import threading def generate_report(module_path, report_orig_path, report_out_path): @@ -48,7 +45,7 @@ def generate_report(module_path, report_orig_path, report_out_path): def generate_reports(druid_path, tmp_path, exclude_ext, num_threads): tmp_path = os.path.abspath(tmp_path) license_report_root = os.path.join(tmp_path, "license-reports") - license_core_path = os.path.join(license_report_root, "core") + license_core_path = os.path.join(license_report_root, "core") license_ext_path = os.path.join(license_report_root, "ext") shutil.rmtree(license_report_root, ignore_errors=True) os.makedirs(license_core_path) @@ -70,7 +67,7 @@ def generate_reports(druid_path, tmp_path, exclude_ext, num_threads): extension_report_dir = "{}/{}".format(license_ext_path, extension_dir) script_args.append((extension_path, os.path.join(extension_path, "target", "site"), extension_report_dir)) - + print("Generating dependency reports") if num_threads > 1: @@ -96,7 +93,7 @@ if __name__ == "__main__": if args.clean_mvn_artifact_transfer: command = "rm -rf ~/.m2/repository/org/apache/maven/shared/maven-artifact-transfer" subprocess.check_call(command, shell=True) - + generate_reports(args.druid_path, args.tmp_path, args.exclude_ext, args.num_threads) except KeyboardInterrupt: print('Interrupted, closing.') diff --git a/distribution/bin/jar-notice-lister.py b/distribution/bin/jar-notice-lister.py index f45f1ee00cb..7a8d38c265b 100755 --- a/distribution/bin/jar-notice-lister.py +++ b/distribution/bin/jar-notice-lister.py @@ -34,14 +34,14 @@ def main(): tmp_lib_path = tmp_path + "/1-lib" os.mkdir(tmp_lib_path) command = "cp -r {}/* {}".format(lib_path, tmp_lib_path) - outstr = subprocess.check_output(command, shell=True).decode('UTF-8') + subprocess.check_output(command, shell=True).decode('UTF-8') # copy hadoop deps to the staging dir hdeps_path = druid_path + "/hadoop-dependencies" tmp_hdeps_path = tmp_path + "/2-hdeps" os.mkdir(tmp_hdeps_path) command = "cp -r {}/* {}".format(hdeps_path, tmp_hdeps_path) - outstr = subprocess.check_output(command, shell=True).decode('UTF-8') + subprocess.check_output(command, shell=True).decode('UTF-8') # copy all extension folders to the staging dir @@ -49,7 +49,7 @@ def main(): tmp_ext_path = tmp_path + "/3-ext" os.mkdir(tmp_ext_path) command = "cp -r {}/* {}".format(ext_path, tmp_ext_path) - outstr = subprocess.check_output(command, shell=True).decode('UTF-8') + subprocess.check_output(command, shell=True).decode('UTF-8') get_notices(tmp_path)