diff options
author | 2016-11-10 11:09:42 +0200 | |
---|---|---|
committer | 2016-11-10 11:09:42 +0200 | |
commit | d584775a6820f23561c5b8922a46644920bbf2e6 (patch) | |
tree | 9d304f27ce03182a042da9dede114aeea7b0ab69 | |
parent | Add a full_name property to package and remove some debug spam on sync (diff) | |
download | grumpy-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.
-rw-r--r-- | backend/lib/sync.py | 12 | ||||
-rwxr-xr-x | manage.py | 2 |
2 files changed, 11 insertions, 3 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 @@ -36,12 +36,10 @@ def sync_packages(): """Synchronize only Gentoo packages base data (without details)""" sync.sync_packages() -''' @manager.command def sync_versions(): """Synchronize only Gentoo package details""" sync.sync_versions() -''' if __name__ == '__main__': manager.run() |