From d0969263ba8a472cc5bdb712c6e255518e95a2f5 Mon Sep 17 00:00:00 2001 From: rubenwardy Date: Sun, 27 May 2018 23:02:11 +0100 Subject: [PATCH] Fix crash due to remaining raise() in getDepends() --- app/tasks/importtasks.py | 84 ++++++++++++++++++++-------------------- 1 file changed, 41 insertions(+), 43 deletions(-) diff --git a/app/tasks/importtasks.py b/app/tasks/importtasks.py index 7ccd36c5..cf07a475 100644 --- a/app/tasks/importtasks.py +++ b/app/tasks/importtasks.py @@ -299,56 +299,54 @@ def getDepends(package): if url.netloc == "github.com": urlmaker = GithubURLMaker(url) else: - raise TaskError("Unsupported repo") + return {} result = {} - if urlmaker.isValid(): - # - # Try getting depends on mod.conf - # - try: - contents = urllib.request.urlopen(urlmaker.getModConfURL()).read().decode("utf-8") - conf = parseConf(contents) - for key in ["depends", "optional_depends"]: - try: - result[key] = conf[key] - except KeyError: - pass + if not urlmaker.isValid(): + return {} - except HTTPError: - print("mod.conf does not exist") + # + # Try getting depends on mod.conf + # + try: + contents = urllib.request.urlopen(urlmaker.getModConfURL()).read().decode("utf-8") + conf = parseConf(contents) + for key in ["depends", "optional_depends"]: + try: + result[key] = conf[key] + except KeyError: + pass - if "depends" in result or "optional_depends" in result: - return result - - - # - # Try depends.txt - # - import re - pattern = re.compile("^([a-z0-9_]+)\??$") - try: - contents = urllib.request.urlopen(urlmaker.getDependsURL()).read().decode("utf-8") - soft = [] - hard = [] - for line in contents.split("\n"): - line = line.strip() - if pattern.match(line): - if line[len(line) - 1] == "?": - soft.append( line[:-1]) - else: - hard.append(line) - - result["depends"] = ",".join(hard) - result["optional_depends"] = ",".join(soft) - except HTTPError: - print("depends.txt does not exist") + except HTTPError: + print("mod.conf does not exist") + if "depends" in result or "optional_depends" in result: return result - else: - print(TaskError("non-github depends detector not implemented yet!")) - return {} + + # + # Try depends.txt + # + import re + pattern = re.compile("^([a-z0-9_]+)\??$") + try: + contents = urllib.request.urlopen(urlmaker.getDependsURL()).read().decode("utf-8") + soft = [] + hard = [] + for line in contents.split("\n"): + line = line.strip() + if pattern.match(line): + if line[len(line) - 1] == "?": + soft.append( line[:-1]) + else: + hard.append(line) + + result["depends"] = ",".join(hard) + result["optional_depends"] = ",".join(soft) + except HTTPError: + print("depends.txt does not exist") + + return result def importDependencies(package, mpackage_cache):