aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMart Raudsepp <leio@gentoo.org>2016-11-10 11:09:42 +0200
committerMart Raudsepp <leio@gentoo.org>2016-11-10 11:09:42 +0200
commitd584775a6820f23561c5b8922a46644920bbf2e6 (patch)
tree9d304f27ce03182a042da9dede114aeea7b0ab69 /backend
parentAdd a full_name property to package and remove some debug spam on sync (diff)
downloadgrumpy-d584775a6820f23561c5b8922a46644920bbf2e6.tar.gz
grumpy-d584775a6820f23561c5b8922a46644920bbf2e6.tar.bz2
grumpy-d584775a6820f23561c5b8922a46644920bbf2e6.zip
Add dirty sync_versions debug code
This just prints the first packages versions JSON data out and exits, so just some initial debug code out of the way to sync in projects.xml first, as sync_versions will need to reference projects and maintainers, so better to finish projects.xml sync first.
Diffstat (limited to 'backend')
-rw-r--r--backend/lib/sync.py12
1 files changed, 11 insertions, 1 deletions
diff --git a/backend/lib/sync.py b/backend/lib/sync.py
index a6aef23..ce54937 100644
--- a/backend/lib/sync.py
+++ b/backend/lib/sync.py
@@ -1,7 +1,7 @@
from flask import json
import requests
from .. import app, db
-from .models import Category, Package
+from .models import Category, Package, PackageVersion
url_base = "https://packages.gentoo.org/"
http_session = requests.session()
@@ -42,3 +42,13 @@ def sync_packages():
new_pkg = Package(category_id=category.id, name=package['name'])
db.session.add(new_pkg)
db.session.commit()
+
+def sync_versions():
+ for package in Package.query.all():
+ data = http_session.get(url_base + "packages/" + package.full_name + ".json")
+ if not data:
+ print("No JSON data for package %s" % package.full_name) # FIXME: Handle better; e.g mark the package as removed if no pkgmove update
+ continue
+ from pprint import pprint
+ pprint(json.loads(data.text))
+ break