Merge lp:~pitti/ubuntuone-control-panel/gi-fixes into lp:ubuntuone-control-panel
Status: | Merged | ||||
---|---|---|---|---|---|
Approved by: | Natalia Bidart on 2011-08-25 | ||||
Approved revision: | 206 | ||||
Merged at revision: | 204 | ||||
Proposed branch: | lp:~pitti/ubuntuone-control-panel/gi-fixes | ||||
Merge into: | lp:ubuntuone-control-panel | ||||
Diff against target: |
138 lines (+20/-16) 4 files modified
ubuntuone/controlpanel/dbus_service.py (+12/-4) ubuntuone/controlpanel/dbustests/test_dbus_service.py (+1/-1) ubuntuone/controlpanel/gui/gtk/gui.py (+2/-7) ubuntuone/controlpanel/gui/gtk/tests/test_gui.py (+5/-4) |
||||
To merge this branch: | bzr merge lp:~pitti/ubuntuone-control-panel/gi-fixes | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Natalia Bidart | 2011-08-22 | Approve on 2011-08-25 | |
Martin Pitt (community) | Abstain on 2011-08-25 | ||
dobey (community) | Abstain on 2011-08-25 | ||
Review via email:
|
Commit message
Make the library work with both GI and static bindings, and consistently use static bindings in the GTK UI. (LP: #829186)
Description of the change
pygobject >= 2.90 is now absolutely zero tolerant against importing both the
static and the GI version of a particular library. This was mostly the case
with 2.28 as well, but did work in some cases (like "import gobject; from
gi.repository import Gtk", in particular for "glib" and "gobject"). These now
cause errors as well.
The GTK frontend has a rather long dependency chain, and porting it to
GTK3/PyGI is going to take a while. It is too risky for Ubuntu Oneiric at this
point. (See lp:~pitti/+junk/u1-control-panel-pygi for my current progress with
this).
On the other hand, the backend already uses the Soup GNOME module, which does
not have an 1:1 equivalent with a static binding. So fix up the last remaining
bit to make this use the GI bindings consistently.
With the fix from this branch we can use the web client library from both
programs with static bindings (GTK frontend), as well as from programs which
use the gobject-
See bug 829186 for more details.
Natalia Bidart (nataliabidart) wrote : | # |
Very likely you will need to import it the humanize method, and make the callers do not use it like an instance method, but as a global function (ie remove the self.humanize calls and replace by calls to humanize directly, there is no point of having it as an instance method).
dobey (dobey) wrote : | # |
12 +if 'gobject' in sys.modules:
13 + import gobject as GObject
14 +else:
15 + from gi.repository import GObject
I'm pretty sure this if statement will always fail, even if the GI version isn't available, as sys.modules doesn't list what is available, but rather what is actively loaded in the current python process? Or at least, looking at sys.modules in python shell without loading anything else, doesn't seem to give particularly useful results for performing this sort of check.
And it's not clear to me why the GLib.format_
Martin Pitt (pitti) wrote : | # |
@Rodney: The 'gobject' in sys.modules works very well, and it's indeed intended to check what is already loaded into the Python process; that's exactly what we need to know -- "has anything before us already imported gobject, or any other static binding depending on it?" (such as glib or gtk). This check has been applied to some 10 other library packages, and is also the one that upstream uses:
http://
> And it's not clear to me why the GLib.format_
Because we can't use GLib (it's the GI binding) when the program importing dbus_service already has loaded static bindings (gobject, glib). Unfortunately the static glib does not export this function, so we can't fallback to the static variant in this case.
I'll change the code to use humanize() instead, I wasn't aware of this.
- 204. By Martin Pitt on 2011-08-23
-
Entirely drop gui/gtk/gui.py's humanize() method, use the one from ubuntuone.
controlpanel. gui instead
Natalia Bidart (nataliabidart) wrote : | # |
There is a failing test:
[ERROR]
Traceback (most recent call last):
File "/usr/lib/
testMethod()
File "/usr/lib/
result = test_method()
File "/home/
mainloop = self.mocker.
File "/usr/lib/
mock = self.proxy(object, spec, type, name, count, passthrough)
File "/usr/lib/
object = getattr(object, attr)
exceptions.
ubuntuone.
Fix for this would be:
=== modified file 'ubuntuone/
--- ubuntuone/
+++ ubuntuone/
@@ -107,7 +107,7 @@
rs()
- mainloop = "ubuntuone.
+ mainloop = "ubuntuone.
mainloop = self.mocker.
mainloop()
loop = self.mocker.mock()
Please also run ./run-tests after applying the fix since there are lint issues:
ubuntuone/
29: [E0611] No name 'GObject' in module 'gi.repository'
29: [W0404] Reimport 'GObject' (imported line 25)
Martin Pitt (pitti) wrote : | # |
Rodney explained what "Resubmit" really means; reverting my "Resubmit" then.
- 205. By Martin Pitt on 2011-08-25
-
test_dbus_
service. py: Fix mocker to use GObject, too
Martin Pitt (pitti) wrote : | # |
I pushed the mocker and pylint fixes.
- 206. By Martin Pitt on 2011-08-25
-
quiesce false-positive pylint warnings
The branch looks great, but, instead of reimplementing the humanize function, please use the one defined in ubuntone. controlpanel. gui.
Thanks a lot for helping us!