def test_get_reports(self): data = debbugs.get_reports('reportbug', timeout=60) self.assertGreater(data[0], 0)
def test_bts796759(self): # verify accessing WNPP happens correctly, now that BTS # access has to be done in batches data = debbugs.get_reports('wnpp', 120, source=True) self.assertGreater(data[0], 0)
def test_get_reports(self): data = debbugs.get_reports("reportbug", timeout=60) self.assertGreater(data[0], 0)
def handle_bts_query(package, bts, timeout, mirrors=None, http_proxy="", queryonly=False, title="", screen=None, archived='no', source=False, version=None, mbox=False, buglist=None, mbox_reader_cmd=None, latest_first=False): root = debbugs.SYSTEMS[bts].get('btsroot') if not root: ewrite('%s bug tracking system has no web URL; bypassing query\n', debbugs.SYSTEMS[bts]['name']) return srcstr = "" if source: srcstr = " (source)" if isinstance(package, basestring): long_message('Querying %s BTS for reports on %s%s...\n', debbugs.SYSTEMS[bts]['name'], package, srcstr) else: long_message('Querying %s BTS for reports on %s%s...\n', debbugs.SYSTEMS[bts]['name'], ' '.join([str(x) for x in package]), srcstr) bugs = [] try: (count, title, hierarchy)=debbugs.get_reports( package, timeout, bts, mirrors=mirrors, version=version, source=source, http_proxy=http_proxy, archived=archived) # If there's no report, then skip all the rest if not count: if hierarchy == None: raise NoPackage else: raise NoBugs hierarchy_new = [] if mbox: mboxbuglist = [] for entry in hierarchy: for bug in entry[1]: mboxbuglist.append(bug.bug_num) return mboxbuglist if buglist: for entry in hierarchy: # second item is a list of bugs report for bug in entry[1]: msg = "#%d %s" %(bug.bug_num, bug.subject) msg = msg.encode(charset, 'replace') print msg sys.exit(0) for entry in hierarchy: # first item is the title of the section entry_new = entry[0] bugs_new = {} bugs_numbers = [] # XXX: we can probably simplify this code, with some lists # generations and map() # second item is a list of bugs report for bug in entry[1]: # show if the bugs is already resolved done = '' if bug.pending == 'done': done = ' [RESOLVED]' # we take the info we need (bug number and subject) # we use a dict so it's easy to sort the keys and then values bugs_new[bug.bug_num] = "%s%s" % (bug.subject, done) # and at the same time create a list of bugs numbers bugs_numbers.append(bug.bug_num) # then we sort both the lists hierarchy_new.append((entry_new, ["#%d %s" % (k, bugs_new[k]) for k in sorted(bugs_new.keys(), reverse=latest_first)])) bugs.extend(sorted(bugs_numbers, reverse=latest_first)) # replace old hierarchy with hierarchy_new hierarchy = hierarchy_new if not count: if hierarchy == None: raise NoPackage else: raise NoBugs elif count == 1: ewrite('%d bug report found:\n\n', count) else: ewrite('%d bug reports found:\n\n', count) return browse_bugs(hierarchy, count, bugs, bts, queryonly, mirrors, http_proxy, timeout, screen, title, package, mbox_reader_cmd) except (IOError, NoNetwork): ewrite('Unable to connect to %s BTS; ', debbugs.SYSTEMS[bts]['name']) res = select_options('continue', 'yN', {'y': 'Keep going.', 'n': 'Abort.'}) if res == 'n': raise NoNetwork except NoPackage: long_message('No record of this package found.') raise NoPackage
def handle_bts_query(package, bts, timeout, mirrors=None, http_proxy="", queryonly=False, screen=None, title="", archived='no', source=False, version=None, mbox=False, buglist=None, mbox_reader_cmd=None, latest_first=False): from reportbug import debbugs sysinfo = debbugs.SYSTEMS[bts] root = sysinfo.get('btsroot') if not root: ewrite("%s bug tracking system has no web URL; bypassing query.\n", sysinfo['name']) return ui = screen if not ui: ui = initialize_urwid_ui() if isinstance(package, str): pkgname = package if source: pkgname += ' (source)' display_message('Querying %s bug tracking system for reports on %s', debbugs.SYSTEMS[bts]['name'], pkgname, ui=ui, title=title) else: display_message('Querying %s bug tracking system for reports %s', debbugs.SYSTEMS[bts]['name'], ' '.join([str(x) for x in package]), ui=ui, title=title) result = None try: (count, sectitle, hierarchy) = debbugs.get_reports(package, timeout, bts, mirrors=mirrors, version=version, http_proxy=http_proxy, archived=archived, source=source) except Exception as e: ui.run_wrapper(nullfunc) long_message('Unable to connect to %s BTS.', sysinfo['name'], title=title) raise NoBugs try: if not count: ui.run_wrapper(nullfunc) if hierarchy is None: raise NoPackage else: raise NoBugs else: if count > 1: sectitle = '%d bug reports found' % (count, ) else: sectitle = '%d bug report found' % (count, ) buglist = [] for (t, bugs) in hierarchy: bcount = len(bugs) buglist.append(('---', t)) buglist_tmp = {} for bug in bugs: # show if the bugs is already resolved done = '' if bug.pending == 'done': done = ' [RESOLVED]' buglist_tmp[bug.bug_num] = bug.subject + done # append the sorted list of bugs for this severity list( map(buglist.append, [(str(k), buglist_tmp[k]) for k in sorted(buglist_tmp, reverse=latest_first)])) p = buglist[1][0] # scr.popWindow() if queryonly: cancellabel = 'Exit' quitlabel = None else: cancellabel = 'New bug' quitlabel = 'Quit' while True: info = int( menu( 'Select a bug to read (and possibly report more information) or report a new bug:', buglist, '', ui=ui, title=sectitle, default=p, oklabel='Read bug', cancellabel=cancellabel, quitlabel=quitlabel)) ui = None if info < 0: if info == -1: result = None # -2 is the Quit response, triggers the exiting way in main elif info == -2: raise NoReport else: # uniform to return Bugreport instance result = debbugs.get_report(info, timeout)[0] break else: res = show_report(info, bts, mirrors, http_proxy, timeout, queryonly=queryonly) if res: result = res break except NoPackage: ui.run_wrapper(nullfunc) long_message('No record of this package found.', title=title) raise NoPackage # we didn't find a report; we access Bugreport thru debbugs, # so to avoid and import of debianbts if result and not isinstance(result, debbugs.debianbts.Bugreport): raise NoReport return result
def handle_bts_query(package, bts, timeout, mirrors=None, http_proxy="", queryonly=False, title="", screen=None, archived='no', source=False, version=None, mbox=False, buglist=None, mbox_reader_cmd=None, latest_first=False): root = debbugs.SYSTEMS[bts].get('btsroot') if not root: ewrite('%s bug tracking system has no web URL; bypassing query\n', debbugs.SYSTEMS[bts]['name']) return srcstr = "" if source: srcstr = " (source)" if isinstance(package, basestring): long_message('Querying %s BTS for reports on %s%s...\n', debbugs.SYSTEMS[bts]['name'], package, srcstr) else: long_message('Querying %s BTS for reports on %s%s...\n', debbugs.SYSTEMS[bts]['name'], ' '.join([str(x) for x in package]), srcstr) bugs = [] try: (count, title, hierarchy) = debbugs.get_reports(package, timeout, bts, mirrors=mirrors, version=version, source=source, http_proxy=http_proxy, archived=archived) # If there's no report, then skip all the rest if not count: if hierarchy == None: raise NoPackage else: raise NoBugs hierarchy_new = [] if mbox: mboxbuglist = [] for entry in hierarchy: for bug in entry[1]: mboxbuglist.append(bug.bug_num) return mboxbuglist if buglist: for entry in hierarchy: # second item is a list of bugs report for bug in entry[1]: msg = "#%d %s" % (bug.bug_num, bug.subject) msg = msg.encode(charset, 'replace') print msg sys.exit(0) for entry in hierarchy: # first item is the title of the section entry_new = entry[0] bugs_new = {} bugs_numbers = [] # XXX: we can probably simplify this code, with some lists # generations and map() # second item is a list of bugs report for bug in entry[1]: # show if the bugs is already resolved done = '' if bug.pending == 'done': done = ' [RESOLVED]' # we take the info we need (bug number and subject) # we use a dict so it's easy to sort the keys and then values bugs_new[bug.bug_num] = "%s%s" % (bug.subject, done) # and at the same time create a list of bugs numbers bugs_numbers.append(bug.bug_num) # then we sort both the lists hierarchy_new.append((entry_new, [ "#%d %s" % (k, bugs_new[k]) for k in sorted(bugs_new.keys(), reverse=latest_first) ])) bugs.extend(sorted(bugs_numbers, reverse=latest_first)) # replace old hierarchy with hierarchy_new hierarchy = hierarchy_new if not count: if hierarchy == None: raise NoPackage else: raise NoBugs elif count == 1: ewrite('%d bug report found:\n\n', count) else: ewrite('%d bug reports found:\n\n', count) return browse_bugs(hierarchy, count, bugs, bts, queryonly, mirrors, http_proxy, timeout, screen, title, package, mbox_reader_cmd) except (IOError, NoNetwork): ewrite('Unable to connect to %s BTS; ', debbugs.SYSTEMS[bts]['name']) res = select_options('continue', 'yN', { 'y': 'Keep going.', 'n': 'Abort.' }) if res == 'n': raise NoNetwork except NoPackage: long_message('No record of this package found.') raise NoPackage
def handle_bts_query(package, bts, timeout, mirrors=None, http_proxy="", queryonly=False, screen=None, title="", archived='no', source=False, version=None, mbox=False, buglist=None, mbox_reader_cmd=None, latest_first=False): from reportbug import debbugs sysinfo = debbugs.SYSTEMS[bts] root = sysinfo.get('btsroot') if not root: ewrite("%s bug tracking system has no web URL; bypassing query.\n", sysinfo['name']) return ui = screen if not ui: ui = initialize_urwid_ui() if isinstance(package, basestring): pkgname = package if source: pkgname += ' (source)' display_message('Querying %s bug tracking system for reports on %s', debbugs.SYSTEMS[bts]['name'], pkgname, ui=ui, title=title) else: display_message('Querying %s bug tracking system for reports %s', debbugs.SYSTEMS[bts]['name'], ' '.join([str(x) for x in package]), ui=ui,title=title) result = None try: (count, sectitle, hierarchy) = debbugs.get_reports( package, timeout, bts, mirrors=mirrors, version=version, http_proxy=http_proxy, archived=archived, source=source) if not count: ui.run_wrapper(nullfunc) if hierarchy == None: raise NoPackage else: raise NoBugs else: if count > 1: sectitle = '%d bug reports found' % (count,) else: sectitle = '%d bug report found' % (count,) buglist = [] for (t, bugs) in hierarchy: bcount = len(bugs) buglist.append( ('---', t) ) buglist_tmp = {} for bug in bugs: # show if the bugs is already resolved done = '' if bug.pending == 'done': done = ' [RESOLVED]' buglist_tmp[bug.bug_num] = bug.subject+done # append the sorted list of bugs for this severity map(buglist.append, [(str(k), buglist_tmp[k]) for k in sorted(buglist_tmp, reverse=latest_first)]) p = buglist[1][0] #scr.popWindow() if queryonly: cancellabel = 'Exit' quitlabel = None else: cancellabel = 'New bug' quitlabel='Quit' while True: info = menu('Select a bug to read (and possibly report more information) or report a new bug:', buglist, '', ui=ui, title=sectitle, default=p, oklabel='Read bug', cancellabel=cancellabel, quitlabel=quitlabel) ui = None if info < 0: if info == -1: result = None # -2 is the Quit response, triggers the exiting way in main elif info == -2: raise NoReport else: # uniform to return Bugreport instance result = debbugs.get_report(info, timeout)[0] break else: p = info res = show_report(int(p), bts, mirrors, http_proxy, timeout, queryonly=queryonly) if res: result = res break except (IOError, NoNetwork): ui.run_wrapper(nullfunc) long_message('Unable to connect to %s BTS.', sysinfo['name'], title=title) except NoPackage: ui.run_wrapper(nullfunc) long_message('No record of this package found.', title=title) raise NoPackage # we didn't find a report; we access Bugreport thru debbugs, # so to avoid and import of debianbts if result and not isinstance(result, debbugs.debianbts.Bugreport): raise NoReport return result