[Reportbug-commits] [SCM] Reportbug - reports bugs in the Debian distribution branch, master, updated. 4.9-82-gcadcedb

Sandro Tosi morph at debian.org
Tue Mar 30 19:57:50 UTC 2010


The following commit has been merged in the master branch:
commit cadcedb3f055d77e4625a2ec703fb27b3fac48b5
Author: Sandro Tosi <morph at debian.org>
Date:   Tue Mar 30 21:56:20 2010 +0200

    Added --timeout option, for a configurable network timeout
    
    * bin/*, reportbub/*
      - add a user-configurable network timeout, adding the CLI option --timeout;
        thanks to Miles Bader for the report; Closes: #572316
    * man/*, doc/README.Users
      - added information about new --timeout CLI option, specifying that some
        network error might be due to a too low timeout; thanks to Michal Suchanek
        for the report; Closes: #571955

diff --git a/bin/querybts b/bin/querybts
index 477e174..c3744d5 100755
--- a/bin/querybts
+++ b/bin/querybts
@@ -84,6 +84,8 @@ def main():
                       help='define the proxy to use')
     parser.add_option('-s', '--source', action='store_true', dest='source',
                       help='Query for source packages rather than binary packages.')
+    parser.add_option('--timeout', type="int", dest='timeout', default=60,
+                      help='Specify the network timeout, in seconds [default: %default].')
     parser.add_option('-u', '--ui', '--interface', dest='interface',
                       help='Specify the user interface to use; available values: %s ' % ', '.join(AVAILABLE_UIS.keys()))
     parser.add_option('-w', '--web', action='store_true', dest='use_browser',
@@ -156,13 +158,13 @@ def main():
             m = re.match('^#?(\d+)$', bugnum)
             if not m:
                 mboxbuglist = []
-                mboxbuglist = ui.handle_bts_query(package, options.system, options.mirrors, options.http_proxy,
+                mboxbuglist = ui.handle_bts_query(package, options.system, options.timeout, options.mirrors, options.http_proxy,
                                     queryonly=True, title=VERSION, archived=options.archived,
                                     source=options.source, mbox=options.mbox)
                 for num in mboxbuglist:
                     url = debianbts.get_report_url(options.system, num, options.archived, mbox=True)
                     try:
-                        report = urlutils.open_url(url)
+                        report = urlutils.open_url(url, timeout=options.timeout)
                         sys.stdout.write(report.read())
                     except urlutils.urllib2.URLError, ex:
                         print >> sys.stderr, "Error while accessing mbox report (%s)." % ex
@@ -170,7 +172,7 @@ def main():
                 num = int(m.group(1))
                 url = debianbts.get_report_url(options.system, num, options.archived, mbox=True)
                 try:
-                    report = urlutils.open_url(url)
+                    report = urlutils.open_url(url, timeout=options.timeout)
                     sys.stdout.write(report.read())
                 except urlutils.urllib2.URLError, ex:
                     print >> sys.stderr, "Error while accessing mbox report (%s)." % ex
@@ -196,7 +198,8 @@ def main():
                 report = int(match.group(1))
                 while 1 :
                     retvalue = ui.show_report(report, options.system, options.mirrors,
-                                          options.http_proxy, queryonly=True,
+                                          options.http_proxy, options.timeout,
+                                          queryonly=True,
                                           title=VERSION,
                                           archived=options.archived)
                     ui.long_message('This option is not available while using querybts alone.\n')
@@ -208,7 +211,7 @@ def main():
                         sys.exit(0)
 
         while 1:
-            ui.handle_bts_query(package, options.system, options.mirrors, options.http_proxy,
+            ui.handle_bts_query(package, options.system, options.timeout, options.mirrors, options.http_proxy,
                                 queryonly=True, title=VERSION, archived=options.archived,
                                 source=options.source, buglist=options.buglist)
             ui.long_message('This option is not available while using querybts alone.\n')
diff --git a/bin/reportbug b/bin/reportbug
index 0418d8b..1477dff 100755
--- a/bin/reportbug
+++ b/bin/reportbug
@@ -488,12 +488,12 @@ def get_package_name(bts='debian', mode=MODE_EXPERT):
 
     return package
 
-def special_prompts(package, bts, ui, fromaddr):
+def special_prompts(package, bts, ui, fromaddr, timeout):
     prompts = debianbts.SYSTEMS[bts].get('specials')
     if prompts:
         pkgprompts = prompts.get(package)
         if pkgprompts:
-            return pkgprompts(package, bts, ui, fromaddr)
+            return pkgprompts(package, bts, ui, fromaddr, timeout)
     return
 
 def offer_configuration(options):
@@ -931,6 +931,8 @@ def main():
                       '(default)')
     parser.add_option('--draftpath', dest="draftpath",
                       help='Save the draft in this directory')
+    parser.add_option('--timeout', type="int", dest='timeout', default=60,
+                      help='Specify the network timeout, in seconds [default: %default]')
 
     (options, args) = parser.parse_args()
 
@@ -1265,7 +1267,7 @@ class UI(object):
                 if match:
                     report = int(match.group(1))
                     exinfo = ui.show_report(report, 'debian', self.options.mirrors,
-                                          self.options.http_proxy, queryonly=True,
+                                          self.options.http_proxy, self.options.timeout, queryonly=True,
                                           title=VERSION,
                                           archived=False)
                     if foundpackage:
@@ -1488,8 +1490,8 @@ class UI(object):
             else:
                 ewrite('Checking for newer versions at packages.debian.org...\n')
             (avail, toonew) = checkversions.check_available(
-                package, pkgversion, check_incoming=check_more,
-                check_newqueue=check_more,
+                package, pkgversion, timeout=self.options.timeout,
+                check_incoming=check_more, check_newqueue=check_more,
                 http_proxy=self.options.http_proxy, arch=arch)
             if toonew:
                 if not ui.yes_no(
@@ -1561,7 +1563,7 @@ class UI(object):
 
         special = False
         if not body and not subject and not notatty:
-            res = special_prompts(package, bts, ui, fromaddr)
+            res = special_prompts(package, bts, ui, fromaddr, self.options.timeout)
             if res:
                 (subject, severity, h, ph, body, query) = res
                 headers += h
@@ -1579,7 +1581,8 @@ class UI(object):
                 if src_name:
                     pkg = src_name
             try:
-                exinfo = ui.handle_bts_query(pkg, bts, self.options.mirrors,
+                exinfo = ui.handle_bts_query(pkg, bts, self.options.timeout,
+                                             self.options.mirrors,
                                              self.options.http_proxy,
                                              source=src,
                                              queryonly=self.options.queryonly,
@@ -1839,7 +1842,8 @@ For more details, please see: http://www.debian.org/devel/wnpp/''')
                 ewrite('Checking buildd.debian.org for past builds of %s...\n',
                        src_name)
                 built = checkbuildd.check_built(src_name,
-                                                http_proxy=self.options.http_proxy)
+                                                http_proxy=self.options.http_proxy,
+                                                timeout=options.timeout)
 
                 if built:
                     ewrite('Successful past builds... treating as serious.\n')
diff --git a/debian/changelog b/debian/changelog
index 35b6352..bcd6e7f 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -17,8 +17,15 @@ reportbug (4.12) UNRELEASED; urgency=low
     - pass 'buglist' to 'sync_pre_operation' method of 'HandleBTSQueryPage'
       class, needed to run querybts; thanks to Andrey Rahmatullin for the
       report; Closes: #565283
-
- -- Sandro Tosi <morph at debian.org>  Sun, 28 Mar 2010 15:50:47 +0200
+  * bin/*, reportbub/*
+    - add a user-configurable network timeout, adding the CLI option --timeout;
+      thanks to Miles Bader for the report; Closes: #572316
+  * man/*, doc/README.Users
+    - added information about new --timeout CLI option, specifying that some
+      network error might be due to a too low timeout; thanks to Michal Suchanek
+      for the report; Closes: #571955
+
+ -- Sandro Tosi <morph at debian.org>  Tue, 30 Mar 2010 21:49:15 +0200
 
 reportbug (4.11) unstable; urgency=low
 
diff --git a/doc/README.Users b/doc/README.Users
index af0fe06..a1f05de 100644
--- a/doc/README.Users
+++ b/doc/README.Users
@@ -109,3 +109,17 @@ not moved to the mail headers part of the email, while adding a header into the
 mail body still trigger the reportbug recognition code that will move the header
 to mail headers part if not a "common" pseudo-header (like 'Usertags',
 'Severity', or 'Package' and so on).
+
+Network Errors and Timeout
+==========================
+
+There are situations where a network error is returned, for example:
+"Unable to connect to BTS". These of course can be caused by a network
+unavailability.
+
+Another explanation can be that the remote resource is so slow to
+respond (or it's stale) and a timeout is triggered. By default this
+timeout is set to 1 minute; so in case of such an error, if you're
+unsure that it's a clear network outage, you can try to pass
+`--timeout <secs>' to either `reportbug' or `querybts' and see if it
+solves the issue.
\ No newline at end of file
diff --git a/man/querybts.1 b/man/querybts.1
index 6c75d66..4b78558 100644
--- a/man/querybts.1
+++ b/man/querybts.1
@@ -47,6 +47,15 @@ behind a firewall.
 .B \-s, \-\-source
 Query on source packages, rather than binary packages.
 .TP
+.B \-\-timeout=SECONDS
+Specify the network timeout, the number of seconds to wait for a
+resource to respond. If nothing is specified, a default timeout of 1
+minute is selected.
+
+In case of a network error, there are chances it's due to a too low
+timeout: try passing the \-\-timeout option with a higher value than
+default.
+.TP
 .B \-u INTERFACE, \-\-ui=INTERFACE, \-\-interface=INTERFACE
 Specify the user interface to use.  Valid options are \fBtext\fP,
 \fBurwid\fP, \fBgtk2\fP; default is taken from the reportbug
diff --git a/man/reportbug.1 b/man/reportbug.1
index 9f054d1..fb4dfcc 100644
--- a/man/reportbug.1
+++ b/man/reportbug.1
@@ -356,6 +356,15 @@ use 'localhost' if you have a working mail server running on your
 machine.  If the \fBPORT\fP is omitted, the standard port for SMTP,
 port 25, is used.
 .TP
+.B \-\-timeout=SECONDS
+Specify the network timeout, the number of seconds to wait for a
+resource to respond. If nothing is specified, a default timeout of 1
+minute is selected.
+
+In case of a network error, there are chances it's due to a too low
+timeout: try passing the \-\-timeout option with a higher value than
+default.
+.TP
 .B \-\-tls
 If using SMTP, use Transport Layer Security (TLS) encryption to secure
 the connection to the mail server.  Some SMTP servers may require this
diff --git a/reportbug/checkbuildd.py b/reportbug/checkbuildd.py
index 08af795..c671dbd 100644
--- a/reportbug/checkbuildd.py
+++ b/reportbug/checkbuildd.py
@@ -70,12 +70,12 @@ class BuilddParser(sgmllib.SGMLParser):
 def archname():
     return commands.getoutput('dpkg --print-architecture')
 
-def check_built(src_package, arch=None, http_proxy=None):
+def check_built(src_package, timeout, arch=None, http_proxy=None):
     if not arch:
         arch = archname()
 
     try:
-        page = open_url(BUILDD_URL % (arch, src_package), http_proxy)
+        page = open_url(BUILDD_URL % (arch, src_package), http_proxy, timeout)
     except NoNetwork:
         return {}
     if not page:
diff --git a/reportbug/checkversions.py b/reportbug/checkversions.py
index 883b1a0..eb4a8a4 100644
--- a/reportbug/checkversions.py
+++ b/reportbug/checkversions.py
@@ -187,12 +187,12 @@ def later_version(a, b):
         return b
     return a
 
-def get_versions_available(package, dists=None, http_proxy=None, arch='i386'):
+def get_versions_available(package, timeout, dists=None, http_proxy=None, arch='i386'):
     if not dists:
         dists = ('stable', 'testing', 'unstable')
 
     try:
-        page = open_url(PACKAGES_URL % package, http_proxy)
+        page = open_url(PACKAGES_URL % package, http_proxy, timeout)
     except NoNetwork:
         return {}
     except urllib2.HTTPError, x:
@@ -225,11 +225,11 @@ def get_versions_available(package, dists=None, http_proxy=None, arch='i386'):
 
     return versions
 
-def get_newqueue_available(package, dists=None, http_proxy=None, arch='i386'):
+def get_newqueue_available(package, timeout, dists=None, http_proxy=None, arch='i386'):
     if dists is None:
         dists = ('unstable (new queue)', )
     try:
-        page = open_url(NEWQUEUE_URL, http_proxy)
+        page = open_url(NEWQUEUE_URL, http_proxy, timeout)
     except NoNetwork:
         return {}
     except urllib2.HTTPError, x:
@@ -259,9 +259,9 @@ def get_newqueue_available(package, dists=None, http_proxy=None, arch='i386'):
     #print 'HERE', gc.garbage
     return versions
 
-def get_incoming_version(package, http_proxy=None, arch='i386'):
+def get_incoming_version(package, timeout, http_proxy=None, arch='i386'):
     try:
-        page = open_url(INCOMING_URL, http_proxy)
+        page = open_url(INCOMING_URL, http_proxy, timeout)
     except NoNetwork:
         return None
     except urllib2.HTTPError, x:
@@ -289,22 +289,22 @@ def get_incoming_version(package, http_proxy=None, arch='i386'):
     del parser
     return None
 
-def check_available(package, version, dists=None, check_incoming=True,
-                    check_newqueue=True,
+def check_available(package, version, timeout, dists=None,
+                    check_incoming=True, check_newqueue=True,
                     http_proxy=None, arch='i386'):
     avail = {}
 
     if check_incoming:
-        iv = get_incoming_version(package, http_proxy, arch)
+        iv = get_incoming_version(package, timeout, http_proxy, arch)
         if iv:
             avail['incoming'] = iv
-    stuff = get_versions_available(package, dists, http_proxy, arch)
+    stuff = get_versions_available(package, timeout, dists, http_proxy, arch)
     avail.update(stuff)
     if check_newqueue:
         srcpackage = utils.get_source_name(package)
 	if srcpackage is None:
 	    srcpackage = package
-        stuff = get_newqueue_available(srcpackage, dists, http_proxy, arch)
+        stuff = get_newqueue_available(srcpackage, timeout, dists, http_proxy, arch)
         avail.update(stuff)
         #print gc.garbage, stuff
 
@@ -328,9 +328,9 @@ def check_available(package, version, dists=None, check_incoming=True,
 
 if __name__=='__main__':
     gc.set_debug(gc.DEBUG_LEAK)
-    print get_newqueue_available('reportbug')
+    print get_newqueue_available('reportbug', timeout=60)
     print gc.garbage
-    print check_available('reportbug', '3.7', arch='s390')
+    #print check_available('reportbug', timeout=60, '3.7', arch='s390')
     #print check_available('openssh-server', '1:4.2p1-8', arch='i386')
     #print check_available('openssh-server', '1:4.2p1-8', arch='kfreebsd-i386')
     time.sleep(1000)
diff --git a/reportbug/debianbts.py b/reportbug/debianbts.py
index 14830bb..57f5ffa 100644
--- a/reportbug/debianbts.py
+++ b/reportbug/debianbts.py
@@ -199,7 +199,7 @@ progenyother = {
     'debian-general' : 'Any non-package-specific bug',
     }
 
-def handle_debian_ftp(package, bts, ui, fromaddr, online=True, http_proxy=None):
+def handle_debian_ftp(package, bts, ui, fromaddr, timeout, online=True, http_proxy=None):
     body = reason = archs = ''
     suite = 'unstable'
     headers = []
@@ -317,7 +317,7 @@ def handle_debian_ftp(package, bts, ui, fromaddr, online=True, http_proxy=None):
     return (subject, severity, headers, pseudos, body, query)
 
 
-def handle_debian_release(package, bts, ui, fromaddr, online=True, http_proxy=None):
+def handle_debian_release(package, bts, ui, fromaddr, timeout, online=True, http_proxy=None):
     body = ''
     headers = []
     pseudos = []
@@ -455,7 +455,7 @@ itp_template = textwrap.dedent(u"""\
 """)
 
 
-def handle_wnpp(package, bts, ui, fromaddr, online=True, http_proxy=None):
+def handle_wnpp(package, bts, ui, fromaddr, timeout, online=True, http_proxy=None):
     short_desc = body = ''
     headers = []
     pseudos = []
@@ -497,7 +497,7 @@ def handle_wnpp(package, bts, ui, fromaddr, online=True, http_proxy=None):
     severity = 'normal'
     if tag in ('ITP', 'RFP'):
         if available and (not online or checkversions.check_available(
-            package, '0', http_proxy=http_proxy)):
+            package, '0', timeout, http_proxy=http_proxy)):
             if not ui.yes_no(
                 ('A package called %s already appears to exist (at least on '
                  'your system); continue?' % package),
@@ -948,8 +948,8 @@ class BTSParser(sgmllib.SGMLParser):
         if fixed:
             self.hierarchy = [('Bugs fixed in subsequent releases (%d bugs)' % len(fixed), fixed)] + newhierarchy
 
-def parse_html_report(number, url, http_proxy, followups=False, cgi=True):
-    page = open_url(url, http_proxy)
+def parse_html_report(number, url, http_proxy, timeout, followups=False, cgi=True):
+    page = open_url(url, http_proxy, timeout)
     if not page:
         return None
 
@@ -991,8 +991,8 @@ def parse_html_report(number, url, http_proxy, followups=False, cgi=True):
     return (title, output)
 
 # XXX: Need to handle charsets properly
-def parse_mbox_report(number, url, http_proxy, followups=False):
-    page = open_url(url, http_proxy)
+def parse_mbox_report(number, url, http_proxy, timeout, followups=False):
+    page = open_url(url, http_proxy, timeout)
     if not page:
         return None
 
@@ -1047,11 +1047,11 @@ def parse_mbox_report(number, url, http_proxy, followups=False):
     title = "#%d: %s" % (number, title)
     return (title, output)
 
-def get_cgi_reports(package, system='debian', http_proxy='', archived=False,
-                    source=False, version=None):
+def get_cgi_reports(package, timeout, system='debian', http_proxy='',
+                    archived=False, source=False, version=None):
     try:
         page = open_url(cgi_package_url(system, package, archived, source,
-                                    version=version), http_proxy)
+                                    version=version), http_proxy, timeout)
     except:
         raise NoNetwork
 
@@ -1091,12 +1091,12 @@ def get_cgi_reports(package, system='debian', http_proxy='', archived=False,
 
     return data
 
-def get_cgi_report(number, system='debian', http_proxy='', archived=False,
+def get_cgi_report(number, timeout, system='debian', http_proxy='', archived=False,
                    followups=False):
     number = int(number)
 
     url = cgi_report_url(system, number, archived='no', mbox=True)
-    return parse_mbox_report(number, url, http_proxy, followups)
+    return parse_mbox_report(number, url, http_proxy, timeout, followups)
     #return parse_html_report(number, url, http_proxy, followups, cgi=True)
 
 def get_btsroot(system, mirrors=None):
@@ -1107,12 +1107,12 @@ def get_btsroot(system, mirrors=None):
                 return alternates[mirror]
     return SYSTEMS[system].get('btsroot', '')
 
-def get_reports(package, system='debian', mirrors=None, version=None,
+def get_reports(package, timeout, system='debian', mirrors=None, version=None,
                 http_proxy='', archived=False, source=False):
     if isinstance(package, basestring):
         if SYSTEMS[system].get('cgiroot'):
             try:
-                result = get_cgi_reports(package, system, http_proxy, archived,
+                result = get_cgi_reports(package, timeout, system, http_proxy, archived,
                                      source, version=version)
             except:
                 raise NoNetwork
@@ -1120,7 +1120,7 @@ def get_reports(package, system='debian', mirrors=None, version=None,
 
         url = package_url(system, package, mirrors, source)
         try:
-            page = open_url(url, http_proxy)
+            page = open_url(url, http_proxy, timeout)
         except:
             raise NoNetwork
         if not page:
@@ -1147,7 +1147,7 @@ def get_reports(package, system='debian', mirrors=None, version=None,
     package = [int(x) for x in package]
     package.sort()
     for bug in package:
-        result = get_report(bug, system, mirrors, http_proxy, archived)
+        result = get_report(bug, timeout, system, mirrors, http_proxy, archived)
         if result:
             title, body = result
             this_hierarchy.append(title)
@@ -1159,24 +1159,24 @@ def get_reports(package, system='debian', mirrors=None, version=None,
 
     return bugcount, title, hierarchy
 
-def get_report(number, system='debian', mirrors=None,
+def get_report(number, timeout, system='debian', mirrors=None,
                http_proxy='', archived=False, followups=False):
     number = int(number)
     if SYSTEMS[system].get('cgiroot'):
-        result = get_cgi_report(number, system, http_proxy, archived,
-                                followups)
+        result = get_cgi_report(number, timeout, system, http_proxy,
+                                archived, followups)
         if result: return result
 
     url = report_url(system, number, mirrors)
     if not url: return None
 
-    return parse_html_report(number, url, http_proxy, followups, cgi=False)
+    return parse_html_report(number, url, http_proxy, timeout, followups, cgi=False)
 
 class NullParser(sgmllib.SGMLParser):
     def __init__(self):
         sgmllib.SGMLParser.__init__(self)
 
 if __name__ == '__main__':
-    data = get_cgi_reports('reportbug')
+    data = get_cgi_reports('reportbug', timeout=60)
     pprint.pprint(data)
     time.sleep(1000)
diff --git a/reportbug/ui/gtk2_ui.py b/reportbug/ui/gtk2_ui.py
index 1e40a6a..50ec332 100644
--- a/reportbug/ui/gtk2_ui.py
+++ b/reportbug/ui/gtk2_ui.py
@@ -319,7 +319,7 @@ class BugReport (object):
 # BTS GUI
 
 class BugPage (gtk.EventBox, threading.Thread):
-    def __init__ (self, assistant, dialog, number, queryonly, bts, mirrors, http_proxy, archived):
+    def __init__ (self, assistant, dialog, number, queryonly, bts, mirrors, http_proxy, timeout, archived):
         threading.Thread.__init__ (self)
         gtk.EventBox.__init__ (self)
         self.setDaemon (True)
@@ -332,6 +332,7 @@ class BugPage (gtk.EventBox, threading.Thread):
         self.bts = bts
         self.mirrors = mirrors
         self.http_proxy = http_proxy
+        self.timeout = timeout
         self.archived = archived
 
         vbox = gtk.VBox (spacing=12)
@@ -347,7 +348,8 @@ class BugPage (gtk.EventBox, threading.Thread):
         # Start the progress bar
         gobject.timeout_add (10, self.pulse)
 
-        info = debianbts.get_report (int (self.number), self.bts, mirrors=self.mirrors,
+        info = debianbts.get_report (int (self.number), self.timeout,
+                                     self.bts, mirrors=self.mirrors,
                                      http_proxy=self.http_proxy, archived=self.archived)
         if not info:
             self.application.run_once_in_main_thread (self.not_found)
@@ -840,11 +842,12 @@ class HandleBTSQueryPage (TreePage):
     default_complete = True
     value_column = 0
 
-    def sync_pre_operation (self, package, bts, mirrors=None, http_proxy="", queryonly=False, screen=None,
+    def sync_pre_operation (self, package, bts, timeout, mirrors=None, http_proxy="", queryonly=False, screen=None,
                             archived='no', source=False, title=None, version=None, buglist=None):
         self.bts = bts
         self.mirrors = mirrors
         self.http_proxy = http_proxy
+        self.timeout = timeout
         self.archived = archived
 
         self.queryonly = queryonly
@@ -871,7 +874,7 @@ class HandleBTSQueryPage (TreePage):
 
         try:
             (count, sectitle, hierarchy) = debianbts.get_reports (
-                package, bts, mirrors=mirrors, version=version,
+                package, timeout, bts, mirrors=mirrors, version=version,
                 http_proxy=http_proxy, archived=archived, source=source)
 
             if not count:
@@ -959,7 +962,7 @@ class HandleBTSQueryPage (TreePage):
 
         dialog = BugsDialog (self.assistant, self.queryonly)
         for id in bug_ids:
-            dialog.show_bug (id, self.bts, self.mirrors, self.http_proxy, self.archived)
+            dialog.show_bug (id, self.bts, self.mirrors, self.http_proxy, self.timeout, self.archived)
         dialog.show_all ()
 
     def is_valid (self, value):
@@ -1019,7 +1022,7 @@ class ShowReportPage (Page):
     default_complete = True
 
     def create_widget (self):
-        self.page = BugPage (self.assistant, None, None, None, None, None, None, None)
+        self.page = BugPage (self.assistant, None, None, None, None, None, None, None, None)
         return self.page
 
     def get_value (self):
@@ -1033,11 +1036,12 @@ class ShowReportPage (Page):
             self.page_type = gtk.ASSISTANT_PAGE_CONFIRM
         return args, kwargs
 
-    def execute (self, number, system, mirrors, http_proxy, queryonly=False, title='', archived='no'):
+    def execute (self, number, system, mirrors, http_proxy, timeout, queryonly=False, title='', archived='no'):
         self.page.number = number
         self.page.bts = system
         self.page.mirrors = mirrors
         self.page.http_proxy = http_proxy
+        self.page.timeout = timeout
         self.page.queryonly = queryonly
         self.page.archived = archived
         self.page.start ()
diff --git a/reportbug/ui/text_ui.py b/reportbug/ui/text_ui.py
index a6a246d..d698227 100644
--- a/reportbug/ui/text_ui.py
+++ b/reportbug/ui/text_ui.py
@@ -388,14 +388,14 @@ def menu(par, options, prompt, default=None, title=None, any_ok=False,
 
 # Things that are very UI dependent go here
 def show_report(number, system, mirrors,
-                http_proxy, screen=None, queryonly=False, title='',
+                http_proxy, timeout, screen=None, queryonly=False, title='',
                 archived='no'):
     sysinfo = debianbts.SYSTEMS[system]
     ewrite('Retrieving report #%d from %s bug tracking system...\n',
            number, sysinfo['name'])
 
     try:
-        info = debianbts.get_report(number, system, mirrors=mirrors,
+        info = debianbts.get_report(number, timeout, system, mirrors=mirrors,
                                     followups=1,
                                     http_proxy=http_proxy, archived=archived)
     except:
@@ -479,7 +479,7 @@ def show_report(number, system, mirrors,
             current_message -= 1
     return
 
-def handle_bts_query(package, bts, mirrors=None, http_proxy="",
+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):
     root = debianbts.SYSTEMS[bts].get('btsroot')
@@ -503,13 +503,13 @@ def handle_bts_query(package, bts, mirrors=None, http_proxy="",
     bugs = []
     try:
         (count, title, hierarchy)=debianbts.get_reports(
-            package, bts, mirrors=mirrors, version=version,
+            package, timeout, bts, mirrors=mirrors, version=version,
             source=source, http_proxy=http_proxy, archived=archived)
 
         if debianbts.SYSTEMS[bts].has_key('namefmt'):
             package2 = debianbts.SYSTEMS[bts]['namefmt'] % package
             (count2, title2, hierarchy2) = \
-                     debianbts.get_reports(package2, bts,
+                     debianbts.get_reports(package2, timeout, bts,
                                            mirrors=mirrors, source=source,
                                            http_proxy=http_proxy,
                                            version=version)
@@ -574,7 +574,7 @@ def handle_bts_query(package, bts, mirrors=None, http_proxy="",
             ewrite('%d bug reports found:\n\n', count)
 
         return browse_bugs(hierarchy, count, bugs, bts, queryonly,
-                           mirrors, http_proxy, screen, title, package)
+                           mirrors, http_proxy, timeout, screen, title, package)
 
     except (IOError, NoNetwork):
         ewrite('Unable to connect to %s BTS; ', debianbts.SYSTEMS[bts]['name'])
@@ -585,7 +585,7 @@ def handle_bts_query(package, bts, mirrors=None, http_proxy="",
             raise NoNetwork
 
 def browse_bugs(hierarchy, count, bugs, bts, queryonly, mirrors,
-                http_proxy, screen, title, package):
+                http_proxy, timeout, screen, title, package):
     try:
         output_encoding = locale.getpreferredencoding()
     except locale.Error, msg:
@@ -725,7 +725,7 @@ def browse_bugs(hierarchy, count, bugs, bts, queryonly, mirrors,
                                 if number not in bugs and 1 <= number <= len(bugs):
                                     number = bugs[number-1]
                                 res = show_report(number, bts, mirrors,
-                                                  http_proxy,
+                                                  http_proxy, timeout,
                                                   queryonly=queryonly,
                                                   screen=screen,
                                                   title=title)
@@ -934,7 +934,7 @@ def search_bugs(hierarchyfull, bts, queryonly, mirrors,
                                 if number not in bugs and 1 <= number <= len(bugs):
                                     number = bugs[number-1]
                                 res = show_report(number, bts, mirrors,
-                                                  http_proxy,
+                                                  http_proxy, timeout,
                                                   queryonly=queryonly,
                                                   screen=screen,
                                                   title=title)
diff --git a/reportbug/ui/urwid_ui.py b/reportbug/ui/urwid_ui.py
index ad39335..8f5e32f 100644
--- a/reportbug/ui/urwid_ui.py
+++ b/reportbug/ui/urwid_ui.py
@@ -492,7 +492,7 @@ def select_multiple(par, options, prompt, title=None, order=None, extras=None):
 
 # Things that are very UI dependent go here
 def show_report(number, system, mirrors,
-                http_proxy, screen=None, queryonly=False, title='',
+                http_proxy, timeout, screen=None, queryonly=False, title='',
                 archived='no'):
     from reportbug import debianbts
 
@@ -504,7 +504,7 @@ def show_report(number, system, mirrors,
     display_message('Retrieving report #%d from %s bug tracking system...',
         number, sysinfo['name'], title=title, ui=ui)
 
-    info = debianbts.get_report(number, system, mirrors=mirrors,
+    info = debianbts.get_report(number, timeout, system, mirrors=mirrors,
                                 http_proxy=http_proxy, archived=archived)
     if not info:
         long_message('Bug report #%d not found.', number, title=title, ui=ui)
@@ -530,7 +530,7 @@ def show_report(number, system, mirrors,
         launch_browser(debianbts.get_report_url(system, number, archived))
     return
 
-def handle_bts_query(package, bts, mirrors=None, http_proxy="",
+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):
     from reportbug import debianbts
@@ -562,7 +562,7 @@ def handle_bts_query(package, bts, mirrors=None, http_proxy="",
     result = None
     try:
         (count, sectitle, hierarchy) = debianbts.get_reports(
-            package, bts, mirrors=mirrors, version=version,
+            package, timeout, bts, mirrors=mirrors, version=version,
             http_proxy=http_proxy, archived=archived, source=source)
 
         if not count:
@@ -618,7 +618,7 @@ def handle_bts_query(package, bts, mirrors=None, http_proxy="",
                 else:
                     p = info
                     res = show_report(int(p), bts, mirrors, http_proxy,
-                                      queryonly=queryonly)
+                                      timeout, queryonly=queryonly)
                     if res:
                         result = res
                         break
diff --git a/reportbug/urlutils.py b/reportbug/urlutils.py
index 29b7538..66d7de6 100644
--- a/reportbug/urlutils.py
+++ b/reportbug/urlutils.py
@@ -42,9 +42,6 @@ from __init__ import VERSION_NUMBER
 
 UA_STR = 'reportbug/'+VERSION_NUMBER+' (Debian)'
 
-# Set timeout to 60 secs (1 min), cfr bug #516449
-socket.setdefaulttimeout(60)
-
 def decode (page):
     "gunzip or deflate a compressed page"
     #print page.info().headers
@@ -130,7 +127,11 @@ def urlopen(url, proxies=None, data=None):
 
 # Global useful URL opener; returns None if the page is absent, otherwise
 # like urlopen
-def open_url(url, http_proxy=None):
+def open_url(url, http_proxy=None, timeout=60):
+    # Set timeout to 60 secs (1 min), cfr bug #516449
+    # in #572316 we set a user-configurable timeout
+    socket.setdefaulttimeout(timeout)
+
     proxies = urllib.getproxies()
     if http_proxy:
         proxies['http'] = http_proxy

-- 
Reportbug - reports bugs in the Debian distribution



More information about the Reportbug-commits mailing list