main.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 
00003 # Software License Agreement (BSD License)
00004 #
00005 # Copyright (c) 2012, Willow Garage, Inc.
00006 # All rights reserved.
00007 #
00008 # Redistribution and use in source and binary forms, with or without
00009 # modification, are permitted provided that the following conditions
00010 # are met:
00011 #
00012 #  * Redistributions of source code must retain the above copyright
00013 #    notice, this list of conditions and the following disclaimer.
00014 #  * Redistributions in binary form must reproduce the above
00015 #    copyright notice, this list of conditions and the following
00016 #    disclaimer in the documentation and/or other materials provided
00017 #    with the distribution.
00018 #  * Neither the name of Willow Garage, Inc. nor the names of its
00019 #    contributors may be used to endorse or promote products derived
00020 #    from this software without specific prior written permission.
00021 #
00022 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00023 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00024 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00025 # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
00026 # COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00027 # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00028 # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00029 # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00030 # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00031 # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
00032 # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00033 # POSSIBILITY OF SUCH DAMAGE.
00034 
00035 import argparse
00036 import os
00037 import sys
00038 
00039 import roslib
00040 roslib.load_manifest('rqt_gui')
00041 
00042 from qt_gui.main import Main as Base
00043 
00044 
00045 class Main(Base):
00046 
00047     def __init__(self, filename=None):
00048         super(Main, self).__init__(filename, 'rqt_gui')
00049         self._plugin_cache = None
00050 
00051     def _add_arguments(self, parser):
00052         super(Main, self)._add_arguments(parser)
00053 
00054         parser.add_argument('-c', '--cache-plugins', dest='cache_plugins', default=False, action='store_true',
00055                           help='cache list of available plugins (trading faster start-up for not up-to-date plugin list)')
00056 
00057         # ignore ROS specific remapping arguments (see http://www.ros.org/wiki/Remapping%20Arguments)
00058         for arg in ['__name', '__log', '__ip', '__hostname', '__master', '__ns']:
00059             parser.add_argument(arg, nargs='?', help=argparse.SUPPRESS)
00060 
00061     def _add_plugin_providers(self):
00062         if self._options.cache_plugins:
00063             from .ros_plugin_provider_cache import RosPluginProviderCache
00064             self._plugin_cache = RosPluginProviderCache()
00065             self._plugin_cache.load()
00066 
00067         try:
00068             from .rospkg_plugin_provider import RospkgPluginProvider
00069             ActualRosPluginProvider = RospkgPluginProvider
00070         except ImportError:
00071             from .roslib_plugin_provider import RoslibPluginProvider
00072             ActualRosPluginProvider = RoslibPluginProvider
00073 
00074         # do not import earlier as it would import Qt stuff without the proper initialization from qt_gui.main
00075         from qt_gui.recursive_plugin_provider import RecursivePluginProvider
00076         self.plugin_providers.append(ActualRosPluginProvider('qt_gui', 'qt_gui_py::Plugin'))
00077         self.plugin_providers.append(RecursivePluginProvider(ActualRosPluginProvider('qt_gui', 'qt_gui_py::PluginProvider')))
00078         self.plugin_providers.append(RecursivePluginProvider(ActualRosPluginProvider('rqt_gui', 'rqt_gui_py::PluginProvider')))
00079 
00080     def _caching_hook(self):
00081         if self._plugin_cache is not None:
00082             self._plugin_cache.save()
00083 
00084     def _add_reload_paths(self, reload_importer):
00085         super(Main, self)._add_reload_paths(reload_importer)
00086         reload_importer.add_reload_path(os.path.join(os.path.dirname(__file__), *('..',) * 4))
00087 
00088 
00089 if __name__ == '__main__':
00090     main = Main()
00091     sys.exit(main.main())


rqt_gui
Author(s): Dirk Thomas
autogenerated on Fri Jan 3 2014 11:53:47