plugin_manager_dbus_interface.py
Go to the documentation of this file.
00001 # Copyright (c) 2011, Dirk Thomas, Dorian Scholz, TU Darmstadt
00002 # All rights reserved.
00003 #
00004 # Redistribution and use in source and binary forms, with or without
00005 # modification, are permitted provided that the following conditions
00006 # are met:
00007 #
00008 #   * Redistributions of source code must retain the above copyright
00009 #     notice, this list of conditions and the following disclaimer.
00010 #   * Redistributions in binary form must reproduce the above
00011 #     copyright notice, this list of conditions and the following
00012 #     disclaimer in the documentation and/or other materials provided
00013 #     with the distribution.
00014 #   * Neither the name of the TU Darmstadt nor the names of its
00015 #     contributors may be used to endorse or promote products derived
00016 #     from this software without specific prior written permission.
00017 #
00018 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00019 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00020 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00021 # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
00022 # COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00023 # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00024 # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00025 # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00026 # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00027 # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
00028 # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00029 # POSSIBILITY OF SUCH DAMAGE.
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)


qt_gui
Author(s): Dirk Thomas
autogenerated on Fri Aug 28 2015 12:15:40