[Reportbug-commits] [SCM] Reportbug - reports bugs in the Debian distribution branch, master, updated. 4.6-17-gcdad7ce

Luca Bruno lethalman88 at gmail.com
Wed Sep 2 21:12:46 UTC 2009


The following commit has been merged in the master branch:
commit 2aa6d15c849f8303c52b82a054fab683d927ccbd
Author: Luca Bruno <lethalman88 at gmail.com>
Date:   Mon Aug 31 12:14:55 2009 +0200

    Fall back to text interface if UI is not initializable; Closes: #534876

diff --git a/bin/reportbug b/bin/reportbug
index 68f18d0..4e73cc8 100755
--- a/bin/reportbug
+++ b/bin/reportbug
@@ -486,7 +486,7 @@ def offer_configuration(options):
     if options.configure or not options.interface:
         interface = ui.menu(
             'Please choose the default interface for reportbug.', AVAILABLE_UIS,
-            'Select interface: ', options.interface, order=['text'])
+            'Select interface: ', options.interface, order=['text', 'urwid', 'gtk2'])
     else:
         interface = options.interface
 
@@ -928,15 +928,21 @@ def main():
 
         try:
             lib_package = __import__('reportbug.ui', fromlist=[iface])
-            ui = getattr(lib_package, iface)
+            newui = getattr(lib_package, iface)
         except UINotImportable, msg:
             ui.long_message('*** Unable to import %s interface: %s '
                             'Falling back to text interface.\n',
                             interface, msg)
             ewrite('\n')
 
-        ui.initialize ()
-        submit.ui = ui
+        if newui.initialize ():
+            ui = newui
+            submit.ui = ui
+        else:
+            ui.long_message('*** Unable to initialize %s interface. '
+                            'Falling back to text interface.\n',
+                            interface)
+
         # Add INTERFACE as an environment variable to access it from the
         # script gathering the special information for reportbug, when
         # a new bug should be filed against it.
diff --git a/debian/changelog b/debian/changelog
index 14d9e4a..09ef5ab 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -22,8 +22,11 @@ reportbug (4.7) UNRELEASED; urgency=low
   * reportbug/ui/gtk_ui.py
     - wrap words when editing bug reports
     - workaround possible GTK+ regression to show the intro page
+  * bin/reportbug
+    - fallback to text interface if UI can't be initialized; Closes: #534876
+    - set UI order to text, urwid, gtk2
 
- -- Luca Bruno <lethalman88 at gmail.com>  Mon, 31 Aug 2009 11:39:04 +0200
+ -- Luca Bruno <lethalman88 at gmail.com>  Mon, 31 Aug 2009 12:11:33 +0200
 
 reportbug (4.6) unstable; urgency=low
 
diff --git a/reportbug/ui/__init__.py b/reportbug/ui/__init__.py
index ddf532b..1c42c98 100644
--- a/reportbug/ui/__init__.py
+++ b/reportbug/ui/__init__.py
@@ -28,7 +28,7 @@ __all__ = ['text_ui', 'urwid_ui', 'gtk2_ui']
 
 UIS = {'text': 'A text-oriented console user interface',
        'urwid': 'A menu-based console user interface',
-       'gtk2': 'A graphical (GTK+) user interface'}
+       'gtk2': 'A graphical (GTK+) user interface. Requires python-vte package to work.'}
 
 # Only the available UIs
 AVAILABLE_UIS = {}
@@ -49,7 +49,6 @@ for uis in UIS.keys():
         # we can't import uis, so just skip it
         pass
 
-
 def getUI(ui):
     """Returns the requested UI, or default to text if not available"""
 
diff --git a/reportbug/ui/gtk2_ui.py b/reportbug/ui/gtk2_ui.py
index d7d575d..894006a 100644
--- a/reportbug/ui/gtk2_ui.py
+++ b/reportbug/ui/gtk2_ui.py
@@ -1438,7 +1438,8 @@ def initialize ():
     try:
         vte = __import__ ("vte")
     except ImportError:
-        message = "Please install the %s package to use the gtk2 interface."
+        message = """Please install the %s package to use the gtk2 interface. 
+Falling back to text interface."""
         dialog = gtk.MessageDialog (None, gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
                                     gtk.MESSAGE_INFO, gtk.BUTTONS_CLOSE, None)
         dialog.set_markup (message % "<b>python-vte</b>")
@@ -1446,7 +1447,7 @@ def initialize ():
         dialog.destroy ()
         while gtk.events_pending ():
             gtk.main_iteration ()
-        sys.exit (1)
+        return False
 
     # Exception hook
     oldhook = sys.excepthook
@@ -1464,6 +1465,7 @@ def initialize ():
     forward_operations (application, dialogs)
 
     application.start ()
+    return True
 
 def test ():
     # Write some tests here
diff --git a/reportbug/ui/text_ui.py b/reportbug/ui/text_ui.py
index dc7eb98..e3f7f6c 100644
--- a/reportbug/ui/text_ui.py
+++ b/reportbug/ui/text_ui.py
@@ -1013,4 +1013,4 @@ def spawn_editor(message, filename, editor, charset='utf-8'):
     return (newmessage, newmessage != message)
 
 def initialize ():
-    pass
+    return True
diff --git a/reportbug/ui/urwid_ui.py b/reportbug/ui/urwid_ui.py
index e0b000c..5f87b0f 100644
--- a/reportbug/ui/urwid_ui.py
+++ b/reportbug/ui/urwid_ui.py
@@ -649,7 +649,7 @@ palette = [
     ]
 
 def initialize ():
-    pass
+    return True
 
 def test():
     import time

-- 
Reportbug - reports bugs in the Debian distribution



More information about the Reportbug-commits mailing list