diff --git a/common/parser_config.py b/common/parser_config.py index 170160b6dec51aaa04b24224014d1101fda90925..0bcef489a34c7492d097472ec815d1c59152ed50 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 bf6ba65a2de610588f722a0b4eb995613361620a..cd1cf3d217689e77ea223b8bf694236356250fb9 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 new file mode 100644 index 0000000000000000000000000000000000000000..ac3dd2aa9bd95bbb8f33561db6eeaf459352a6c8 --- /dev/null +++ b/core/save.py @@ -0,0 +1,46 @@ +#/bin/env python3 +# -*- encoding=utf8 -*- +""" +created by: miaokaibo +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): + """ + save info + """ + def __init__(self): + """ + init + """ + parc = ParserConfigIni() + self.file_name = parc.get_package_info_file() + + 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(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__": + s = SaveInfo() + s.save_package_msg("vim", "master") +