From 31a9e767a55152a117dea0eba3160048a1fcc6a6 Mon Sep 17 00:00:00 2001 From: miao_kaibo Date: Thu, 22 Oct 2020 14:36:44 +0800 Subject: [PATCH 1/8] add save method for package --- core/save.py | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 core/save.py diff --git a/core/save.py b/core/save.py new file mode 100644 index 0000000..aed66e1 --- /dev/null +++ b/core/save.py @@ -0,0 +1,37 @@ +#/bin/env python3 +# -*- encoding=utf8 -*- +""" +created by: miaokaibo +date: 2020-10-22 9:30 +""" +import csv +import os + + +class SaveInfo(object): + """ + save info to file for packages which is not be updated + """ + def __init__(self): + """ + init + """ + pass + + def save_package_msg(self, package_name, branch_name): + """ + save info + package_name: package which is not be updated + branch_name: branch of package + """ + file_path = os.path.join(os.path.split(os.path.realpath(__file__))[0], + "../log/package_info.csv") + with open(file_path, 'a') as f: + csv_writer = csv.writer(f) + csv_writer.writerow([package_name, branch_name]) + + +if __name__ == "__main__": + s = SaveInfo() + s.save_package_msg("vim","master") + -- Gitee From 1b206721ad0988227ff9c2771545764bd3dae725 Mon Sep 17 00:00:00 2001 From: miao_kaibo Date: Thu, 22 Oct 2020 16:24:35 +0800 Subject: [PATCH 2/8] update package info --- log/package_info.csv | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 log/package_info.csv diff --git a/log/package_info.csv b/log/package_info.csv new file mode 100644 index 0000000..5782e53 --- /dev/null +++ b/log/package_info.csv @@ -0,0 +1,7 @@ +vim,master +vim,master +vim,master +vim,master +vim,master +vi,mster +vim,master -- Gitee From 0270a5c00f9b88d2aff7ca005df556b35300e126 Mon Sep 17 00:00:00 2001 From: miao_kaibo Date: Thu, 22 Oct 2020 16:41:31 +0800 Subject: [PATCH 3/8] update package info --- log/package_info_file.csv | 1 + 1 file changed, 1 insertion(+) create mode 100644 log/package_info_file.csv diff --git a/log/package_info_file.csv b/log/package_info_file.csv new file mode 100644 index 0000000..eb74c81 --- /dev/null +++ b/log/package_info_file.csv @@ -0,0 +1 @@ +vim,master -- Gitee From 12a597ccd3cacfe5d60867b87876448d2d21ddd3 Mon Sep 17 00:00:00 2001 From: miao_kaibo Date: Thu, 22 Oct 2020 16:44:32 +0800 Subject: [PATCH 4/8] add package info file to config.ini --- common/parser_config.py | 13 +++++++++++++ config/config.ini | 2 ++ core/save.py | 15 ++++++++++++--- 3 files changed, 27 insertions(+), 3 deletions(-) diff --git a/common/parser_config.py b/common/parser_config.py index 170160b..0bcef48 100644 --- a/common/parser_config.py +++ b/common/parser_config.py @@ -30,6 +30,7 @@ class ParserConfigIni(object): self.config.read(config_path, encoding='utf-8') self._init_update_enabled_flag() self._init_ignored_repo() + self._init_package_info_file() def _init_update_enabled_flag(self): """ @@ -62,6 +63,18 @@ class ParserConfigIni(object): """ return self.ignored_repos + def _init_package_info_file(self): + """ + init package info file for store package which is not be updated + """ + self.package_info_file = self.config.get("package_info_file", "name") + + def get_package_info_file(self): + """ + get file + """ + return self.package_info_file + if __name__ == "__main__": p = ParserConfigIni() diff --git a/config/config.ini b/config/config.ini index bf6ba65..cd1cf3d 100644 --- a/config/config.ini +++ b/config/config.ini @@ -5,3 +5,5 @@ openEuler-20.03-LTS-Next = True openEuler-20.09 = True [ignore_repo] name = ci_check build +[package_info_file] +name = package_info.csv diff --git a/core/save.py b/core/save.py index aed66e1..dce3d1a 100644 --- a/core/save.py +++ b/core/save.py @@ -6,7 +6,12 @@ date: 2020-10-22 9:30 """ import csv import os +import sys +current_path = os.path.join(os.path.split(os.path.realpath(__file__))[0]) +sys.path.append(os.path.join(current_path, "..")) +from common.log_obs import log +from common.parser_config import ParserConfigIni class SaveInfo(object): """ @@ -16,7 +21,8 @@ class SaveInfo(object): """ init """ - pass + parc = ParserConfigIni() + self.file_name = parc.get_package_info_file() def save_package_msg(self, package_name, branch_name): """ @@ -24,11 +30,14 @@ class SaveInfo(object): package_name: package which is not be updated branch_name: branch of package """ - file_path = os.path.join(os.path.split(os.path.realpath(__file__))[0], - "../log/package_info.csv") + file_path = os.path.join(current_path, "../log", self.file_name) + log.info("package: %s, branch: %s" % (package_name, branch_name)) with open(file_path, 'a') as f: csv_writer = csv.writer(f) csv_writer.writerow([package_name, branch_name]) + cmd="git pull; git add %s; git commit -m 'update package info';\ + git push" % file_path + os.system(cmd) if __name__ == "__main__": -- Gitee From dc8e14278827a69fd0a456a7415127e5433397f9 Mon Sep 17 00:00:00 2001 From: miao_kaibo Date: Thu, 22 Oct 2020 16:45:43 +0800 Subject: [PATCH 5/8] delete csv file --- log/package_info.csv | 7 ------- log/package_info_file.csv | 1 - 2 files changed, 8 deletions(-) delete mode 100644 log/package_info.csv delete mode 100644 log/package_info_file.csv diff --git a/log/package_info.csv b/log/package_info.csv deleted file mode 100644 index 5782e53..0000000 --- a/log/package_info.csv +++ /dev/null @@ -1,7 +0,0 @@ -vim,master -vim,master -vim,master -vim,master -vim,master -vi,mster -vim,master diff --git a/log/package_info_file.csv b/log/package_info_file.csv deleted file mode 100644 index eb74c81..0000000 --- a/log/package_info_file.csv +++ /dev/null @@ -1 +0,0 @@ -vim,master -- Gitee From 282196e9fa37c1f6cb063f48ec8e58127e8d0759 Mon Sep 17 00:00:00 2001 From: miao_kaibo Date: Thu, 22 Oct 2020 16:47:50 +0800 Subject: [PATCH 6/8] add espace before ';' --- core/save.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/save.py b/core/save.py index dce3d1a..5201e7e 100644 --- a/core/save.py +++ b/core/save.py @@ -35,7 +35,7 @@ class SaveInfo(object): with open(file_path, 'a') as f: csv_writer = csv.writer(f) csv_writer.writerow([package_name, branch_name]) - cmd="git pull; git add %s; git commit -m 'update package info';\ + cmd="git pull; git add %s; git commit -m 'update package info'; \ git push" % file_path os.system(cmd) -- Gitee From a42bf1dfbe5cca9a7ab04cb5136b813b5e0b3457 Mon Sep 17 00:00:00 2001 From: miao_kaibo Date: Thu, 22 Oct 2020 16:49:36 +0800 Subject: [PATCH 7/8] add espace after ',' --- core/save.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/save.py b/core/save.py index 5201e7e..241fe5e 100644 --- a/core/save.py +++ b/core/save.py @@ -42,5 +42,5 @@ class SaveInfo(object): if __name__ == "__main__": s = SaveInfo() - s.save_package_msg("vim","master") + s.save_package_msg("vim", "master") -- Gitee From 10f8fa33c8b6d27794b0ea5e873322ac7e23f458 Mon Sep 17 00:00:00 2001 From: miao_kaibo Date: Thu, 22 Oct 2020 16:51:05 +0800 Subject: [PATCH 8/8] change save.py discription --- core/save.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/save.py b/core/save.py index 241fe5e..ac3dd2a 100644 --- a/core/save.py +++ b/core/save.py @@ -15,7 +15,7 @@ from common.parser_config import ParserConfigIni class SaveInfo(object): """ - save info to file for packages which is not be updated + save info """ def __init__(self): """ -- Gitee