commit:     d584775a6820f23561c5b8922a46644920bbf2e6
Author:     Mart Raudsepp <leio <AT> gentoo <DOT> org>
AuthorDate: Thu Nov 10 09:09:42 2016 +0000
Commit:     Mart Raudsepp <leio <AT> gentoo <DOT> org>
CommitDate: Thu Nov 10 09:09:42 2016 +0000
URL:        https://gitweb.gentoo.org/proj/grumpy.git/commit/?id=d584775a

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.

 backend/lib/sync.py | 12 +++++++++++-
 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

diff --git a/manage.py b/manage.py
index 4634518..359c63a 100755
--- a/manage.py
+++ b/manage.py
@@ -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()

Reply via email to