Please rearrange these imports - they should be like this:
import dbus
from dbus.mainloop.qt import DBusQtMainLoop
from PyQt4 import QtGui
import sys
from autopilot.vis.bus_enumerator import BusEnumerator
from autopilot.vis.main_window import MainWindow
i.e.- imports should be system first, then local, and should be ordered alphabetically. Please also fix the imports at the top of bus_enumerator.py (yes, I realise that's my code :))
I think this is already defined in autopilot.introspection.dbus. If it's not, it should be defined there (it's certainly used there). Let's define this in one palce (in that module) and import & use it here.
These should be wrapped inside a try: ... except dbus.DBusException block. If the interface dissapears before you get to it this will throw. This will also throw if the app doesn't send a reply, or if a bunch of other things go wrong.
210 + """itemData will return a tuple with (obj, iface) details pair."""
This should be a comment, not a docstring for the method.
Hi,
6 +import sys vis.bus_ enumerator import BusEnumerator vis.main_ window import MainWindow
7 +import dbus
8 +from dbus.mainloop.qt import DBusQtMainLoop
9 +from autopilot.
10 +from autopilot.
11 +from PyQt4 import QtGui
Please rearrange these imports - they should be like this:
import dbus
from dbus.mainloop.qt import DBusQtMainLoop
from PyQt4 import QtGui
import sys
from autopilot. vis.bus_ enumerator import BusEnumerator vis.main_ window import MainWindow
from autopilot.
i.e.- imports should be system first, then local, and should be ordered alphabetically. Please also fix the imports at the top of bus_enumerator.py (yes, I realise that's my code :))
142 + AP_DBUS_IFACE_STR = "com.canonical. Autopilot. Introspection"
I think this is already defined in autopilot. introspection. dbus. If it's not, it should be defined there (it's certainly used there). Let's define this in one palce (in that module) and import & use it here.
179 + # print "Updating interface list: %s, %s, %s" % (conn, obj, iface)
Please remove.
180 + dbus_object = session_ bus.get_ object( str(conn) , str(obj)) dbus_object, Autopilot. Introspection' ) GetState( "/")[0]
181 + dbus_iface = dbus.Interface(
182 + 'com.canonical.
183 + cls_name, cls_state = dbus_iface.
These should be wrapped inside a try: ... except dbus.DBusException block. If the interface dissapears before you get to it this will throw. This will also throw if the app doesn't send a reply, or if a bunch of other things go wrong.
210 + """itemData will return a tuple with (obj, iface) details pair."""
This should be a comment, not a docstring for the method.
221 + object_details = dict(filter(lambda i: i[0] != "Children", details. iteritems( )))
222 + object_
A nicer way to write this would be:
object_ detail. pop("Children" , None)
or maybe:
if "Children" in object_details: details[ "Children" ]
del object_
225 + if key == "Children":
226 + continue
I don't understand why you're doing this, given the code above...
242 + import dbus
Please remove - you're already importing this at the top of the file.
256 + if isinstance( dbus_type, dbus.Array): [dbus_string_ rep(i) for i in dbus_type])
257 + return ', '.join(
Please make this work for dbus.Struct as well. That will make it behave nicely with QSize, QRect, QPoint, and a few other types that Qt apps export.
Other than those issues, looks great!