From d9a239988864bb1f354d9440c8a8d971d70fd8df Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Mar 01 2017 20:49:44 +0000 Subject: Fix the error: 'Project' object has no attribute 'ci_hook' Since 2.13.1, we were running into this error: AttributeError: 'Project' object has no attribute 'ci_hook' on a regular basis, when creating a new PR or when commenting on one, but not regular comment, just notification. In both of these situations, and on pagure.io that has the jenkins integration turned on, we notify the pagure-ci service that there was a change to the PR that should be tested. However, nowhere in the code did we load pagure.hooks.pagure_ci which contains the definition of the PagureCiTable having the backref from that table to Project and named it ``ci_hook``. This was working in 2.13 and not in 2.13.1 because in the commit: 867097dc25bea470ed3d53cbd28c390e22d52b01 We ran flake8 to clean the pagure.lib module and we removed that import. Simply bringing back this import and make it ignored of flake8 solves our problem. Fixes https://pagure.io/pagure/issue/2013 --- diff --git a/pagure/lib/lib_ci.py b/pagure/lib/lib_ci.py index a89aa0e..5f53107 100644 --- a/pagure/lib/lib_ci.py +++ b/pagure/lib/lib_ci.py @@ -15,6 +15,10 @@ import pagure.exceptions import pagure.lib +# This import is needed as pagure.lib relies on Project.ci_hook to be +# defined and accessible and this happens in pagure.hooks.pagure_ci +from pagure.hooks import pagure_ci # noqa + BUILD_STATS = { 'SUCCESS': ('Build successful', 100),