#374 Get rid of calls to pkgdb
Merged 6 years ago by abompard. Opened 6 years ago by abompard.
abompard/fedora-hubs pagure-dist-git  into  develop

file modified
+3 -3
@@ -13,10 +13,10 @@ 

  .. automodule:: hubs.utils.cache

     :members:

  

- Packages database utils

- -----------------------

+ Package database utils

+ ----------------------

  

- .. automodule:: hubs.utils.pkgdb

+ .. automodule:: hubs.utils.packages

     :members:

  

  Datagrepper utils

file modified
-1
@@ -71,6 +71,5 @@ 

      'hubs.widgets.stats:Stats',

      'hubs.widgets.sticky:Sticky',

      'hubs.widgets.subscriptions:Subscriptions',

-     'hubs.widgets.workflow.pendingacls:PendingACLs',

      'hubs.widgets.workflow.updates2stable:Updates2Stable',

      ]

file modified
-6
@@ -46,12 +46,6 @@ 

          }))

      hub.widgets.append(widget)

      widget = hubs.models.Widget(

-         plugin='workflow.pendingacls', index=2,

-         _config=json.dumps({

-             'username': username,

-         }))

-     hub.widgets.append(widget)

-     widget = hubs.models.Widget(

          plugin='subscriptions', index=3,

          _config=json.dumps({

              'username': username,

hubs/tests/utils/test_packages.py hubs/tests/utils/test_pkgdb.py
file renamed
+29 -14
@@ -6,13 +6,13 @@ 

  

  from hubs.tests import APPTest

  from hubs.utils.cache import cache

- from hubs.utils.pkgdb import get_owned_packages

+ from hubs.utils.packages import get_user_packages

  

  

- class PkgdbUtilsTest(APPTest):

+ class PackageUtilsTest(APPTest):

  

      def setUp(self):

-         super(PkgdbUtilsTest, self).setUp()

+         super(PackageUtilsTest, self).setUp()

          # Use a memory backend, not the default null backend, or we can't test

          # the caching feature.

          cache.configure(backend='dogpile.cache.memory',
@@ -23,28 +23,43 @@ 

          result = cache.get(b"owned_packages:abompard", ignore_expiration=True)

          return not isinstance(result, dogpile.cache.api.NoValue)

  

-     def test_get_owned_packages(self):

-         pkgs = get_owned_packages("abompard", use_cache=False)

-         self.assertEqual(len(pkgs), 42)  # not kidding! :-)

+     def test_get_user_packages(self):

+         pkgs = get_user_packages("abompard", use_cache=False)

+         self.assertEqual(len(pkgs), 280)

          for pkg in pkgs:

              self.assertEqual(type(pkg), type(""))

          self.assertFalse(self._is_cached())

  

-     def test_get_owned_packages_invalid(self):

-         pkgs = get_owned_packages("abompard", use_cache=False)

+     def test_get_user_packages_owned(self):

+         pkgs = get_user_packages("abompard", only_owned=True, use_cache=False)

+         self.assertEqual(len(pkgs), 18)

+         for pkg in pkgs:

+             self.assertEqual(type(pkg), type(""))

+         self.assertFalse(self._is_cached())

+ 

+     @patch("hubs.utils.packages.requests")

+     def test_get_user_packages_invalid(self, requests):

+         response = Mock()

+         response.json.side_effect = ValueError("invalid value")

+         requests.get.return_value = response

+         pkgs = get_user_packages("abompard", use_cache=False)

          self.assertListEqual(pkgs, [])

  

-     @patch("hubs.utils.pkgdb.requests")

-     def test_get_owned_packages_cache(self, requests):

+     @patch("hubs.utils.packages.requests")

+     def test_get_user_packages_cache(self, requests):

          response = Mock()

          response.json.return_value = {

-             "point of contact": [],

-             "co-maintained": [],

+             "forks": [],

+             "repos": [],

+             "user": {

+                 "name": "abompard",

+                 "fullname": "abompard",

+             },

          }

          requests.get.return_value = response

-         get_owned_packages("abompard", use_cache=True)

+         get_user_packages("abompard", use_cache=True)

          self.assertTrue(self._is_cached())

          self.assertEqual(requests.get.call_count, 1)

-         get_owned_packages("abompard", use_cache=True)

+         get_user_packages("abompard", use_cache=True)

          self.assertTrue(self._is_cached())

          self.assertEqual(requests.get.call_count, 1)

@@ -43,8 +43,8 @@ 

          self.assertListEqual(

              [w.plugin for w in widgets["right"]],

              ['contact', 'meetings', 'fedmsgstats', 'workflow.updates2stable',

-              'workflow.pendingacls', 'subscriptions', 'badges', 'pagure_pr',

-              'github_pr', 'bugzilla', 'halp', 'about']

+              'subscriptions', 'badges', 'pagure_pr', 'github_pr', 'bugzilla',

+              'halp', 'about']

              )

  

      def test_get_visible_widgets_preview(self):

@@ -1,451 +0,0 @@ 

- interactions:

- - request:

-     body: null

-     headers:

-       Accept: ['*/*']

-       Accept-Encoding: ['gzip, deflate']

-       Connection: [keep-alive]

-       User-Agent: [python-requests/2.13.0]

-     method: GET

-     uri: https://admin.fedoraproject.org/pkgdb/api/packager/package/abompard

-   response:

-     body: {string: "{\n  \"co-maintained\": [\n    {\n      \"acls\": [],\n      \"\

-         creation_date\": 1430239258.0,\n      \"description\": \"contextlib2 is a\

-         \ backport of the standard library's contextlib module to\\nearlier Python\

-         \ versions.\\n\\nIt also serves as a real world proving ground for possible\

-         \ future\\nenhancements to the standard library version.\",\n      \"koschei_monitor\"\

-         : false,\n      \"monitor\": true,\n      \"name\": \"python-contextlib2\"\

-         ,\n      \"namespace\": \"rpms\",\n      \"review_url\": \"https://bugzilla.redhat.com/1210978\"\

-         ,\n      \"status\": \"Approved\",\n      \"summary\": \"Backports and enhancements\

-         \ for the contextlib module\",\n      \"upstream_url\": \"https://pypi.io/project/contextlib2\"\

-         \n    },\n    {\n      \"acls\": [],\n      \"creation_date\": 1400070978.0,\n\

-         \      \"description\": \"This is a lib package for use by pytest-cov, nose-cov\

-         \ and nose2-cov. If\\nyou're developing a coverage plugin for a test framework\

-         \ then you probably\\nwant one of those.\",\n      \"koschei_monitor\": false,\n\

-         \      \"monitor\": false,\n      \"name\": \"python-cov-core\",\n      \"\

-         namespace\": \"rpms\",\n      \"review_url\": null,\n      \"status\": \"\

-         Approved\",\n      \"summary\": \"Plugin core for use by pytest-cov, nose-cov\

-         \ and nose2-cov\",\n      \"upstream_url\": \"http://bitbucket.org/memedough/cov-core/overview\"\

-         \n    },\n    {\n      \"acls\": [],\n      \"creation_date\": 1400070978.0,\n\

-         \      \"description\": \"Coverage.py is a Python module that measures code\

-         \ coverage during Python\\nexecution. It uses the code analysis tools and\

-         \ tracing hooks provided in the\\nPython standard library to determine which\

-         \ lines are executable, and which\\nhave been executed.\",\n      \"koschei_monitor\"\

-         : false,\n      \"monitor\": true,\n      \"name\": \"python-coverage\",\n\

-         \      \"namespace\": \"rpms\",\n      \"review_url\": null,\n      \"status\"\

-         : \"Approved\",\n      \"summary\": \"Code coverage testing module for Python\"\

-         ,\n      \"upstream_url\": \"http://nedbatchelder.com/code/modules/coverage.html\"\

-         \n    },\n    {\n      \"acls\": [],\n      \"creation_date\": 1437659169.0,\n\

-         \      \"description\": \"DDT (Data-Driven Tests) allows you to multiply one\

-         \ test case by running it with\\ndifferent test data, and make it appear as\

-         \ multiple test cases. It is used in\\ncombination with other testing frameworks\

-         \ like unittest and nose.\",\n      \"koschei_monitor\": true,\n      \"monitor\"\

-         : true,\n      \"name\": \"python-ddt\",\n      \"namespace\": \"rpms\",\n\

-         \      \"review_url\": \"https://bugzilla.redhat.com/1244014\",\n      \"\

-         status\": \"Approved\",\n      \"summary\": \"Python library to multiply test\

-         \ cases\",\n      \"upstream_url\": \"https://github.com/txels/ddt\"\n   \

-         \ },\n    {\n      \"acls\": [],\n      \"creation_date\": 1400070978.0,\n\

-         \      \"description\": \"Falcon is a high-performance Python framework for\

-         \ building cloud APIs.\\nIt encourages the REST architectural style, and tries\

-         \ to do as little as\\npossible while remaining highly effective.\",\n   \

-         \   \"koschei_monitor\": false,\n      \"monitor\": true,\n      \"name\"\

-         : \"python-falcon\",\n      \"namespace\": \"rpms\",\n      \"review_url\"\

-         : null,\n      \"status\": \"Approved\",\n      \"summary\": \"An unladen\

-         \ web framework for building APIs and app backends\",\n      \"upstream_url\"\

-         : \"https://falconframework.org\"\n    },\n    {\n      \"acls\": [],\n  \

-         \    \"creation_date\": 1400070978.0,\n      \"description\": \"A comprehensive\

-         \ HTTP client library that supports many features left out of\\nother HTTP\

-         \ libraries.\",\n      \"koschei_monitor\": false,\n      \"monitor\": true,\n\

-         \      \"name\": \"python-httplib2\",\n      \"namespace\": \"rpms\",\n  \

-         \    \"review_url\": null,\n      \"status\": \"Approved\",\n      \"summary\"\

-         : \"A comprehensive HTTP client library\",\n      \"upstream_url\": \"https://pypi.python.org/pypi/httplib2\"\

-         \n    },\n    {\n      \"acls\": [],\n      \"creation_date\": 1400070978.0,\n\

-         \      \"description\": \"This module provides basic functions for parsing\

-         \ mime-type names\\nand matching them against a list of media-ranges.\",\n\

-         \      \"koschei_monitor\": false,\n      \"monitor\": false,\n      \"name\"\

-         : \"python-mimeparse\",\n      \"namespace\": \"rpms\",\n      \"review_url\"\

-         : null,\n      \"status\": \"Approved\",\n      \"summary\": \"Python module\

-         \ for parsing mime-type names\",\n      \"upstream_url\": \"https://github.com/dbtsai/python-mimeparse\"\

-         \n    },\n    {\n      \"acls\": [],\n      \"creation_date\": 1400070978.0,\n\

-         \      \"description\": \"Passlib is a password hashing library for Python\

-         \ 2 & 3, which provides\\ncross-platform implementations of over 20 password\

-         \ hashing algorithms,\\nas well as a framework for managing existing password\

-         \ hashes. It's\\ndesigned to be useful for a wide range of tasks, from verifying\

-         \ a hash\\nfound in /etc/shadow, to providing full-strength password hashing\

-         \ for\\nmulti-user application.\",\n      \"koschei_monitor\": false,\n  \

-         \    \"monitor\": true,\n      \"name\": \"python-passlib\",\n      \"namespace\"\

-         : \"rpms\",\n      \"review_url\": null,\n      \"status\": \"Approved\",\n\

-         \      \"summary\": \"Comprehensive password hashing framework supporting\

-         \ over 20 schemes\",\n      \"upstream_url\": \"https://bitbucket.org/ecollins/passlib\"\

-         \n    },\n    {\n      \"acls\": [],\n      \"creation_date\": 1462278195.0,\n\

-         \      \"description\": \"A fork of SocksiPy with bug fixes and extra features.\\\

-         n\\nActs as a drop-in replacement to the socket module. Featuring:\\n\\n-\

-         \ SOCKS proxy client for Python 2.6 - 3.x\\n- TCP and UDP both supported\\\

-         n- HTTP proxy client included but not supported or recommended (you should\

-         \ use\\n  urllib2's or requests' own HTTP proxy interface)\\n- urllib2 handler\

-         \ included.\",\n      \"koschei_monitor\": true,\n      \"monitor\": \"nobuild\"\

-         ,\n      \"name\": \"python-pysocks\",\n      \"namespace\": \"rpms\",\n \

-         \     \"review_url\": \"https://bugzilla.redhat.com/1332206\",\n      \"status\"\

-         : \"Approved\",\n      \"summary\": \"A Python SOCKS client module\",\n  \

-         \    \"upstream_url\": \"https://github.com/Anorov/PySocks\"\n    },\n   \

-         \ {\n      \"acls\": [],\n      \"creation_date\": 1400070978.0,\n      \"\

-         description\": \"testtools is a set of extensions to the Python standard library's\

-         \ unit testing\\nframework.\",\n      \"koschei_monitor\": false,\n      \"\

-         monitor\": true,\n      \"name\": \"python-testtools\",\n      \"namespace\"\

-         : \"rpms\",\n      \"review_url\": null,\n      \"status\": \"Approved\",\n\

-         \      \"summary\": \"Extensions to the Python unit testing framework\",\n\

-         \      \"upstream_url\": \"https://launchpad.net/testtools\"\n    },\n   \

-         \ {\n      \"acls\": [],\n      \"creation_date\": 1400070978.0,\n      \"\

-         description\": \"This package represents the core of the Zope Component Architecture.\\\

-         nTogether with the 'zope.interface' package, it provides facilities for\\\

-         ndefining, registering and looking up components.\",\n      \"koschei_monitor\"\

-         : false,\n      \"monitor\": true,\n      \"name\": \"python-zope-component\"\

-         ,\n      \"namespace\": \"rpms\",\n      \"review_url\": null,\n      \"status\"\

-         : \"Approved\",\n      \"summary\": \"Zope Component Architecture\",\n   \

-         \   \"upstream_url\": \"https://pypi.io/project/zope.component\"\n    },\n\

-         \    {\n      \"acls\": [],\n      \"creation_date\": 1400070978.0,\n    \

-         \  \"description\": \"The zope configuration system provides an extensible\

-         \ system for supporting\\nvarious kinds of configurations.\\n\\nIt is based\

-         \ on the idea of configuration directives. Users of the configuration\\nsystem\

-         \ provide configuration directives in some language that express\\nconfiguration\

-         \ choices. The intent is that the language be pluggable. An XML\\nlanguage\

-         \ is provided by default.\",\n      \"koschei_monitor\": true,\n      \"monitor\"\

-         : true,\n      \"name\": \"python-zope-configuration\",\n      \"namespace\"\

-         : \"rpms\",\n      \"review_url\": null,\n      \"status\": \"Approved\",\n\

-         \      \"summary\": \"Zope Configuration Markup Language (ZCML)\",\n     \

-         \ \"upstream_url\": \"https://github.com/zopefoundation/zope.configuration\"\

-         \n    },\n    {\n      \"acls\": [],\n      \"creation_date\": 1400070978.0,\n\

-         \      \"description\": \"The zope.event package provides a simple event system.\

-         \ It provides\\nan event publishing system and a very simple event-dispatching\

-         \ system\\non which more sophisticated event dispatching systems can be built.\\\

-         n(For example, a type-based event dispatching system that builds on\\nzope.event\

-         \ can be found in zope.component.)\",\n      \"koschei_monitor\": false,\n\

-         \      \"monitor\": true,\n      \"name\": \"python-zope-event\",\n      \"\

-         namespace\": \"rpms\",\n      \"review_url\": null,\n      \"status\": \"\

-         Approved\",\n      \"summary\": \"Zope Event Publication\",\n      \"upstream_url\"\

-         : \"http://pypi.python.org/pypi/zope.event/\"\n    },\n    {\n      \"acls\"\

-         : [],\n      \"creation_date\": 1400070978.0,\n      \"description\": \"This\

-         \ package contains exception interfaces and implementations which are so\\\

-         ngeneral purpose that they don't belong in Zope application-specific packages.\"\

-         ,\n      \"koschei_monitor\": false,\n      \"monitor\": true,\n      \"name\"\

-         : \"python-zope-exceptions\",\n      \"namespace\": \"rpms\",\n      \"review_url\"\

-         : null,\n      \"status\": \"Approved\",\n      \"summary\": \"Zope Exceptions\"\

-         ,\n      \"upstream_url\": \"http://pypi.python.org/pypi/zope.exceptions\"\

-         \n    },\n    {\n      \"acls\": [],\n      \"creation_date\": 1400070978.0,\n\

-         \      \"description\": \"This module provides message identifiers for internationalization.\"\

-         ,\n      \"koschei_monitor\": false,\n      \"monitor\": true,\n      \"name\"\

-         : \"python-zope-i18nmessageid\",\n      \"namespace\": \"rpms\",\n      \"\

-         review_url\": null,\n      \"status\": \"Approved\",\n      \"summary\": \"\

-         Message Identifiers for internationalization\",\n      \"upstream_url\": \"\

-         http://pypi.python.org/pypi/zope.i18nmessageid\"\n    },\n    {\n      \"\

-         acls\": [],\n      \"creation_date\": 1400070978.0,\n      \"description\"\

-         : \"This package is a zope.interface extension for defining data schemas.\"\

-         ,\n      \"koschei_monitor\": false,\n      \"monitor\": true,\n      \"name\"\

-         : \"python-zope-schema\",\n      \"namespace\": \"rpms\",\n      \"review_url\"\

-         : null,\n      \"status\": \"Approved\",\n      \"summary\": \"Zope 3 schemas\"\

-         ,\n      \"upstream_url\": \"http://pypi.python.org/pypi/zope.schema\"\n \

-         \   },\n    {\n      \"acls\": [],\n      \"creation_date\": 1400070978.0,\n\

-         \      \"description\": \"This package provides a number of testing frameworks.\

-         \ It includes a\\nflexible test runner, and supports both doctest and unittest.\"\

-         ,\n      \"koschei_monitor\": false,\n      \"monitor\": true,\n      \"name\"\

-         : \"python-zope-testing\",\n      \"namespace\": \"rpms\",\n      \"review_url\"\

-         : null,\n      \"status\": \"Approved\",\n      \"summary\": \"Zope Testing\

-         \ Framework\",\n      \"upstream_url\": \"https://pypi.io/project/zope.testing\"\

-         \n    }\n  ],\n  \"output\": \"ok\",\n  \"point of contact\": [\n    {\n \

-         \     \"acls\": [],\n      \"creation_date\": 1400070978.0,\n      \"description\"\

-         : \"Grisbi is a very functional personal financial management program\\nwith\

-         \ a lot of features: checking, cash and liabilities accounts,\\nseveral accounts\

-         \ with automatic contra entries, several currencies,\\nincluding euro, arbitrary\

-         \ currency for every operation, money\\ninterchange fees, switch to euro account\

-         \ per account, description\\nof the transactions with third parties, categories,\

-         \ sub-categories,\\nfinancial year, notes, breakdown, transfers between accounts,\

-         \ even\\nfor accounts of different currencies, bank reconciliation, scheduled\\\

-         ntransactions, automatic recall of last transaction for every third\\nparty,\

-         \ nice and easy user interface, user manual, QIF import/export.\",\n     \

-         \ \"koschei_monitor\": false,\n      \"monitor\": false,\n      \"name\":\

-         \ \"grisbi\",\n      \"namespace\": \"rpms\",\n      \"review_url\": null,\n\

-         \      \"status\": \"Approved\",\n      \"summary\": \"Personal finances manager\"\

-         ,\n      \"upstream_url\": \"http://www.grisbi.org\"\n    },\n    {\n    \

-         \  \"acls\": [],\n      \"creation_date\": 1400070978.0,\n      \"description\"\

-         : \"KeePassX is an application for people with extremly high demands on secure\\\

-         npersonal data management.\\nKeePassX saves many different information e.g.\

-         \ user names, passwords, urls,\\nattachemts and comments in one single database.\

-         \ For a better management\\nuser-defined titles and icons can be specified\

-         \ for each single entry.\\nFurthermore the entries are sorted in groups, which\

-         \ are customizable as well.\\nThe integrated search function allows to search\

-         \ in a single group or the\\ncomplete database.\\nKeePassX offers a little\

-         \ utility for secure password generation. The password\\ngenerator is very\

-         \ customizable, fast and easy to use. Especially someone who\\ngenerates passwords\

-         \ frequently will appreciate this feature.\\nThe complete database is always\

-         \ encrypted either with AES (alias Rijndael) or\\nTwofish encryption algorithm\

-         \ using a 256 bit key. Therefore the saved\\ninformation can be considered\

-         \ as quite safe. KeePassX uses a database format\\nthat is compatible with\

-         \ KeePass Password Safe v2 for MS Windows.\",\n      \"koschei_monitor\":\

-         \ false,\n      \"monitor\": false,\n      \"name\": \"keepassx\",\n     \

-         \ \"namespace\": \"rpms\",\n      \"review_url\": null,\n      \"status\"\

-         : \"Approved\",\n      \"summary\": \"Cross-platform password manager\",\n\

-         \      \"upstream_url\": \"http://www.keepassx.org/\"\n    },\n    {\n   \

-         \   \"acls\": [],\n      \"creation_date\": 1400070978.0,\n      \"description\"\

-         : \"A ssh-add helper that uses kwallet and kpassworddialog.\",\n      \"koschei_monitor\"\

-         : false,\n      \"monitor\": true,\n      \"name\": \"ksshaskpass\",\n   \

-         \   \"namespace\": \"rpms\",\n      \"review_url\": null,\n      \"status\"\

-         : \"Approved\",\n      \"summary\": \"A ssh-add helper that uses kwallet and\

-         \ kpassworddialog\",\n      \"upstream_url\": \"https://cgit.kde.org/ksshaskpass.git\"\

-         \n    },\n    {\n      \"acls\": [],\n      \"creation_date\": 1474548104.0,\n\

-         \      \"description\": \"Libsass is a C/C++ port of the Sass CSS precompiler.\

-         \ The original version was\\nwritten in Ruby, but this version is meant for\

-         \ efficiency and portability.\\n\\nThis library strives to be light, simple,\

-         \ and easy to build and integrate with\\na variety of platforms and languages.\\\

-         n\\nLibsass is just a library, but if you want to RUN libsass, install the\

-         \ sassc\\npackage.\",\n      \"koschei_monitor\": true,\n      \"monitor\"\

-         : true,\n      \"name\": \"libsass\",\n      \"namespace\": \"rpms\",\n  \

-         \    \"review_url\": \"https://bugzilla.redhat.com/1369534\",\n      \"status\"\

-         : \"Approved\",\n      \"summary\": \"C/C++ port of the Sass CSS precompiler\"\

-         ,\n      \"upstream_url\": \"http://sass-lang.com/libsass\"\n    },\n    {\n\

-         \      \"acls\": [],\n      \"creation_date\": 1496666386.0,\n      \"description\"\

-         : \"This is a server for SMTP and related protocols, similar in utility\\\

-         r\\nto the standard library\\u2019s smtpd.py module, but rewritten to be based\\\

-         r\\non asyncio for Python 3.\",\n      \"koschei_monitor\": true,\n      \"\

-         monitor\": true,\n      \"name\": \"python-aiosmtpd\",\n      \"namespace\"\

-         : \"rpms\",\n      \"review_url\": \"https://bugzilla.redhat.com/1404883\"\

-         ,\n      \"status\": \"Approved\",\n      \"summary\": \"Asyncio-based SMTP\

-         \ server\",\n      \"upstream_url\": \"https://github.com/aio-libs/aiosmtpd\"\

-         \n    },\n    {\n      \"acls\": [],\n      \"creation_date\": 1496666324.0,\n\

-         \      \"description\": \"This is a very simple decorator and function which\

-         \ populates a \\r\\nmodule's __all__ and optionally the module globals. \\\

-         r\\nThis provides both a pure-Python implementation and a C implementation.\

-         \ \\r\\nIt is proposed that the C implementation be added to built-ins for\

-         \ \\r\\nPython 3.6.\",\n      \"koschei_monitor\": true,\n      \"monitor\"\

-         : true,\n      \"name\": \"python-atpublic\",\n      \"namespace\": \"rpms\"\

-         ,\n      \"review_url\": \"https://bugzilla.redhat.com/1404882\",\n      \"\

-         status\": \"Approved\",\n      \"summary\": \"Decorator for populating a Python\

-         \ module's __all__\",\n      \"upstream_url\": \"http://public.readthedocs.io\"\

-         \n    },\n    {\n      \"acls\": [],\n      \"creation_date\": 1496666808.0,\n\

-         \      \"description\": \"Blessed is a thin, practical wrapper around terminal\

-         \ styling, screen\\r\\npositioning, and keyboard input.\",\n      \"koschei_monitor\"\

-         : true,\n      \"monitor\": true,\n      \"name\": \"python-blessed\",\n \

-         \     \"namespace\": \"rpms\",\n      \"review_url\": \"https://bugzilla.redhat.com/1435986\"\

-         ,\n      \"status\": \"Approved\",\n      \"summary\": \"A thin, practical\

-         \ wrapper around terminal capabilities in Python\",\n      \"upstream_url\"\

-         : \"https://pypi.python.org/pypi/blessed\"\n    },\n    {\n      \"acls\"\

-         : [],\n      \"creation_date\": 1476188786.0,\n      \"description\": \"The\

-         \ flufl.bounce library provides a set of heuristics and an API for\\ndetecting\

-         \ the original bouncing email addresses from a bounce message.  Many\\nformats\

-         \ found in the wild are supported, as are VERP and RFC 3464 (DSN).\",\n  \

-         \    \"koschei_monitor\": true,\n      \"monitor\": true,\n      \"name\"\

-         : \"python-flufl-bounce\",\n      \"namespace\": \"rpms\",\n      \"review_url\"\

-         : \"https://bugzilla.redhat.com/1375999\",\n      \"status\": \"Approved\"\

-         ,\n      \"summary\": \"Email bounce detectors\",\n      \"upstream_url\"\

-         : \"https://gitlab.com/warsaw/flufl.bounce\"\n    },\n    {\n      \"acls\"\

-         : [],\n      \"creation_date\": 1476188935.0,\n      \"description\": \"The\

-         \ ``flufl.i18n`` library provides a convenient API for managing translation\\\

-         ncontexts in Python applications. It provides facilities not only for\\nsingle-context\

-         \ applications like command line scripts, but also more\\nsophisticated management\

-         \ of multiple-context applications such as Internet\\nservers.\",\n      \"\

-         koschei_monitor\": true,\n      \"monitor\": true,\n      \"name\": \"python-flufl-i18n\"\

-         ,\n      \"namespace\": \"rpms\",\n      \"review_url\": \"https://bugzilla.redhat.com/1375993\"\

-         ,\n      \"status\": \"Approved\",\n      \"summary\": \"A high level API\

-         \ for Python internationalization\",\n      \"upstream_url\": \"https://gitlab.com/warsaw/flufl.i18n\"\

-         \n    },\n    {\n      \"acls\": [],\n      \"creation_date\": 1476188827.0,\n\

-         \      \"description\": \"The flufl.lock library provides an NFS-safe file-based\

-         \ locking algorithm\\ninfluenced by the GNU/Linux \\\"open(2)\\\" man page,\

-         \ under the description of\\nthe \\\"O_EXCL\\\" option.\",\n      \"koschei_monitor\"\

-         : true,\n      \"monitor\": true,\n      \"name\": \"python-flufl-lock\",\n\

-         \      \"namespace\": \"rpms\",\n      \"review_url\": \"https://bugzilla.redhat.com/1376001\"\

-         ,\n      \"status\": \"Approved\",\n      \"summary\": \"NFS-safe file locking\

-         \ with timeouts for POSIX systems\",\n      \"upstream_url\": \"https://gitlab.com/warsaw/flufl.lock\"\

-         \n    },\n    {\n      \"acls\": [],\n      \"creation_date\": 1481720827.0,\n\

-         \      \"description\": \"This package contains a small collection of test\

-         \ helpers that Barry Warsaw\\nuses in almost all his packages. Specifically,\

-         \ plugins for the following\\ntest tools are provided:\\n- nose2\\n- flake8\\\

-         nPython 3.4 is the minimum supported version.\",\n      \"koschei_monitor\"\

-         : true,\n      \"monitor\": true,\n      \"name\": \"python-flufl-testing\"\

-         ,\n      \"namespace\": \"rpms\",\n      \"review_url\": \"https://bugzilla.redhat.com/1401582\"\

-         ,\n      \"status\": \"Approved\",\n      \"summary\": \"Small collection\

-         \ of test tool plugins\",\n      \"upstream_url\": \"https://gitlab.com/warsaw/flufl.testing\"\

-         \n    },\n    {\n      \"acls\": [],\n      \"creation_date\": 1481720722.0,\n\

-         \      \"description\": \"The LAZR config system is typically used to manage\

-         \ process configuration.\\nProcess configuration is for saying how things\

-         \ change when we run systems on\\ndifferent machines, or under different circumstances.\\\

-         n\\nThis system uses ini-like file format of section, keys, and values. The\

-         \ config\\nfile supports inheritance to minimize duplication of information\

-         \ across files.\\nThe format supports schema validation.\",\n      \"koschei_monitor\"\

-         : true,\n      \"monitor\": true,\n      \"name\": \"python-lazr-config\"\

-         ,\n      \"namespace\": \"rpms\",\n      \"review_url\": \"https://bugzilla.redhat.com/1387518\"\

-         ,\n      \"status\": \"Approved\",\n      \"summary\": \"Create configuration\

-         \ schemas, and process and validate configurations\",\n      \"upstream_url\"\

-         : \"https://launchpad.net/lazr.config\"\n    },\n    {\n      \"acls\": [],\n\

-         \      \"creation_date\": 1477410675.0,\n      \"description\": \"The lazr.delegates\

-         \ package makes it easy to write objects that delegate\\nbehavior to another\

-         \ object. The new object adds some property or behavior on\\nto the other\

-         \ object, while still providing the underlying interface, and\\ndelegating\

-         \ behavior.\",\n      \"koschei_monitor\": true,\n      \"monitor\": true,\n\

-         \      \"name\": \"python-lazr-delegates\",\n      \"namespace\": \"rpms\"\

-         ,\n      \"review_url\": \"https://bugzilla.redhat.com/1387291\",\n      \"\

-         status\": \"Approved\",\n      \"summary\": \"Easily write objects that delegate\

-         \ behavior\",\n      \"upstream_url\": \"https://launchpad.net/lazr.delegates\"\

-         \n    },\n    {\n      \"acls\": [],\n      \"creation_date\": 1479219121.0,\n\

-         \      \"description\": \"This is LAZR smtptest, a framework for testing SMTP-based\

-         \ applications and\\nlibraries. It provides a real, live SMTP server that\

-         \ you can send messages\\nto, and from which you can read those test messages.\

-         \ This can be used to\\nensure proper operation of your applications which\

-         \ send email.\",\n      \"koschei_monitor\": true,\n      \"monitor\": true,\n\

-         \      \"name\": \"python-lazr-smtptest\",\n      \"namespace\": \"rpms\"\

-         ,\n      \"review_url\": \"https://bugzilla.redhat.com/1387250\",\n      \"\

-         status\": \"Approved\",\n      \"summary\": \"Test framework for SMTP-based\

-         \ applications\",\n      \"upstream_url\": \"https://launchpad.net/lazr.smtptest\"\

-         \n    },\n    {\n      \"acls\": [],\n      \"creation_date\": 1400070978.0,\n\

-         \      \"description\": \"Mako is a template library written in Python. It\

-         \ provides a familiar, non-XML\\nsyntax which compiles into Python modules\

-         \ for maximum performance. Mako's\\nsyntax and API borrows from the best ideas\

-         \ of many others, including Django\\ntemplates, Cheetah, Myghty, and Genshi.\

-         \ Conceptually, Mako is an embedded\\nPython (i.e. Python Server Page) language,\

-         \ which refines the familiar ideas of\\ncomponentized layout and inheritance\

-         \ to produce one of the most straightforward\\nand flexible models available,\

-         \ while also maintaining close ties to Python\\ncalling and scoping semantics.\"\

-         ,\n      \"koschei_monitor\": false,\n      \"monitor\": true,\n      \"name\"\

-         : \"python-mako\",\n      \"namespace\": \"rpms\",\n      \"review_url\":\

-         \ null,\n      \"status\": \"Approved\",\n      \"summary\": \"Mako template\

-         \ library for Python\",\n      \"upstream_url\": \"http://www.makotemplates.org/\"\

-         \n    },\n    {\n      \"acls\": [],\n      \"creation_date\": 1474373839.0,\n\

-         \      \"description\": \"nose2 is the next generation of nicer testing for\

-         \ Python, based on the plugins\\nbranch of unittest2. nose2 aims to improve\

-         \ on nose by:\\n- providing a better plugin API\\n- being easier for users\

-         \ to configure\\n- simplifying internal interfaces and processes\\n- supporting\

-         \ Python 2 and 3 from the same codebase, without translation\\n- encouraging\

-         \ greater community involvement in its development\\n\\nIn service of some\

-         \ those goals, some features of nose will not be supported in\\nnose2. See\

-         \ the documentation for a thorough rundown.\",\n      \"koschei_monitor\"\

-         : true,\n      \"monitor\": true,\n      \"name\": \"python-nose2\",\n   \

-         \   \"namespace\": \"rpms\",\n      \"review_url\": \"https://bugzilla.redhat.com/1375926\"\

-         ,\n      \"status\": \"Approved\",\n      \"summary\": \"Next generation of\

-         \ nicer testing for Python\",\n      \"upstream_url\": \"https://nose2.readthedocs.org\"\

-         \n    },\n    {\n      \"acls\": [],\n      \"creation_date\": 1400070978.0,\n\

-         \      \"description\": \"pylibmc is a client in Python for memcached. It\

-         \ is a wrapper\\naround TangentOrg\\u2018s libmemcached library. The interface\

-         \ is\\nintentionally made as close to python-memcached as possible,\\nso that\

-         \ applications can drop-in replace it.\",\n      \"koschei_monitor\": false,\n\

-         \      \"monitor\": false,\n      \"name\": \"python-pylibmc\",\n      \"\

-         namespace\": \"rpms\",\n      \"review_url\": null,\n      \"status\": \"\

-         Approved\",\n      \"summary\": \"Memcached client for Python\",\n      \"\

-         upstream_url\": \"http://sendapatch.se/projects/pylibmc/\"\n    },\n    {\n\

-         \      \"acls\": [],\n      \"creation_date\": 1400070978.0,\n      \"description\"\

-         : \"Most existing Python modules for sending HTTP requests are extremely verbose\

-         \ and\\ncumbersome. Python\\u2019s built-in urllib2 module provides most of\

-         \ the HTTP\\ncapabilities you should need, but the API is thoroughly broken.\

-         \ This library is\\ndesigned to make HTTP requests easy for developers.\"\

-         ,\n      \"koschei_monitor\": false,\n      \"monitor\": true,\n      \"name\"\

-         : \"python-requests\",\n      \"namespace\": \"rpms\",\n      \"review_url\"\

-         : null,\n      \"status\": \"Approved\",\n      \"summary\": \"HTTP library,\

-         \ written in Python, for human beings\",\n      \"upstream_url\": \"https://pypi.io/project/requests\"\

-         \n    },\n    {\n      \"acls\": [],\n      \"creation_date\": 1400070978.0,\n\

-         \      \"description\": \"Tornado is an open source version of the scalable,\

-         \ non-blocking web\\nserver and tools.\\n\\nThe framework is distinct from\

-         \ most mainstream web server frameworks\\n(and certainly most Python frameworks)\

-         \ because it is non-blocking and\\nreasonably fast. Because it is non-blocking\

-         \ and uses epoll, it can\\nhandle thousands of simultaneous standing connections,\

-         \ which means it is\\nideal for real-time web services.\",\n      \"koschei_monitor\"\

-         : true,\n      \"monitor\": true,\n      \"name\": \"python-tornado\",\n \

-         \     \"namespace\": \"rpms\",\n      \"review_url\": null,\n      \"status\"\

-         : \"Approved\",\n      \"summary\": \"Scalable, non-blocking web server and\

-         \ tools\",\n      \"upstream_url\": \"http://www.tornadoweb.org\"\n    },\n\

-         \    {\n      \"acls\": [],\n      \"creation_date\": 1400070978.0,\n    \

-         \  \"description\": \"Python HTTP module with connection pooling and file\

-         \ POST abilities.\",\n      \"koschei_monitor\": false,\n      \"monitor\"\

-         : true,\n      \"name\": \"python-urllib3\",\n      \"namespace\": \"rpms\"\

-         ,\n      \"review_url\": null,\n      \"status\": \"Approved\",\n      \"\

-         summary\": \"Python HTTP library with thread-safe connection pooling and file\

-         \ post\",\n      \"upstream_url\": \"https://github.com/shazow/urllib3\"\n\

-         \    },\n    {\n      \"acls\": [],\n      \"creation_date\": 1400070978.0,\n\

-         \      \"description\": \"Werkzeug\\n========\\n\\nWerkzeug started as simple\

-         \ collection of various utilities for WSGI\\napplications and has become one\

-         \ of the most advanced WSGI utility\\nmodules.  It includes a powerful debugger,\

-         \ full featured request and\\nresponse objects, HTTP utilities to handle entity\

-         \ tags, cache control\\nheaders, HTTP dates, cookie handling, file uploads,\

-         \ a powerful URL\\nrouting system and a bunch of community contributed addon\

-         \ modules.\\n\\nWerkzeug is unicode aware and doesn't enforce a specific template\\\

-         nengine, database adapter or anything else.  It doesn't even enforce\\na specific\

-         \ way of handling requests and leaves all that up to the\\ndeveloper. It's\

-         \ most useful for end user applications which should work\\non as many server\

-         \ environments as possible (such as blogs, wikis,\\nbulletin boards, etc.).\"\

-         ,\n      \"koschei_monitor\": true,\n      \"monitor\": true,\n      \"name\"\

-         : \"python-werkzeug\",\n      \"namespace\": \"rpms\",\n      \"review_url\"\

-         : null,\n      \"status\": \"Approved\",\n      \"summary\": \"The Swiss Army\

-         \ knife of Python web development\",\n      \"upstream_url\": \"http://werkzeug.pocoo.org/\"\

-         \n    },\n    {\n      \"acls\": [],\n      \"creation_date\": 1465852253.0,\n\

-         \      \"description\": \"This package provides a flexible test runner with\

-         \ layer support.\",\n      \"koschei_monitor\": true,\n      \"monitor\":\

-         \ true,\n      \"name\": \"python-zope-testrunner\",\n      \"namespace\"\

-         : \"rpms\",\n      \"review_url\": \"https://bugzilla.redhat.com/1341815\"\

-         ,\n      \"status\": \"Approved\",\n      \"summary\": \"Zope testrunner script\"\

-         ,\n      \"upstream_url\": \"https://pypi.python.org/pypi/zope.testrunner\"\

-         \n    },\n    {\n      \"acls\": [],\n      \"creation_date\": 1481116746.0,\n\

-         \      \"description\": \"The zope.event package provides a simple event system.\

-         \ It provides\\nan event publishing system and a very simple event-dispatching\

-         \ system\\non which more sophisticated event dispatching systems can be built.\\\

-         n(For example, a type-based event dispatching system that builds on\\nzope.event\

-         \ can be found in zope.component.)\",\n      \"koschei_monitor\": true,\n\

-         \      \"monitor\": true,\n      \"name\": \"python3-zope-event\",\n     \

-         \ \"namespace\": \"rpms\",\n      \"review_url\": \"https://bugzilla.redhat.com/1395244\"\

-         ,\n      \"status\": \"Approved\",\n      \"summary\": \"Zope Event Publication\"\

-         ,\n      \"upstream_url\": \"http://pypi.python.org/pypi/zope.event/\"\n \

-         \   },\n    {\n      \"acls\": [],\n      \"creation_date\": 1481289213.0,\n\

-         \      \"description\": \"Interfaces are a mechanism for labeling objects\

-         \ as conforming to a given API\\nor contract.\\nThis is a separate distribution\

-         \ of the zope.interface package used in Zope 3.\",\n      \"koschei_monitor\"\

-         : true,\n      \"monitor\": true,\n      \"name\": \"python3-zope-interface\"\

-         ,\n      \"namespace\": \"rpms\",\n      \"review_url\": \"https://bugzilla.redhat.com/1395255\"\

-         ,\n      \"status\": \"Approved\",\n      \"summary\": \"Zope 3 Interface\

-         \ Infrastructure\",\n      \"upstream_url\": \"https://pypi.io/project/zope.interface\"\

-         \n    },\n    {\n      \"acls\": [],\n      \"creation_date\": 1479138409.0,\n\

-         \      \"description\": \"SassC is a wrapper around libsass used to generate\

-         \ a useful command-line\\napplication that can be installed and packaged for\

-         \ several operating systems.\",\n      \"koschei_monitor\": true,\n      \"\

-         monitor\": true,\n      \"name\": \"sassc\",\n      \"namespace\": \"rpms\"\

-         ,\n      \"review_url\": \"https://bugzilla.redhat.com/1369535\",\n      \"\

-         status\": \"Approved\",\n      \"summary\": \"Wrapper around libsass to compile\

-         \ CSS stylesheet\",\n      \"upstream_url\": \"http://github.com/sass/sassc\"\

-         \n    }\n  ],\n  \"watch\": [\n    {\n      \"acls\": [],\n      \"creation_date\"\

-         : 1400070978.0,\n      \"description\": \"Advanced Web Statistics is a powerful\

-         \ and featureful tool that generates\\nadvanced web server graphic statistics.\

-         \ This server log analyzer works\\nfrom command line or as a CGI and shows\

-         \ you all information your log contains,\\nin graphical web pages. It can\

-         \ analyze a lot of web/wap/proxy servers like\\nApache, IIS, Weblogic, Webstar,\

-         \ Squid, ... but also mail or ftp servers.\\n\\nThis program can measure visits,\

-         \ unique vistors, authenticated users, pages,\\ndomains/countries, OS busiest\

-         \ times, robot visits, type of files, search\\nengines/keywords used, visits\

-         \ duration, HTTP errors and more...\\nStatistics can be updated from a browser\

-         \ or your scheduler.\\nThe program also supports virtual servers, plugins\

-         \ and a lot of features.\\n\\nWith the default configuration, the statistics\

-         \ are available:\\nhttp://localhost/awstats/awstats.pl\",\n      \"koschei_monitor\"\

-         : true,\n      \"monitor\": true,\n      \"name\": \"awstats\",\n      \"\

-         namespace\": \"rpms\",\n      \"review_url\": null,\n      \"status\": \"\

-         Approved\",\n      \"summary\": \"Advanced Web Statistics\",\n      \"upstream_url\"\

-         : \"http://awstats.sourceforge.net\"\n    },\n    {\n      \"acls\": [],\n\

-         \      \"creation_date\": 1452111332.0,\n      \"description\": \"This API\

-         \ is mainly for Terminal Emulator implementors, or those writing programs\\\

-         nthat expect to interpreted by a terminal emulator and wish to determine the\\\

-         nprintable width of a string on a Terminal.\",\n      \"koschei_monitor\"\

-         : true,\n      \"monitor\": true,\n      \"name\": \"python-wcwidth\",\n \

-         \     \"namespace\": \"rpms\",\n      \"review_url\": \"https://bugzilla.redhat.com/1295152\"\

-         ,\n      \"status\": \"Approved\",\n      \"summary\": \"Measures number of\

-         \ Terminal column cells of wide-character codes\",\n      \"upstream_url\"\

-         : \"https://github.com/jquast/wcwidth\"\n    }\n  ]\n}"}

-     headers:

-       Accept-Ranges: [bytes]

-       Age: ['0']

-       AppServer: [proxy06.fedoraproject.org]

-       AppTime: [D=293465]

-       Connection: [Keep-Alive]

-       Content-Length: ['30176']

-       Content-Type: [application/json]

-       Date: ['Thu, 15 Jun 2017 15:04:24 GMT']

-       Keep-Alive: ['timeout=15, max=500']

-       Server: [Apache/2.4.6 (Red Hat Enterprise Linux) mod_wsgi/3.4 Python/2.7.5]

-       Set-Cookie: ['pkgdb=eyJfcGVybWFuZW50Ijp0cnVlfQ.DCQzeA.1B01lt3fuPret9GeJCOsCK6JptU;

-           Expires=Thu, 15-Jun-2017 16:04:24 GMT; Secure; HttpOnly; Path=/pkgdb/']

-       Strict-Transport-Security: [max-age=15768000; includeSubDomains; preload]

-       Via: [1.1 varnish-v4]

-       X-Varnish: ['23219393']

-     status: {code: 200, message: OK}

- version: 1

@@ -1,30 +0,0 @@ 

- interactions:

- - request:

-     body: null

-     headers:

-       Accept: ['*/*']

-       Accept-Encoding: ['gzip, deflate']

-       Connection: [keep-alive]

-       User-Agent: [python-requests/2.13.0]

-     method: GET

-     uri: https://admin.fedoraproject.org/pkgdb/api/packager/package/abompard

-   response:

-     body: {string: "this is invalid"}

-     headers:

-       Accept-Ranges: [bytes]

-       Age: ['0']

-       AppServer: [proxy06.fedoraproject.org]

-       AppTime: [D=293465]

-       Connection: [Keep-Alive]

-       Content-Length: ['30176']

-       Content-Type: [application/json]

-       Date: ['Thu, 15 Jun 2017 15:04:24 GMT']

-       Keep-Alive: ['timeout=15, max=500']

-       Server: [Apache/2.4.6 (Red Hat Enterprise Linux) mod_wsgi/3.4 Python/2.7.5]

-       Set-Cookie: ['pkgdb=eyJfcGVybWFuZW50Ijp0cnVlfQ.DCQzeA.1B01lt3fuPret9GeJCOsCK6JptU;

-           Expires=Thu, 15-Jun-2017 16:04:24 GMT; Secure; HttpOnly; Path=/pkgdb/']

-       Strict-Transport-Security: [max-age=15768000; includeSubDomains; preload]

-       Via: [1.1 varnish-v4]

-       X-Varnish: ['23219393']

-     status: {code: 200, message: OK}

- version: 1

hubs/utils/packages.py hubs/utils/pkgdb.py
file renamed
+14 -6
@@ -8,21 +8,26 @@ 

  

  log = logging.getLogger(__name__)

  

- PKGDB_URL = "https://admin.fedoraproject.org/pkgdb/api/packager/package"

+ PAGURE_URL = "https://src.fedoraproject.org"

  

  

- def get_owned_packages(username, use_cache=True):

+ def get_user_packages(username, only_owned=False, use_cache=True):

      """Get the list of packages owned by the username.

  

      Args:

          username (str): The FAS username.

+         only_owned (bool): Only return the package names owned by the user, not

+             those they are co-maintainer of.

          use_cache (bool): Whether to cache the results for a few minutes.

              Defaults to ``True``.

+ 

+     Returns:

+         The list of package names sorted alphabetically.

      """

      def get_data():

-         url = "/".join([PKGDB_URL, username])

+         url = "/".join([PAGURE_URL, "api", "0", "user", username])

          try:

-             response = requests.get(url, timeout=5)

+             response = requests.get(url, timeout=20)

          except (requests.exceptions.ConnectionError,

                  requests.exceptions.Timeout):

              log.warning("Could not get the list of owned packages for %s",
@@ -35,11 +40,14 @@ 

                  "Invalid JSON response getting the list of packages "

                  "owned by %s: %s", username, response.text)

              return []

-         owned = data['point of contact'] + data['co-maintained']

-         return sorted(set(p['name'] for p in owned))

+         return sorted(set(

+             repo['name'] for repo in data["repos"]

+             if not only_owned or repo["user"]["name"] == username

+             ))

      if not use_cache:

          return get_data()

      else:

          cache_key = ":".join(["owned_packages", username])

          # Cache for 5 minutes, it seems reasonable.

+         # TODO: invalidate on fedmsg?

          return cache.get_or_create(cache_key.encode("utf-8"), get_data, 5 * 60)

@@ -4,7 +4,7 @@ 

  

  import pkgwat.api

  

- from hubs.utils.pkgdb import get_owned_packages

+ from hubs.utils.packages import get_user_packages

  from hubs.widgets import validators

  from hubs.widgets.base import Widget

  from hubs.widgets.view import RootWidgetView
@@ -48,14 +48,13 @@ 

  class GetIssues(CachedFunction):

      """Returns data for Bugzilla widget.

  

-     Queries pkgdb api for package list of the user and bugzilla for

-     corresponding issues.

+     Queries Bugzilla for issues on the user's packages.

      """

  

      def execute(self):

          username = self.instance.config["username"]

          max_num = int(self.instance.config.get("max", 3))

-         owned = get_owned_packages(username)

+         owned = get_user_packages(username)

          issues = []

          for pkg_name in owned:

              if len(issues) == max_num:
@@ -79,5 +78,5 @@ 

          except KeyError:

              return False

          username = self.instance.config["username"]

-         owned = get_owned_packages(username)

+         owned = get_user_packages(username)

          return (component in owned)

@@ -25,7 +25,7 @@ 

          username = instance.config["username"]

          categories = [

              'git', 'Wiki', 'Copr', 'anitya', 'mirrormanager', 'ansible',

-             'fedoratagger', 'Pkgdb', 'summershum', 'nuancier', 'Mailman',

+             'fedoratagger', 'summershum', 'nuancier', 'Mailman',

              'fedbadges', 'FMN', 'koschei', 'compose', 'fedimg',

              'Jenkins', 'irc', 'FAS', 'buildsys', 'Askbot', 'pagure',

              'Bodhi', 'faf', 'kerneltest', 'github', 'Trac', 'meetbot',

@@ -1,68 +0,0 @@ 

- from __future__ import unicode_literals

- 

- import requests

- 

- from hubs.utils import username2avatar

- from hubs.widgets import validators

- from hubs.widgets.base import Widget

- from hubs.widgets.view import RootWidgetView

- from hubs.widgets.caching import CachedFunction

- 

- 

- class PendingACLs(Widget):

- 

-     name = "workflow.pendingacls"

-     label = 'Pending ACL Requests'

-     position = "right"

-     parameters = [

-         dict(

-             name="username",

-             label="Username",

-             default=None,

-             validator=validators.Username,

-             help="A FAS username.",

-         )]

- 

- 

- class BaseView(RootWidgetView):

- 

-     # TODO -- add approve/deny buttons or just link through to pkgdb

-     template_name = "pendingacls.html"

- 

-     def get_context(self, instance, *args, **kwargs):

-         get_pending = GetPending(instance)

-         context = dict(

-             title=self.widget.label,

-             username=instance.config["username"],

-             )

-         context.update(get_pending())

-         return context

- 

- 

- class GetPending(CachedFunction):

- 

-     def execute(self):

-         # TODO -- rewrite this to

-         # 1) use the datagrepper API instead of the direct pkgdb API

-         # 2) so that we can use the fedmsg.meta.conglomerate API to

-         # 3) group messages nicely in the UI instead of having repeats

-         # It will be slower, but that's fine because of our cache.

-         username = self.instance.config["username"]

-         baseurl = "https://admin.fedoraproject.org/pkgdb/api/pendingacls"

-         query = "?username={username}&format=json".format(username=username)

-         url = baseurl + query

-         response = requests.get(url)

-         data = response.json()

-         for acl in data['pending_acls']:

-             acl['avatar'] = username2avatar(acl['user'], s=32)

-         return data

- 

-     def should_invalidate(self, message):

-         if not message['topic'].endswith('pkgdb.acl.update'):

-             return False

-         # Search the message to see if I am in the ACLs list of the request.

-         username = self.instance.config["username"]

-         for acl in message['msg']['package_listing'].get('acls', []):

-             if acl['fas_name'] == username and acl['status'] == 'Approved':

-                 return True

-         return False

@@ -1,26 +0,0 @@ 

- {% if pending_acls or edit_mode %}

- 

- {% extends "panel.html" %}

- 

- {% block content %}

- {% if session['nickname'] == username %}

- <a class="btn btn-success" target="_blank" href="https://admin.fedoraproject.org/pkgdb/acl/pending/">Manage requests</a>

- <hr/>

- {% endif %}

- <ul class="media-list">

- {% for acl in pending_acls %}

-     <li class="media">

-         <div class="media-left">

-             <img class="media-object img-circle" src="{{acl['avatar']}}"/>

-         </div>

-         <div class="media-body">

-             <h4 class="media-heading">{{acl['user']}} is {{acl['status']}}</h4>

-             for {{acl['acl']}} on

-             {{acl['package']}}({{acl['collection']}})

-         </div>

-     </li>

- {% endfor %}

- </ul>

- {% endblock %}

- 

- {% endif %}

@@ -30,7 +30,6 @@ 

  

  class BaseView(RootWidgetView):

  

-     # TODO -- add approve/deny buttons or just link through to pkgdb

      template_name = "updates2stable.html"

  

      def get_context(self, instance, *args, **kwargs):

PkgDB is being retired in favor of Pagure over dist-git, this branch makes the necessary changes:

  • the hubs.utils.pkgdb has been rewritten to make REST calls to the Pagure API
  • The Pkgdb category in the linechart widget has been removed
  • The workflow.pendingacls widget has been removed because ACLs aren't approved via a webapp anymore, requests must be made via email.

Fixes: #368

Ah! this PR needs a rebase and merge.

rebased

6 years ago

Pull-Request has been merged by abompard

6 years ago