Exemplo n.º 1
0
def bug(bot, ievent):
    """bug <bugid>"""
    bts = debbugs()
    b = bts.get(int(ievent.args[0]))

    status = "(fixed) " if b.status == "done" else ""
    severity = "(%s) " % b.severity if b.severity != "normal" else ""

    #msg = colourise("[bug]#%s[reset]%s: %s: «[title]%s[reset]»%s [url]%s[reset]" % (b.bug, status, package, b.summary, severity, b.url)).decode("utf-8")
    #msg = "#%s%s: %s: %s%s %s" % (b.bug, status, b.package, b.summary, severity, b.url)
    msg = "%s %s%s- %s: %s" % (b.url, status, severity, b.package, b.summary)
    bot.msg(choose_dest(ievent), "%s: %s" % (ievent.nick, msg.encode("utf-8")))
def bug_synopsis(bug_string):
    m = BUG_NUMBER_PATTERN.search(bug_string)
    try:
        bug_number = int(m.group(0))
    except:
        raise ValueError

    bts = debbugs()
    entry = bts.get(bug_number)

    msg = BugSynopsis()

    msg.bug_number = bug_number
    msg.status = entry.status
    msg.package = entry.package
    msg.severity = entry.severity

    msg.title = tidy_bug_title.tidy_bug_title(entry.summary, entry.package)

    return msg
Exemplo n.º 3
0
    def _update_iter(self, iter, bug_number):
        print >>sys.stderr, "Querying status for bug #%d..." % bug_number

        try:
            # Actually download the entry
            bts_entry = debbugs().get(bug_number)

            print >>sys.stderr, "Got status for bug #%d." % bug_number

            gtk.gdk.threads_enter()
            iter = self._iter_from_bug(bug_number)
            if not iter:
                # Bug has been deleted since the entry was downloaded
                gtk.gdk.threads_leave()
                return

            old = {}
            for idx, field in enumerate(BtsApplet.FIELDS):
                old[field] = self._bugs.get_value(iter, idx)

            new = {
                'bug_number': bug_number,
                'state': BtsApplet.ST_DOWNLOADED,
                'package': str(bts_entry.package),
                'summary': str(bts_entry.summary),
                'severity': str(bts_entry.severity),
                'tags': ', '.join(bts_entry.tags),
                'status': str(bts_entry.status),
                'tick': old['tick'],
            }

            # Update backing ListStore
            if self._bugs.iter_is_valid(iter):
                for idx, field in enumerate(BtsApplet.FIELDS):
                    self._bugs.set(iter, idx, new[field])

            gtk.gdk.threads_leave()

            # Check whether the bug has changed. We only check for changes
            # if we already have data!
            if old['state'] >= BtsApplet.ST_UPDATING:
                delta = []
                for idx, field in enumerate(BtsApplet.FIELDS):

                    # We don't want to know if the bug downloaded state changes
                    if idx == BtsApplet.FIELDS.index('state'):
                        continue

                    # .. or the tick count
                    if idx == BtsApplet.FIELDS.index('tick'):
                        continue

                    if old[field] != new[field]:
                        delta.append(field)

                # If there are changes, reset tick and notify user
                if len(delta) > 0:
                    gtk.gdk.threads_enter()
                    if self._bugs.iter_is_valid(iter):
                        self._bugs.set(iter, BtsApplet.FIELDS.index('tick'), BtsApplet.TICK_DEFAULT)
                    gtk.gdk.threads_leave()

                    self.controller.do_notify(old, new, delta)

        except:
            gtk.gdk.threads_enter()

            print >>sys.stderr, "Error getting status for bug #%d." % bug_number
            import traceback
            traceback.print_exc()

            # Mark error state in bug
            iter = self._iter_from_bug(bug_number)
            if not iter:
                # Bug was deleted
                gtk.gdk.threads_leave()
                return

            # Caclulate new state (see HACKING for state transitions)
            old_state = self._bugs.get_value(iter, BtsApplet.FIELDS.index('state'))
            new_status = {
                BtsApplet.ST_DOWNLOADING: BtsApplet.ST_ERROR_DOWNLOADING,
                BtsApplet.ST_DOWNLOADED: BtsApplet.ST_ERROR_UPDATING,
                BtsApplet.ST_UPDATING: BtsApplet.ST_ERROR_UPDATING,
            }[old_state]
            self._bugs.set(iter, BtsApplet.FIELDS.index('state'), new_status)

            # Reset tick to error state
            self._bugs.set(iter, BtsApplet.FIELDS.index('tick'), BtsApplet.TICK_ERROR_RESET)

            gtk.gdk.threads_leave()