diff options
author | rubenwardy <rw@rubenwardy.com> | 2018-06-05 19:47:02 +0100 |
---|---|---|
committer | rubenwardy <rw@rubenwardy.com> | 2018-06-05 19:47:02 +0100 |
commit | 8d9da5a75034bc9af48a90294f5bec2776829a0f (patch) | |
tree | 10d3f41127758ace0d5af3f20fbabcc849761c90 /app/tasks/importtasks.py | |
parent | 9a36bb7d727585b023ae288451bb9b93729faaca (diff) | |
download | cheatdb-8d9da5a75034bc9af48a90294f5bec2776829a0f.tar.xz |
Make git error public, delete dir after clone
Diffstat (limited to 'app/tasks/importtasks.py')
-rw-r--r-- | app/tasks/importtasks.py | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/app/tasks/importtasks.py b/app/tasks/importtasks.py index c39a008..c2460d2 100644 --- a/app/tasks/importtasks.py +++ b/app/tasks/importtasks.py @@ -15,7 +15,8 @@ # along with this program. If not, see <https://www.gnu.org/licenses/>. -import flask, json, os, git, tempfile +import flask, json, os, git, tempfile, shutil +from git import GitCommandError from flask.ext.sqlalchemy import SQLAlchemy from urllib.error import HTTPError import urllib.request @@ -246,10 +247,23 @@ def getMeta(urlstr, author): url = urlparse(urlstr) gitDir = tempfile.gettempdir() + "/" + randomString(10) - git.Repo.clone_from(urlstr, gitDir, progress=None, env=None, depth=1) + + err = None + + try: + git.Repo.clone_from(urlstr, gitDir, progress=None, env=None, depth=1) + except GitCommandError as e: + err = e.stderr + + if err is not None: + raise TaskError(err.replace("stderr: ", "") \ + .replace("Cloning into '" + gitDir + "'...", "") \ + .strip()) tree = PackageTreeNode(gitDir, author=author, repo=urlstr) + shutil.rmtree(gitDir) + result = {} result["name"] = tree.name result["provides"] = tree.fold("name") |