Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 from dbus.service import BusName, Object
00032 import dbus
00033
00034 from python_qt_binding.QtCore import qDebug, qWarning
00035
00036
00037 class PluginManagerDBusInterface(Object):
00038
00039 """DBus service of the `PluginManager` available on the unique bus name."""
00040
00041 def __init__(self, plugin_manager, application_context):
00042 bus_name = BusName(application_context.dbus_unique_bus_name, dbus.SessionBus())
00043 super(PluginManagerDBusInterface, self).__init__(bus_name, '/PluginManager')
00044 self._plugin_manager = plugin_manager
00045
00046 @dbus.service.method('org.ros.qt_gui.PluginManager', in_signature='ss', out_signature='is')
00047 def start_plugin(self, plugin_name, argv):
00048 qDebug('PluginManagerDBusInterface.start_plugin(%s)' % plugin_name)
00049 plugins = self._plugin_manager.find_plugins_by_name(plugin_name)
00050 if len(plugins) == 0:
00051 msg = 'PluginManagerDBusInterface.start_plugin() found no plugin matching "%s"' % plugin_name
00052 qWarning(msg)
00053 return (1, msg)
00054 elif len(plugins) > 1:
00055 msg = 'PluginManagerDBusInterface.start_plugin() found multiple plugins matching "%s"\n%s' % (plugin_name, '\n'.join(plugins.values()))
00056 qWarning(msg)
00057 return (1, msg)
00058 plugin_id = plugins.keys()[0]
00059 self._plugin_manager.load_plugin(plugin_id, argv=argv.split(' ') if argv else [])
00060 return (0, plugin_id)