]> git.ipfire.org Git - people/jschlag/pbs.git/commitdiff
Move sending bug updates out of manager
authorMichael Tremer <michael.tremer@ipfire.org>
Sun, 8 Oct 2017 13:55:06 +0000 (14:55 +0100)
committerMichael Tremer <michael.tremer@ipfire.org>
Sun, 8 Oct 2017 13:55:06 +0000 (14:55 +0100)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Makefile.am
src/buildservice/bugtracker.py
src/crontab/pakfire-build-service
src/manager/__init__.py
src/manager/bugs.py [deleted file]
src/scripts/pakfire-build-service

index 4f0ea3f8064784c95e8523b7eeff4910cdceae43..a3ba07693269d15cdb2453d59359e42f1c4031c7 100644 (file)
@@ -123,7 +123,6 @@ hubdir = $(buildservicedir)/hub
 manager_PYTHON = \
        src/manager/__init__.py \
        src/manager/base.py \
-       src/manager/bugs.py \
        src/manager/builds.py \
        src/manager/repositories.py \
        src/manager/sources.py
index 7d80c1c3ef2c94cd39b50df74e010116946561d1..2832544ecec4a1085752e21a402e9803dc54db7e 100644 (file)
@@ -65,7 +65,6 @@ class BugzillaBug(base.Object):
 
                self.call("update", ids=[self.id,], **kwargs)
 
-       
 
 class Bugzilla(base.Object):
        def __init__(self, pakfire):
@@ -133,7 +132,6 @@ class Bugzilla(base.Object):
        def get_bug(self, bug_id):
                try:
                        bug = BugzillaBug(self, bug_id)
-                       s = bug.status
 
                except xmlrpclib.Fault:
                        return None
@@ -174,3 +172,29 @@ class Bugzilla(base.Object):
                        bugs.append(bug)
 
                return bugs
+
+       def send_all(self, limit=100):
+               # Get up to ten updates.
+               query = self.db.query("SELECT * FROM builds_bugs_updates \
+                       WHERE error IS FALSE ORDER BY time LIMIT %s", limit)
+
+               # XXX CHECK IF BZ IS ACTUALLY REACHABLE AND WORKING
+
+               for update in query:
+                       try:
+                               bug = self.backend.bugzilla.get_bug(update.bug_id)
+                               if not bug:
+                                       logging.error("Bug #%s does not exist." % update.bug_id)
+                                       continue
+
+                               # Set the changes.
+                               bug.set_status(update.status, update.resolution, update.comment)
+
+                       except Exception, e:
+                               # If there was an error, we save that and go on.
+                               self.db.execute("UPDATE builds_bugs_updates SET error = 'Y', error_msg = %s \
+                                       WHERE id = %s", "%s" % e, update.id)
+
+                       else:
+                               # Remove the update when it has been done successfully.
+                               self.db.execute("DELETE FROM builds_bugs_updates WHERE id = %s", update.id)
index bf9ab184d59b2ca0da74d07ed7f08ac00f01ed26..84b598d2e88d3e3e4ee20a0140f98dbd4335728a 100644 (file)
@@ -1,6 +1,9 @@
 # Send queued emails once a minute
 * * * * *      nobody  pakfire-build-service process-message-queue &>/dev/null
 
+# Send updates to Bugzilla
+*/5 * * * *    nobody  pakfire-build-service send-bug-updates &>/dev/null
+
 # Cleanup timed-out uploads
 0 */6 * * *    nobody  pakfire-build-service cleanup-uploads &>/dev/null
 
index 6baa0956c51b4b922d2a7622650faf5e568c90d8..d59e557d3ab6e1f099ac6e8a252ab4f8a926e8dc 100644 (file)
@@ -2,7 +2,6 @@
 
 from . import base
 
-from .bugs         import BugsUpdateEvent
 from .builds       import BuildsFailedRestartEvent, CheckBuildDependenciesEvent
 from .builds       import CreateTestBuildsEvent, DistEvent
 from .repositories import RepositoriesUpdateEvent
diff --git a/src/manager/bugs.py b/src/manager/bugs.py
deleted file mode 100644 (file)
index 1ee5f64..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-#!/usr/bin/python
-
-import logging
-
-from . import base
-
-class BugsUpdateEvent(base.Event):
-       # User feedback gets a high priority.
-       priority = 1
-
-       @property
-       def interval(self):
-               return self.pakfire.settings.get_int("bugzilla_update_interval", 60)
-
-       def run(self):
-               # Get up to ten updates.
-               query = self.db.query("SELECT * FROM builds_bugs_updates \
-                       WHERE error = 'N' ORDER BY time")
-
-               # XXX CHECK IF BZ IS ACTUALLY REACHABLE AND WORKING
-
-               for update in query:
-                       try:
-                               bug = self.pakfire.bugzilla.get_bug(update.bug_id)
-                               if not bug:
-                                       logging.error("Bug #%s does not exist." % update.bug_id)
-                                       continue
-
-                               # Set the changes.
-                               bug.set_status(update.status, update.resolution, update.comment)
-
-                       except Exception, e:
-                               # If there was an error, we save that and go on.
-                               self.db.execute("UPDATE builds_bugs_updates SET error = 'Y', error_msg = %s \
-                                       WHERE id = %s", "%s" % e, update.id)
-
-                       else:
-                               # Remove the update when it has been done successfully.
-                               self.db.execute("DELETE FROM builds_bugs_updates WHERE id = %s", update.id)
index 2fb2cc0755580a76cc0cac3950f5d4c8924bd33a..20c93e6470f58d01cbbe65b12783b39dae392e8f 100644 (file)
@@ -25,6 +25,9 @@ class Cli(object):
 
                        # Sends all queued messages
                        "process-message-queue" : self.backend.messages.process_queue,
+
+                       # Send bug updates to Bugzilla
+                       "send-bug-updates" : self.backend.bugzilla.send_all,
                }
 
        def __call__(self, *args):