diff --git a/advisors/check_abi.py b/advisors/check_abi.py index cc68e6aef917d2893158998df7da0d0742e06e9f..749af6bd4e06b6118fdfdee95b875c04367d851c 100755 --- a/advisors/check_abi.py +++ b/advisors/check_abi.py @@ -159,7 +159,7 @@ class CheckAbi(): ret = subprocess.run(abidiff_cmd, shell=True, check=False) abidiff_file = os.path.join(self.work_path, "{}_{}_abidiff.out".format(base_name, - os.path.basename(new_so_file))) + os.path.basename(new_so_file))) all_abidiff_files.append(abidiff_file) logging.info("result write in: %s, returncode:%d", abidiff_file, ret.returncode) return_code |= ret.returncode @@ -259,7 +259,7 @@ class CheckAbi(): #logging.debug("\n---check if the rpm require target .so files:%s---", rpm_package) require_info_file = os.path.join(temp_path, "require_info_file.txt") subprocess.call("rpm -qpR {} > {}".format(rpm_package, require_info_file), shell=True, - stderr=subprocess.PIPE) + stderr=subprocess.PIPE) logging.debug("write require .sos info at:%s", require_info_file) with open(require_info_file, 'r') as fd_diff: @@ -316,7 +316,8 @@ class CheckAbi(): logging.info("[%d/%d] check effect rpms: %s", count, rpm_number, os.path.basename(rpm_package)) if self.check_rpm_require_taget_functions(rpm_package, temp_path, - rpm_require_functions, diff_functions): + rpm_require_functions, + diff_functions): write_name = os.path.basename(rpm_package) + ":" for func in rpm_require_functions: write_name += (" " + func) @@ -421,7 +422,7 @@ class CheckAbi(): debuginfo_paths = [os.path.join(x, "usr/lib/debug") for x in abi_paths] - rpm_base_name = os.path.basename(rpm_path[0]).rsplit("-", 2)[0] + rpm_base_name = os.path.basename(rpm_path[0]).rsplit("-", 2)[0] returncode = self.do_abidiff(all_so_pairs, rpm_base_name, debuginfo_paths) logging.debug("\n--- delete temp directory:%s ---", temp_path) @@ -453,7 +454,7 @@ class CheckAbi(): new_rpm_name = find_new_rpm(old_rpm_name, rpms_paths[1]) if new_rpm_name: rpms_pair = [old_rpm_name, new_rpm_name] - debug_rpms_pair = [self.find_debug_rpm(x[0], x[1]) + debug_rpms_pair = [find_debug_rpm(x[0], x[1]) for x in zip(rpms_pair, rpms_paths)] if not debug_rpms_pair[0] or not debug_rpms_pair[1]: debuginfo_rpm = None @@ -496,7 +497,7 @@ class CheckAbi(): logging.debug("begin abidiff between %s and %s", old_so_file, new_so_file) abidiff_file = os.path.join(self.work_path, "{}_{}_abidiff.out".format(base_name, - os.path.basename(new_so_file))) + os.path.basename(new_so_file))) so_options = "{} {}".format(old_so_file, new_so_file) if self.show_all_info: additional_options = "--harmless" @@ -539,7 +540,10 @@ def get_rpms_path(rpms_url, dest): use_args = "-t 5 -r -c -np -nH -nd -R index.html" if isinstance(rpms_url, str): subprocess.run("wget {} -P {} {} > /dev/null 2>&1".format(use_args, - dest, rpms_url), shell=True, check=False) + dest, + rpms_url), + shell=True, + check=False) else: count = 0 need_download = len(rpms_url) @@ -620,7 +624,8 @@ def scan_target_functions_with_so(so_file, temp_path, rpm_require_functions, """ require_func_file = os.path.join(temp_path, "calls_func_file.txt") subprocess.run("nm -D -C -u {} > {}".format(so_file, require_func_file), - shell=True, check=False) + shell=True, + check=False) with open(require_func_file, 'r') as fd_req: lines = fd_req.readlines() fd_req.close() @@ -727,13 +732,14 @@ def parse_command_line(): so_parser.add_argument("-f", "--debuginfo_path", nargs=2, required=False, metavar=('old_debuginfo_path', 'new_debuginfo_path'), help="Path or URL of both the old and new debuginfo files," - "corresponding to compared .so files.") + "corresponding to compared .so files.") + so_parser.set_defaults(func=process_with_so) rpms_parser = subparser.add_parser('compare_rpms', help="Compare between two RPMs paths") rpms_parser.add_argument("-p", "--paths", required=True, nargs=2, - metavar=('old_path', 'new_path'), - help="Path of both the old RPMs and new RPMs") + metavar=('old_path', 'new_path'), + help="Path of both the old RPMs and new RPMs") rpms_parser.set_defaults(func=process_with_rpms) config = parser.parse_args() @@ -775,7 +781,7 @@ def main(): logging.basicConfig(format='%(message)s', level=logging.INFO) config.work_path = os.path.abspath(config.work_path) - check_abi_process = CheckAbi(vars(config)) + check_abi_process = CheckAbi(**vars(config)) ret = config.func(config, check_abi_process) sys.exit(ret) diff --git a/advisors/simple_update_robot.py b/advisors/simple_update_robot.py index 68eec0730cc5cce795a450d5a2a8314250981105..55265e3cfc3a078cf8475b0dedf0816ba85606ba 100755 --- a/advisors/simple_update_robot.py +++ b/advisors/simple_update_robot.py @@ -74,7 +74,8 @@ def download_helper(src_url, file_name=None): while down_cnt < 2: down_cnt += 1 if not subprocess.call(["timeout 15m wget -c {url} -O {name} -q".format(url=src_url, - name=file_name)], shell=True): + name=file_name)], + shell=True): break return src_url @@ -135,7 +136,9 @@ def update_ver_check(repo, o_ver, n_ver): result = True else: print("WARNING: Update failed >> [{pkg}: current_ver:{c_ver}, upgrade_ver:{u_ver}]".format( - pkg=repo, c_ver=o_ver, u_ver=n_ver)) + pkg=repo, + c_ver=o_ver, + u_ver=n_ver)) result = False return result @@ -154,7 +157,7 @@ def fork_clone_repo(gt_api, repo, branch): if os.path.exists(repo): shutil.rmtree(repo, ignore_errors=True) if subprocess.call(["git", "clone", "git@gitee.com:{user}/{pkg}".format(user=name, - pkg=repo)]): + pkg=repo)]): time.sleep(1) continue os.chdir(repo) @@ -203,8 +206,9 @@ def cpan_source_helper(src_name, src_url): download_helper(new_url) old_path = src_url.strip(src_file) new_path = new_url.strip(src_file) - subprocess.call(["grep -lr {old} | xargs sed -i \'s#{old}#{new}#g\'".format( - old=old_path, new=new_path)], shell=True) + subprocess.call(["grep -lr {old} | xargs sed -i \'s#{old}#{new}#g\'" + .format(old=old_path, new=new_path)], + shell=True) break return @@ -327,7 +331,7 @@ def build_pkg(u_pkg, u_branch, obs_prj): subprocess.call(["osc", "rm", "_service"]) subprocess.call(["osc", "up", "-S"]) subprocess.call(["for file in `ls _service:*`;" + "do newfile=${file##*:};" + - "mv -v $file $newfile;done"], shell=True) + "mv -v $file $newfile;done"], shell=True) #Build old version if 'aarch64' in platform.machine(): @@ -391,6 +395,9 @@ def push_create_pr_issue(gt_api, values): shell=True) subprocess.call(["git push origin"], shell=True) ret_pr = gt_api.create_pr(u_pkg, u_ver, u_branch) + if not ret_pr: + print("WARNING: create_pr failed, please check the pr already exist ?") + return number = json.loads(ret_pr)['number'] gt_api.create_pr_comment(u_pkg, number, check_result) gt_api.create_issue(u_pkg, u_ver, u_branch) @@ -460,7 +467,7 @@ def auto_update_repo(gt_api, u_repo, u_branch): repo_yaml = open(os.path.join(os.getcwd(), "{repo}.yaml".format(repo=u_repo))) except FileNotFoundError: print("WARNING: {repo}.yaml can't be found in current working directory.".format( - repo=u_repo)) + repo=u_repo)) repo_yaml = gt_api.get_community(u_repo) if not repo_yaml: print("WARNING: {repo}.yaml in community is empty.".format(repo=u_repo)) @@ -597,7 +604,8 @@ def __manual_operate(gt_api, op_args): spec_string = gt_api.get_spec(op_args.repo_pkg, op_args.branch) if not spec_string: print("WARNING: Spec of {pkg} can't be found on the {br} branch.".format( - pkg=op_args.repo_pkg, br=op_args.branch)) + pkg=op_args.repo_pkg, + br=op_args.branch)) sys.exit(1) spec_file = Spec.from_string(spec_string) cur_version = replace_macros(spec_file.version, spec_file)