aboutsummaryrefslogtreecommitdiff
path: root/app/tasks/importtasks.py
diff options
context:
space:
mode:
authorrubenwardy <rw@rubenwardy.com>2018-05-27 23:02:11 +0100
committerrubenwardy <rw@rubenwardy.com>2018-05-27 23:02:11 +0100
commitd0969263ba8a472cc5bdb712c6e255518e95a2f5 (patch)
tree7d065d10084e26ccf4ab7bbd5a909a15dcc5997c /app/tasks/importtasks.py
parentd046de8057d42d4653af6d7c6c7ff557319d1bae (diff)
downloadcheatdb-d0969263ba8a472cc5bdb712c6e255518e95a2f5.tar.xz
Fix crash due to remaining raise() in getDepends()
Diffstat (limited to 'app/tasks/importtasks.py')
-rw-r--r--app/tasks/importtasks.py82
1 files changed, 40 insertions, 42 deletions
diff --git a/app/tasks/importtasks.py b/app/tasks/importtasks.py
index 7ccd36c..cf07a47 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
-
- except HTTPError:
- print("mod.conf does not exist")
+ if not urlmaker.isValid():
+ return {}
- if "depends" in result or "optional_depends" in result:
- return result
+ #
+ # 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
+ except HTTPError:
+ print("mod.conf does not exist")
- #
- # 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)
+ if "depends" in result or "optional_depends" in result:
+ return result
- result["depends"] = ",".join(hard)
- result["optional_depends"] = ",".join(soft)
- except HTTPError:
- print("depends.txt does not exist")
- 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")
- else:
- print(TaskError("non-github depends detector not implemented yet!"))
- return {}
+ return result
def importDependencies(package, mpackage_cache):