提交 4ee24ba5 编写于 作者: L Leo Fang

improve get_yaml() in gitee.py and bugfix for oa_upgradable.py

Signed-off-by: NLeo Fang <leofang_94@163.com>
上级 2781a7b1
...@@ -131,7 +131,7 @@ Yours openEuler-Advisor. ...@@ -131,7 +131,7 @@ Yours openEuler-Advisor.
def get_yaml(self, pkg, br="master"): def get_yaml(self, pkg, br="master"):
""" """
get upstream yaml metadata for specific package Get upstream yaml metadata for specific package
""" """
yamlurl = self.advisor_url_template.format(package=pkg) yamlurl = self.advisor_url_template.format(package=pkg)
try: try:
...@@ -145,7 +145,7 @@ Yours openEuler-Advisor. ...@@ -145,7 +145,7 @@ Yours openEuler-Advisor.
except urllib.error.HTTPError: except urllib.error.HTTPError:
resp = "Not found" resp = "Not found"
if re.match("Not found", resp): if re.match("Not found", resp):
print("Cannot find upstream metadata") print("Cann't find yaml metadata for {package} from upstream-info.".format(package=pkg))
return False return False
else: else:
return resp return resp
......
...@@ -22,30 +22,26 @@ def _get_rec_excpt(): ...@@ -22,30 +22,26 @@ def _get_rec_excpt():
""" """
Get except case of version recommend Get except case of version recommend
""" """
y_file = open(os.getcwd() + "/helper/ver_rec_excpt.yaml") y_file = open(os.path.join(os.path.dirname(os.path.abspath(__file__)), "helper/ver_rec_excpt.yaml"))
excpt = yaml.load(y_file, Loader=yaml.Loader) excpt = yaml.load(y_file, Loader=yaml.Loader)
return excpt return excpt
def get_ver_tags(gt, repo, cwd_path=None):
def get_ver_tags(gt, repo, d_path=None):
""" """
Get version tags of given package Get version tags of given package
""" """
repo_yaml = "" repo_yaml = ""
if d_path: if cwd_path:
try: try:
repo_yaml = open(os.path.join(d_path, repo + ".yaml")).read() repo_yaml = open(os.path.join(cwd_path, repo + ".yaml")).read()
except FileNotFoundError: except FileNotFoundError:
print("Failed to get YAML info from default path.") print("Cann't find yaml metadata for {pkg} from current working directory.".format(pkg=repo))
if not repo_yaml:
try:
repo_yaml = gt.get_yaml(repo) repo_yaml = gt.get_yaml(repo)
except urllib.error.HTTPError:
print("Failed to get YAML info for {pkg}".format(pkg=repo))
return None
pkg_info = yaml.load(repo_yaml, Loader=yaml.Loader) if repo_yaml:
pkg_info = yaml.load(repo_yaml, Loader=yaml.Loader)
else:
return None
vc_type = pkg_info["version_control"] vc_type = pkg_info["version_control"]
if vc_type == "hg": if vc_type == "hg":
...@@ -65,7 +61,7 @@ def get_ver_tags(gt, repo, d_path=None): ...@@ -65,7 +61,7 @@ def get_ver_tags(gt, repo, d_path=None):
else: else:
print("Unsupport version control method {vc}".format(vc=vc_type)) print("Unsupport version control method {vc}".format(vc=vc_type))
return None return None
excpt_list = _get_rec_excpt() excpt_list = _get_rec_excpt()
if repo in excpt_list: if repo in excpt_list:
for excpt in excpt_list[repo]: for excpt in excpt_list[repo]:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册