From c9cfb341fd9a6195a9e9c8cb571e66e8811ba734 Mon Sep 17 00:00:00 2001 From: anyuting Date: Sun, 25 Jun 2023 06:50:44 +0000 Subject: [PATCH 01/13] =?UTF-8?q?=E6=96=B0=E5=BB=BA=20porting=5Fadvisor?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tools/porting_advisor/.keep | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 tools/porting_advisor/.keep diff --git a/tools/porting_advisor/.keep b/tools/porting_advisor/.keep new file mode 100644 index 0000000..e69de29 -- Gitee From d6b5dd49c844e486dd0c1106b8adca4ef8cb1b9c Mon Sep 17 00:00:00 2001 From: anyuting Date: Sun, 25 Jun 2023 07:06:20 +0000 Subject: [PATCH 02/13] =?UTF-8?q?=E6=89=B9=E9=87=8F=E6=89=AB=E4=BB=93?= =?UTF-8?q?=E5=BA=93=E6=BA=90=E7=A0=81=E7=9A=84=E8=84=9A=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: anyuting --- tools/porting_advisor/Batch_Scan.py | 37 +++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 tools/porting_advisor/Batch_Scan.py diff --git a/tools/porting_advisor/Batch_Scan.py b/tools/porting_advisor/Batch_Scan.py new file mode 100644 index 0000000..12174ea --- /dev/null +++ b/tools/porting_advisor/Batch_Scan.py @@ -0,0 +1,37 @@ +import os +import time + +import requests + +os.environ['http_proxy'] = "http://a30042002:ayt522159+@proxycn2.huawei.com:8080/" +os.environ['https_proxy'] = "http://a30042002:ayt5221539+@proxycn2.huawei.com:8080/" +try: + from urllib import urlencode +except ImportError: + from urllib.parse import urlencode + +repo_owner = 'src-openeuler' #获取那个组织的仓库 +requests.packages.urllib3.disable_warnings() +body = "/source_scan" +data = {"access_token": 'b9782766767e177bdc98990a00482e25', "body": "/source_scan"} +for i in range(7, 101):#从第几页开始扫描 + comment_pr_url = "https://gitee.com/api/v5/orgs/{}/repos?type=all&page={}&per_page=100".format(repo_owner, i) + res = requests.get(comment_pr_url, verify=False, timeout=50) + print("获取仓库") + root_dict = res.json() + for j in range(0, 100): + repo = root_dict[j]["name"] + print("页数") + print(i) + print("仓库名为" + repo) + comment_pr_url = "https://gitee.com/api/v5/repos/{}/{}/pulls/{}/comments".format(repo_owner, repo, 1) + res = requests.post(comment_pr_url, data, timeout=50, verify=False) + print("评论/source_scan") + comment_pr_url = "https://gitee.com/api/v5/repos/{}/{}/pulls/{}/comments?per_page=20&direction=desc". \ + format(repo_owner, repo, 1) + res = requests.get(comment_pr_url, data, timeout=50, verify=False) + if res.status_code == 200: + while res.json()[0]["user"]["name"] == 'anyuting': + time.sleep(30) + res = requests.get(comment_pr_url, data, timeout=50, verify=False) + print("已得到" + repo + "的报告") -- Gitee From d4392b24e69c5b6ee7cab4db43625042605d8fbe Mon Sep 17 00:00:00 2001 From: anyuting Date: Sun, 25 Jun 2023 07:06:42 +0000 Subject: [PATCH 03/13] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=96=87=E4=BB=B6=20to?= =?UTF-8?q?ols/porting=5Fadvisor/.keep?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tools/porting_advisor/.keep | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 tools/porting_advisor/.keep diff --git a/tools/porting_advisor/.keep b/tools/porting_advisor/.keep deleted file mode 100644 index e69de29..0000000 -- Gitee From 5e3c2844e664aa2baba7faf382ed1cd7d77e5fc9 Mon Sep 17 00:00:00 2001 From: anyuting Date: Sun, 25 Jun 2023 07:07:39 +0000 Subject: [PATCH 04/13] =?UTF-8?q?=E5=AF=B9=E5=B7=A5=E5=85=B7=E7=9A=84?= =?UTF-8?q?=E6=89=AB=E6=8F=8F=E7=BB=93=E6=9E=9C=E8=BF=9B=E8=A1=8C=E6=89=AB?= =?UTF-8?q?=E6=8F=8F=EF=BC=8C=E8=8E=B7=E5=8F=96=E6=B1=87=E6=80=BB=E4=BF=A1?= =?UTF-8?q?=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: anyuting --- tools/porting_advisor/ScanReport.py | 46 +++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 tools/porting_advisor/ScanReport.py diff --git a/tools/porting_advisor/ScanReport.py b/tools/porting_advisor/ScanReport.py new file mode 100644 index 0000000..c39699c --- /dev/null +++ b/tools/porting_advisor/ScanReport.py @@ -0,0 +1,46 @@ +import csv +import os + +path = 'C:\\Users\\a30042002\Desktop\\report-master' # 要扫描的文件夹,注意不要包含中文 +files = os.listdir(path) # 获取的文件夹列表 +title = ["项目", "是否需要迁移", "Number of Scanned Files", "C/C++/Fortran/Makefile/CMakeLists.txt/Automake", + "pure assembly files", "Go files", "python files", "java files", "scala files", + "Estimated transplant workload"] + +with open(r'C:\\Users\\a30042002\Desktop\\report.csv', 'a', newline="", encoding="UTF-8-SIG") as f:#写入title + writer = csv.writer(f) + writer.writerow(title) + + +def splitCsvFiles(): + for file in files: + dirpath = 'C:\\Users\\a30042002\Desktop\\report-master\\{}\\porting-advisor.csv'.format(file) + print(dirpath) + f = open(dirpath) + csv_reader = csv.reader(f) + fields = [file] + begin = 0 + for line in csv_reader:#判断是否需要迁移, + if begin == 1: + fields.append(line) + if 'Estimated transplant' in line: + begin = 0 + break + if 'Source Need Migrated: NO' in line: + fields.append('Source Need Migrated: NO') + break + if 'Source Need Migrated: YES' in line: + begin = 1 + fields.append('Source Need Migrated: YES') + if 'Architecture-related Dependencies:' in line or 'Source files scan details are as follows:' in line: + fields.pop(len(fields) - 1) + fields.pop(len(fields) - 1) + begin = 0 + break + with open(r'C:\\Users\\a30042002\Desktop\\report.csv', 'a', newline="") as f: + writer = csv.writer(f) + writer.writerow(fields) + + +if __name__ == '__main__': + splitCsvFiles() -- Gitee From a8b86b154f7a5486d273e841dc1e89850b9e88ab Mon Sep 17 00:00:00 2001 From: anyuting Date: Sun, 25 Jun 2023 07:55:44 +0000 Subject: [PATCH 05/13] rename tools/porting_advisor/Batch_Scan.py to tools/porting_advisor/batch_scan.py. Signed-off-by: anyuting --- tools/porting_advisor/{Batch_Scan.py => batch_scan.py} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename tools/porting_advisor/{Batch_Scan.py => batch_scan.py} (100%) diff --git a/tools/porting_advisor/Batch_Scan.py b/tools/porting_advisor/batch_scan.py similarity index 100% rename from tools/porting_advisor/Batch_Scan.py rename to tools/porting_advisor/batch_scan.py -- Gitee From c75c7efa18c4d671210ccdf072bc1911dcbf38f5 Mon Sep 17 00:00:00 2001 From: anyuting Date: Sun, 25 Jun 2023 07:56:10 +0000 Subject: [PATCH 06/13] rename tools/porting_advisor/ScanReport.py to tools/porting_advisor/scan_report.py. Signed-off-by: anyuting --- tools/porting_advisor/{ScanReport.py => scan_report.py} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename tools/porting_advisor/{ScanReport.py => scan_report.py} (100%) diff --git a/tools/porting_advisor/ScanReport.py b/tools/porting_advisor/scan_report.py similarity index 100% rename from tools/porting_advisor/ScanReport.py rename to tools/porting_advisor/scan_report.py -- Gitee From bca433c122bbc4ae4c9f8eb55de1a66dff12b7f7 Mon Sep 17 00:00:00 2001 From: anyuting Date: Sun, 25 Jun 2023 08:30:34 +0000 Subject: [PATCH 07/13] update tools/porting_advisor/batch_scan.py. Signed-off-by: anyuting --- tools/porting_advisor/batch_scan.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/porting_advisor/batch_scan.py b/tools/porting_advisor/batch_scan.py index 12174ea..a88f3b3 100644 --- a/tools/porting_advisor/batch_scan.py +++ b/tools/porting_advisor/batch_scan.py @@ -14,7 +14,7 @@ repo_owner = 'src-openeuler' #获取那个组织的仓库 requests.packages.urllib3.disable_warnings() body = "/source_scan" data = {"access_token": 'b9782766767e177bdc98990a00482e25', "body": "/source_scan"} -for i in range(7, 101):#从第几页开始扫描 +for i in range(7, 101): #从第几页开始扫描 comment_pr_url = "https://gitee.com/api/v5/orgs/{}/repos?type=all&page={}&per_page=100".format(repo_owner, i) res = requests.get(comment_pr_url, verify=False, timeout=50) print("获取仓库") -- Gitee From de24d0942767180d7aeee5b262d9eee8c69ee529 Mon Sep 17 00:00:00 2001 From: anyuting Date: Sun, 25 Jun 2023 08:30:52 +0000 Subject: [PATCH 08/13] update tools/porting_advisor/scan_report.py. Signed-off-by: anyuting --- tools/porting_advisor/scan_report.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/porting_advisor/scan_report.py b/tools/porting_advisor/scan_report.py index c39699c..0b70143 100644 --- a/tools/porting_advisor/scan_report.py +++ b/tools/porting_advisor/scan_report.py @@ -7,7 +7,7 @@ title = ["项目", "是否需要迁移", "Number of Scanned Files", "C/C++/Fortr "pure assembly files", "Go files", "python files", "java files", "scala files", "Estimated transplant workload"] -with open(r'C:\\Users\\a30042002\Desktop\\report.csv', 'a', newline="", encoding="UTF-8-SIG") as f:#写入title +with open(r'C:\\Users\\a30042002\Desktop\\report.csv', 'a', newline="", encoding="UTF-8-SIG") as f: #写入title writer = csv.writer(f) writer.writerow(title) @@ -20,7 +20,7 @@ def splitCsvFiles(): csv_reader = csv.reader(f) fields = [file] begin = 0 - for line in csv_reader:#判断是否需要迁移, + for line in csv_reader: #判断是否需要迁移, if begin == 1: fields.append(line) if 'Estimated transplant' in line: -- Gitee From 91d662c06a2186ccce397b13e2d4517fdacfd1c1 Mon Sep 17 00:00:00 2001 From: anyuting Date: Sun, 25 Jun 2023 11:38:40 +0000 Subject: [PATCH 09/13] update tools/porting_advisor/batch_scan.py. Signed-off-by: anyuting --- tools/porting_advisor/batch_scan.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/porting_advisor/batch_scan.py b/tools/porting_advisor/batch_scan.py index a88f3b3..89e42ea 100644 --- a/tools/porting_advisor/batch_scan.py +++ b/tools/porting_advisor/batch_scan.py @@ -3,8 +3,8 @@ import time import requests -os.environ['http_proxy'] = "http://a30042002:ayt522159+@proxycn2.huawei.com:8080/" -os.environ['https_proxy'] = "http://a30042002:ayt5221539+@proxycn2.huawei.com:8080/" +os.environ['http_proxy'] = "http://w3账号:密码@proxycn2.huawei.com:8080/" +os.environ['https_proxy'] = "http://w3账号:密码@proxycn2.huawei.com:8080/" try: from urllib import urlencode except ImportError: -- Gitee From 5343108f31f9fbdb21829fded7732f2d93873cd6 Mon Sep 17 00:00:00 2001 From: anyuting Date: Sun, 25 Jun 2023 11:45:41 +0000 Subject: [PATCH 10/13] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=96=87=E4=BB=B6=20to?= =?UTF-8?q?ols/porting=5Fadvisor/batch=5Fscan.py?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tools/porting_advisor/batch_scan.py | 37 ----------------------------- 1 file changed, 37 deletions(-) delete mode 100644 tools/porting_advisor/batch_scan.py diff --git a/tools/porting_advisor/batch_scan.py b/tools/porting_advisor/batch_scan.py deleted file mode 100644 index 89e42ea..0000000 --- a/tools/porting_advisor/batch_scan.py +++ /dev/null @@ -1,37 +0,0 @@ -import os -import time - -import requests - -os.environ['http_proxy'] = "http://w3账号:密码@proxycn2.huawei.com:8080/" -os.environ['https_proxy'] = "http://w3账号:密码@proxycn2.huawei.com:8080/" -try: - from urllib import urlencode -except ImportError: - from urllib.parse import urlencode - -repo_owner = 'src-openeuler' #获取那个组织的仓库 -requests.packages.urllib3.disable_warnings() -body = "/source_scan" -data = {"access_token": 'b9782766767e177bdc98990a00482e25', "body": "/source_scan"} -for i in range(7, 101): #从第几页开始扫描 - comment_pr_url = "https://gitee.com/api/v5/orgs/{}/repos?type=all&page={}&per_page=100".format(repo_owner, i) - res = requests.get(comment_pr_url, verify=False, timeout=50) - print("获取仓库") - root_dict = res.json() - for j in range(0, 100): - repo = root_dict[j]["name"] - print("页数") - print(i) - print("仓库名为" + repo) - comment_pr_url = "https://gitee.com/api/v5/repos/{}/{}/pulls/{}/comments".format(repo_owner, repo, 1) - res = requests.post(comment_pr_url, data, timeout=50, verify=False) - print("评论/source_scan") - comment_pr_url = "https://gitee.com/api/v5/repos/{}/{}/pulls/{}/comments?per_page=20&direction=desc". \ - format(repo_owner, repo, 1) - res = requests.get(comment_pr_url, data, timeout=50, verify=False) - if res.status_code == 200: - while res.json()[0]["user"]["name"] == 'anyuting': - time.sleep(30) - res = requests.get(comment_pr_url, data, timeout=50, verify=False) - print("已得到" + repo + "的报告") -- Gitee From 642dd672e6158cf56bb1d9d39d552c1602517b4e Mon Sep 17 00:00:00 2001 From: anyuting Date: Sun, 25 Jun 2023 11:47:45 +0000 Subject: [PATCH 11/13] update tools/porting_advisor/scan_report.py. Signed-off-by: anyuting --- tools/porting_advisor/scan_report.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tools/porting_advisor/scan_report.py b/tools/porting_advisor/scan_report.py index 0b70143..c8c86d5 100644 --- a/tools/porting_advisor/scan_report.py +++ b/tools/porting_advisor/scan_report.py @@ -1,20 +1,20 @@ import csv import os -path = 'C:\\Users\\a30042002\Desktop\\report-master' # 要扫描的文件夹,注意不要包含中文 +path = 'C:\\Users\Desktop\\report-master' # 要扫描的文件夹,注意不要包含中文 files = os.listdir(path) # 获取的文件夹列表 title = ["项目", "是否需要迁移", "Number of Scanned Files", "C/C++/Fortran/Makefile/CMakeLists.txt/Automake", "pure assembly files", "Go files", "python files", "java files", "scala files", "Estimated transplant workload"] -with open(r'C:\\Users\\a30042002\Desktop\\report.csv', 'a', newline="", encoding="UTF-8-SIG") as f: #写入title +with open(r'C:\\Users\Desktop\\report.csv', 'a', newline="", encoding="UTF-8-SIG") as f: #写入title writer = csv.writer(f) writer.writerow(title) def splitCsvFiles(): for file in files: - dirpath = 'C:\\Users\\a30042002\Desktop\\report-master\\{}\\porting-advisor.csv'.format(file) + dirpath = 'C:\\Users\Desktop\\report-master\\{}\\porting-advisor.csv'.format(file) print(dirpath) f = open(dirpath) csv_reader = csv.reader(f) @@ -37,7 +37,7 @@ def splitCsvFiles(): fields.pop(len(fields) - 1) begin = 0 break - with open(r'C:\\Users\\a30042002\Desktop\\report.csv', 'a', newline="") as f: + with open(r'C:\\Users\Desktop\\report.csv', 'a', newline="") as f: writer = csv.writer(f) writer.writerow(fields) -- Gitee From dbb9c007944f9b968b18ce3de940b7de69db15b3 Mon Sep 17 00:00:00 2001 From: anyuting Date: Sun, 25 Jun 2023 11:49:20 +0000 Subject: [PATCH 12/13] =?UTF-8?q?=E6=89=B9=E9=87=8F=E6=89=AB=E4=BB=93?= =?UTF-8?q?=E5=BA=93=E6=BA=90=E7=A0=81=E7=9A=84=E8=84=9A=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: anyuting --- tools/porting_advisor/batch_scan.py | 37 +++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 tools/porting_advisor/batch_scan.py diff --git a/tools/porting_advisor/batch_scan.py b/tools/porting_advisor/batch_scan.py new file mode 100644 index 0000000..5b6d8e9 --- /dev/null +++ b/tools/porting_advisor/batch_scan.py @@ -0,0 +1,37 @@ +import os +import time + +import requests + +os.environ['http_proxy'] = "http://a30042002:ayt522159+@proxycn2.huawei.com:8080/" +os.environ['https_proxy'] = "http://a30042002:ayt5221539+@proxycn2.huawei.com:8080/" +try: + from urllib import urlencode +except ImportError: + from urllib.parse import urlencode + +repo_owner = 'src-openeuler' # 获取那个组织的仓库 +requests.packages.urllib3.disable_warnings() +body = "/source_scan" +data = {"access_token": 'b9782766767e177bdc98990a00482e25', "body": "/source_scan"} +for i in range(7, 101): # 从第几页开始扫描 + comment_pr_url = "https://gitee.com/api/v5/orgs/{}/repos?type=all&page={}&per_page=100".format(repo_owner, i) + res = requests.get(comment_pr_url, verify=False, timeout=50) + print("获取仓库") + root_dict = res.json() + for j in range(0, 100): + repo = root_dict[j]["name"] + print("页数") + print(i) + print("仓库名为" + repo) + comment_pr_url = "https://gitee.com/api/v5/repos/{}/{}/pulls/{}/comments".format(repo_owner, repo, 1) + res = requests.post(comment_pr_url, data, timeout=50, verify=False) + print("评论/source_scan") + comment_pr_url = "https://gitee.com/api/v5/repos/{}/{}/pulls/{}/comments?per_page=20&direction=desc". \ + format(repo_owner, repo, 1) + res = requests.get(comment_pr_url, data, timeout=50, verify=False) + if res.status_code == 200: + while res.json()[0]["user"]["name"] == 'anyuting': + time.sleep(30) + res = requests.get(comment_pr_url, data, timeout=50, verify=False) + print("已得到" + repo + "的报告") -- Gitee From 672b8094a530bb5f7e044c126900ecee73e0f577 Mon Sep 17 00:00:00 2001 From: anyuting Date: Sun, 25 Jun 2023 11:50:45 +0000 Subject: [PATCH 13/13] update tools/porting_advisor/batch_scan.py. Signed-off-by: anyuting --- tools/porting_advisor/batch_scan.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tools/porting_advisor/batch_scan.py b/tools/porting_advisor/batch_scan.py index 5b6d8e9..6364f70 100644 --- a/tools/porting_advisor/batch_scan.py +++ b/tools/porting_advisor/batch_scan.py @@ -3,8 +3,8 @@ import time import requests -os.environ['http_proxy'] = "http://a30042002:ayt522159+@proxycn2.huawei.com:8080/" -os.environ['https_proxy'] = "http://a30042002:ayt5221539+@proxycn2.huawei.com:8080/" +os.environ['http_proxy'] = "http://w3账号:密码@proxycn2.huawei.com:8080/" +os.environ['https_proxy'] = "http://w3账号:密码@proxycn2.huawei.com:8080/" try: from urllib import urlencode except ImportError: @@ -13,8 +13,8 @@ except ImportError: repo_owner = 'src-openeuler' # 获取那个组织的仓库 requests.packages.urllib3.disable_warnings() body = "/source_scan" -data = {"access_token": 'b9782766767e177bdc98990a00482e25', "body": "/source_scan"} -for i in range(7, 101): # 从第几页开始扫描 +data = {"access_token": 'token实际的值', "body": "/source_scan"} +for i in range(10, 101): # 从第几页开始扫描 comment_pr_url = "https://gitee.com/api/v5/orgs/{}/repos?type=all&page={}&per_page=100".format(repo_owner, i) res = requests.get(comment_pr_url, verify=False, timeout=50) print("获取仓库") -- Gitee