]> git.ipfire.org Git - people/jschlag/pbs.git/blob - src/manager/bugs.py
Drop dependency on textile
[people/jschlag/pbs.git] / src / manager / bugs.py
1 #!/usr/bin/python
2
3 import logging
4
5 import base
6
7 class BugsUpdateEvent(base.Event):
8 # User feedback gets a high priority.
9 priority = 1
10
11 @property
12 def interval(self):
13 return self.pakfire.settings.get_int("bugzilla_update_interval", 60)
14
15 def run(self):
16 # Get up to ten updates.
17 query = self.db.query("SELECT * FROM builds_bugs_updates \
18 WHERE error = 'N' ORDER BY time")
19
20 # XXX CHECK IF BZ IS ACTUALLY REACHABLE AND WORKING
21
22 for update in query:
23 try:
24 bug = self.pakfire.bugzilla.get_bug(update.bug_id)
25 if not bug:
26 logging.error("Bug #%s does not exist." % update.bug_id)
27 continue
28
29 # Set the changes.
30 bug.set_status(update.status, update.resolution, update.comment)
31
32 except Exception, e:
33 # If there was an error, we save that and go on.
34 self.db.execute("UPDATE builds_bugs_updates SET error = 'Y', error_msg = %s \
35 WHERE id = %s", "%s" % e, update.id)
36
37 else:
38 # Remove the update when it has been done successfully.
39 self.db.execute("DELETE FROM builds_bugs_updates WHERE id = %s", update.id)