Merge lp:~dobey/ubuntuone-dev-tools/gi-glib-fallback into lp:ubuntuone-dev-tools

Proposed by dobey on 2012-04-25
Status: Merged
Approved by: Brian Curtin on 2012-04-26
Approved revision: 68
Merged at revision: 67
Proposed branch: lp:~dobey/ubuntuone-dev-tools/gi-glib-fallback
Merge into: lp:ubuntuone-dev-tools
Diff against target: 47 lines (+18/-6)
2 files modified
bin/u1trial (+1/-1)
ubuntuone/devtools/reactors/gi.py (+17/-5)
To merge this branch: bzr merge lp:~dobey/ubuntuone-dev-tools/gi-glib-fallback
Reviewer Review Type Date Requested Status
Brian Curtin (community) Approve on 2012-04-26
Alejandro J. Cura (community) 2012-04-25 Approve on 2012-04-25
Review via email: mp+103561@code.launchpad.net

Commit Message

Fall back to the gtk2/glib2 reactors if gtk3/gi reactors aren't available
Default to using gi reactor in u1trial

To post a comment you must log in.
68. By dobey on 2012-04-25

Remove the absolute_import import

Alejandro J. Cura (alecu) wrote :

Code looks good; all tests pass on both Oneiric and Precise.

review: Approve
Brian Curtin (brian.curtin) wrote :

Looks good.

You need to change this, but you have Python 3-like print usage in there, although it's just passing a single tuple to the print statement.

review: Approve
dobey (dobey) wrote :

> You need to change this, but you have Python 3-like print usage in there,
> although it's just passing a single tuple to the print statement.

As we will be needing to support Python 3 for 12.10 as best we can, I thought it best to start using the print statement as a function, as is required in Python 3, even though I did not add the __future__ import to enforce it. I suspect we'll need to get several of our lower level projects working with Python 3 soon.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bin/u1trial'
2--- bin/u1trial 2012-03-30 17:44:03 +0000
3+++ bin/u1trial 2012-04-25 20:31:18 +0000
4@@ -236,7 +236,7 @@
5 ["loop", None, 1],
6 ["ignore-modules", "i", ""],
7 ["ignore-paths", "p", ""],
8- ["reactor", "r", "glib"],
9+ ["reactor", "r", "gi"],
10 ]
11
12 def __init__(self):
13
14=== modified file 'ubuntuone/devtools/reactors/gi.py'
15--- ubuntuone/devtools/reactors/gi.py 2012-03-30 17:44:03 +0000
16+++ ubuntuone/devtools/reactors/gi.py 2012-04-25 20:31:18 +0000
17@@ -29,13 +29,25 @@
18 REACTOR_URL = 'http://twistedmatrix.com/trac/ticket/4558'
19
20
21+def load_reactor(reactor_name=None):
22+ """Load the reactor module and return it."""
23+ return __import__(reactor_name, None, None, [''])
24+
25+
26 def install(options=None):
27 """Install the reactor and parse any options we might need."""
28- reactor_name = None
29+ reactor = None
30 if options is not None and options['gui']:
31- reactor_name = 'twisted.internet.gtk3reactor'
32+ try:
33+ reactor = load_reactor('twisted.internet.gtk3reactor')
34+ except ImportError:
35+ print('Falling back to gtk2reactor module.')
36+ reactor = load_reactor('twisted.internet.gtk2reactor')
37 else:
38- reactor_name = 'twisted.internet.gireactor'
39+ try:
40+ reactor = load_reactor('twisted.internet.gireactor')
41+ except ImportError:
42+ print('Falling back to glib2reactor module.')
43+ reactor = load_reactor('twisted.internet.glib2reactor')
44
45- glibreactor = __import__(reactor_name, None, None, [''])
46- glibreactor.install()
47+ reactor.install()

Subscribers

People subscribed via source and target branches

to all changes: