Fix alerts from LGTM about python files (#8383)

This commit is contained in:
Benedict Jin 2019-09-07 05:41:15 +08:00 committed by Himanshu
parent 1fe4ecf17a
commit bba391a48c
4 changed files with 8 additions and 14 deletions

View File

@ -16,7 +16,6 @@
# limitations under the License. # limitations under the License.
import yaml import yaml
import json
import os import os
import sys import sys
from html.parser import HTMLParser from html.parser import HTMLParser

View File

@ -20,7 +20,6 @@ import re
import requests import requests
import subprocess import subprocess
import sys import sys
import time
def extract_pr_title_from_commit_message(commit_msg): 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): def find_missing_backports(pr_jsons, release_pr_subjects):
for pr in pr_jsons: for pr in pr_jsons:
if pr['milestone'] is not None: 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): for pr_title_candidate in extract_pr_title(pr):
if pr_title_candidate in release_pr_subjects: if pr_title_candidate in release_pr_subjects:
return return
@ -65,8 +64,7 @@ def find_next_url(links):
else: else:
url_holder = match_result.group(0) url_holder = match_result.group(0)
return url_holder[1:-1] return url_holder[1:-1]
else: return None
return None
if len(sys.argv) != 5: if len(sys.argv) != 5:

View File

@ -18,11 +18,8 @@
import os import os
import shutil import shutil
import subprocess import subprocess
import sys
import argparse import argparse
import concurrent.futures import concurrent.futures
import time
import threading
def generate_report(module_path, report_orig_path, report_out_path): 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): def generate_reports(druid_path, tmp_path, exclude_ext, num_threads):
tmp_path = os.path.abspath(tmp_path) tmp_path = os.path.abspath(tmp_path)
license_report_root = os.path.join(tmp_path, "license-reports") 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") license_ext_path = os.path.join(license_report_root, "ext")
shutil.rmtree(license_report_root, ignore_errors=True) shutil.rmtree(license_report_root, ignore_errors=True)
os.makedirs(license_core_path) 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) extension_report_dir = "{}/{}".format(license_ext_path, extension_dir)
script_args.append((extension_path, os.path.join(extension_path, "target", "site"), extension_report_dir)) script_args.append((extension_path, os.path.join(extension_path, "target", "site"), extension_report_dir))
print("Generating dependency reports") print("Generating dependency reports")
if num_threads > 1: if num_threads > 1:
@ -96,7 +93,7 @@ if __name__ == "__main__":
if args.clean_mvn_artifact_transfer: if args.clean_mvn_artifact_transfer:
command = "rm -rf ~/.m2/repository/org/apache/maven/shared/maven-artifact-transfer" command = "rm -rf ~/.m2/repository/org/apache/maven/shared/maven-artifact-transfer"
subprocess.check_call(command, shell=True) subprocess.check_call(command, shell=True)
generate_reports(args.druid_path, args.tmp_path, args.exclude_ext, args.num_threads) generate_reports(args.druid_path, args.tmp_path, args.exclude_ext, args.num_threads)
except KeyboardInterrupt: except KeyboardInterrupt:
print('Interrupted, closing.') print('Interrupted, closing.')

View File

@ -34,14 +34,14 @@ def main():
tmp_lib_path = tmp_path + "/1-lib" tmp_lib_path = tmp_path + "/1-lib"
os.mkdir(tmp_lib_path) os.mkdir(tmp_lib_path)
command = "cp -r {}/* {}".format(lib_path, 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 # copy hadoop deps to the staging dir
hdeps_path = druid_path + "/hadoop-dependencies" hdeps_path = druid_path + "/hadoop-dependencies"
tmp_hdeps_path = tmp_path + "/2-hdeps" tmp_hdeps_path = tmp_path + "/2-hdeps"
os.mkdir(tmp_hdeps_path) os.mkdir(tmp_hdeps_path)
command = "cp -r {}/* {}".format(hdeps_path, 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 # copy all extension folders to the staging dir
@ -49,7 +49,7 @@ def main():
tmp_ext_path = tmp_path + "/3-ext" tmp_ext_path = tmp_path + "/3-ext"
os.mkdir(tmp_ext_path) os.mkdir(tmp_ext_path)
command = "cp -r {}/* {}".format(ext_path, 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) get_notices(tmp_path)