diff options
author | 2016-12-05 19:44:25 +0200 | |
---|---|---|
committer | 2016-12-05 19:44:25 +0200 | |
commit | 8c264ac120faebd8463f9b6fadde65f40df2ddb0 (patch) | |
tree | d985db9f63d5c98efaa3b699472ca16aa94b0b75 | |
parent | sync: use requests response.json() directly instead of json.loads (diff) | |
download | grumpy-8c264ac120faebd8463f9b6fadde65f40df2ddb0.tar.gz grumpy-8c264ac120faebd8463f9b6fadde65f40df2ddb0.tar.bz2 grumpy-8c264ac120faebd8463f9b6fadde65f40df2ddb0.zip |
sync: return empty dict on projects retrieval error, so the caller won't error
-rw-r--r-- | backend/lib/sync.py | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/backend/lib/sync.py b/backend/lib/sync.py index 2d6244c..e53fa9b 100644 --- a/backend/lib/sync.py +++ b/backend/lib/sync.py @@ -8,16 +8,16 @@ pkg_url_base = "https://packages.gentoo.org/" http_session = requests.session() def get_project_data(): + projects = {} data = http_session.get(proj_url) if not data: print("Failed retrieving projects.xml") - return + return projects root = ET.fromstring(data.content) - projects = {} # Parsing is based on http://www.gentoo.org/dtd/projects.dtd as of 2016-11-10 if root.tag.lower() != 'projects': print("Downloaded projects.xml root tag isn't 'projects'") - return + return projects for proj_elem in root: if proj_elem.tag.lower() != 'project': print("Skipping unknown <projects> subtag <%s>" % proj_elem.tag) |