plugin_manager_dbus_interface.py
Go to the documentation of this file.
1 # Copyright (c) 2011, Dirk Thomas, Dorian Scholz, TU Darmstadt
2 # All rights reserved.
3 #
4 # Redistribution and use in source and binary forms, with or without
5 # modification, are permitted provided that the following conditions
6 # are met:
7 #
8 # * Redistributions of source code must retain the above copyright
9 # notice, this list of conditions and the following disclaimer.
10 # * Redistributions in binary form must reproduce the above
11 # copyright notice, this list of conditions and the following
12 # disclaimer in the documentation and/or other materials provided
13 # with the distribution.
14 # * Neither the name of the TU Darmstadt nor the names of its
15 # contributors may be used to endorse or promote products derived
16 # from this software without specific prior written permission.
17 #
18 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
21 # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
22 # COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
23 # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
24 # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25 # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26 # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
28 # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 # POSSIBILITY OF SUCH DAMAGE.
30 
31 import dbus
32 from dbus.service import BusName, Object
33 
34 from python_qt_binding.QtCore import qDebug, qWarning
35 
36 
38  """DBus service of the `PluginManager` available on the unique bus name."""
39 
40  def __init__(self, plugin_manager, application_context):
41  bus_name = BusName(application_context.dbus_unique_bus_name, dbus.SessionBus())
42  super(PluginManagerDBusInterface, self).__init__(bus_name, '/PluginManager')
43  self._plugin_manager = plugin_manager
44 
45  @dbus.service.method('org.ros.qt_gui.PluginManager', in_signature='ss', out_signature='is')
46  def start_plugin(self, plugin_name, argv):
47  qDebug('PluginManagerDBusInterface.start_plugin(%s)' % plugin_name)
48  plugins = self._plugin_manager.find_plugins_by_name(plugin_name)
49  if len(plugins) == 0:
50  msg = 'PluginManagerDBusInterface.start_plugin() found no plugin matching "%s"' % \
51  plugin_name
52  qWarning(msg)
53  return (1, msg)
54  elif len(plugins) > 1:
55  msg = 'PluginManagerDBusInterface.start_plugin() found multiple plugins ' \
56  'matching "%s"\n%s' % (plugin_name, '\n'.join(plugins.values()))
57  qWarning(msg)
58  return (1, msg)
59  plugin_id = plugins.keys()[0]
60  self._plugin_manager.load_plugin(plugin_id, argv=argv.split(' ') if argv else [])
61  return (0, plugin_id)


qt_gui
Author(s): Dirk Thomas
autogenerated on Tue Apr 13 2021 03:03:12