Skip to content

Commit

Permalink
Style changes (#143)
Browse files Browse the repository at this point in the history
* Style changes

* Indentation

* ROS2 compatible style changes

* Style

* Adding style changes based on PR feedback

* minor fixup
  • Loading branch information
brawner authored and mlautman committed Oct 31, 2018
1 parent 67a7020 commit ffcab92
Show file tree
Hide file tree
Showing 10 changed files with 39 additions and 29 deletions.
2 changes: 1 addition & 1 deletion rqt_gui/CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Changelog for package rqt_gui
0.2.9 (2013-06-06)
------------------
* make plugin resources relative to plugin.xml (`ros-visualization/qt_gui_core#16 <https://github.com/ros-visualization/qt_gui_core/issues/16>`_)
* use standard rospy function to filter remapping arguments (`#76 <https://github.com/ros-visualization/rqt/issues/76>`_)
* use standard rospy function to filter remapping arguments (`#76 <https://github.com/ros-visualization/rqt/issues/76>`_)
* fix help provider

0.2.8 (2013-01-11)
Expand Down
1 change: 1 addition & 0 deletions rqt_gui/setup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env python

from distutils.core import setup

from catkin_pkg.python_setup import generate_distutils_setup

d = generate_distutils_setup(
Expand Down
12 changes: 7 additions & 5 deletions rqt_gui/src/rqt_gui/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@
import os
import sys

import rospy
from rospkg.rospack import RosPack

from qt_gui.main import Main as Base

from rospkg.rospack import RosPack
import rospy


class Main(Base):

Expand All @@ -59,8 +59,10 @@ def main(self, argv=None, standalone=None, plugin_argument_provider=None):
argv = rospy.myargv(argv)

return super(
Main, self).main(argv, standalone=standalone, plugin_argument_provider=plugin_argument_provider,
plugin_manager_settings_prefix=str(hash(os.environ['ROS_PACKAGE_PATH'])))
Main, self).main(argv, standalone=standalone,
plugin_argument_provider=plugin_argument_provider,
plugin_manager_settings_prefix=str(
hash(os.environ['ROS_PACKAGE_PATH'])))

def create_application(self, argv):
from python_qt_binding.QtGui import QIcon
Expand Down
18 changes: 10 additions & 8 deletions rqt_gui/src/rqt_gui/ros_plugin_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,9 @@

from qt_gui.plugin_descriptor import PluginDescriptor
from qt_gui.plugin_provider import PluginProvider
from qt_gui.ros_package_helper import get_package_path


class RosPluginProvider(PluginProvider):

"""Base class for providing plugins based on the ROS package system."""

def __init__(self, export_tag, base_class_type):
Expand All @@ -59,6 +57,7 @@ def __init__(self, export_tag, base_class_type):
def discover(self, discovery_data):
"""
Discover the plugins.
The information of the `PluginDescriptor`s are extracted from the plugin manifests.
"""
# search for plugins
Expand All @@ -83,8 +82,11 @@ def load(self, plugin_id, plugin_context):
qCritical('RosPluginProvider.load(%s): raised an exception:\n%s' % (plugin_id, e))
return None
except Exception as e:
qCritical('RosPluginProvider.load(%s) exception raised in __builtin__.__import__(%s, [%s]):\n%s' % (
plugin_id, attributes['module_name'], attributes['class_from_class_type'], traceback.format_exc()))
qCritical('RosPluginProvider.load(%s) exception raised in '
'__builtin__.__import__(%s, [%s]):\n%s' % (
plugin_id, attributes['module_name'],
attributes['class_from_class_type'],
traceback.format_exc()))
raise e

class_ref = getattr(module, attributes['class_from_class_type'], None)
Expand Down Expand Up @@ -113,15 +115,15 @@ def _parse_plugin_xml(self, package_name, plugin_xml):
plugin_descriptors = []

if not os.path.isfile(plugin_xml):
qCritical('RosPluginProvider._parse_plugin_xml() plugin file "%s" in package "%s" not found' %
(plugin_xml, package_name))
qCritical('RosPluginProvider._parse_plugin_xml() plugin file "%s" in package "%s" '
'not found' % (plugin_xml, package_name))
return plugin_descriptors

try:
root = ElementTree.parse(plugin_xml)
except Exception:
qCritical('RosPluginProvider._parse_plugin_xml() could not parse "%s" in package "%s"' %
(plugin_xml, package_name))
qCritical('RosPluginProvider._parse_plugin_xml() could not parse "%s" in package "%s"'
% (plugin_xml, package_name))
return plugin_descriptors
for library_el in root.getiterator('library'):
library_path = library_el.attrib['path']
Expand Down
6 changes: 3 additions & 3 deletions rqt_gui_cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ project(rqt_gui_cpp)
# Load catkin and all dependencies required for this package
find_package(catkin REQUIRED COMPONENTS qt_gui qt_gui_cpp roscpp nodelet)
catkin_package(
INCLUDE_DIRS include
LIBRARIES ${PROJECT_NAME}
INCLUDE_DIRS include
LIBRARIES ${PROJECT_NAME}
CATKIN_DEPENDS qt_gui qt_gui_cpp roscpp nodelet
)

Expand All @@ -26,7 +26,7 @@ qt5_wrap_cpp(rqt_gui_cpp_MOCS ${rqt_gui_cpp_HDRS})
add_library(${PROJECT_NAME} ${rqt_gui_cpp_SRCS} ${rqt_gui_cpp_MOCS})
target_link_libraries(${PROJECT_NAME} ${catkin_LIBRARIES} Qt5::Widgets)

if(APPLE)
if(APPLE)
set_target_properties(${PROJECT_NAME} PROPERTIES LINK_FLAGS "-undefined dynamic_lookup")
endif()

Expand Down
2 changes: 1 addition & 1 deletion rqt_gui_cpp/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<run_depend version_gte="0.3.0">qt_gui_cpp</run_depend>
<run_depend>roscpp</run_depend>
<run_depend>nodelet</run_depend>

<export>
<cpp cflags="-I${prefix}/include" lflags="-L${prefix}/lib -Wl,-rpath,${prefix}/lib -lrqt_gui_cpp"/>
<qt_gui plugin="${prefix}/plugin.xml"/>
Expand Down
2 changes: 1 addition & 1 deletion rqt_gui_py/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<run_depend version_gte="0.3.0">qt_gui</run_depend>
<run_depend version_gte="0.3.0">rqt_gui</run_depend>
<run_depend>rospy</run_depend>

<export>
<rqt_gui plugin="${prefix}/plugin.xml"/>
</export>
Expand Down
1 change: 1 addition & 0 deletions rqt_gui_py/setup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env python

from distutils.core import setup

from catkin_pkg.python_setup import generate_distutils_setup

d = generate_distutils_setup(
Expand Down
6 changes: 4 additions & 2 deletions rqt_gui_py/src/rqt_gui_py/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,11 @@


class Plugin(Base):

"""
Interface for Python plugins which use the ROS client library.
User-defined plugins may either subclass `rqt_gui_py.plugin.Plugin` or according to duck typing implement only the needed methods.
User-defined plugins may either subclass `rqt_gui_py.plugin.Plugin` or according to duck typing
implement only the needed methods.
A plugin must not call rospy.init_node() as this is performed once by the framework.
The name of the ROS node consists of the prefix "rqt_gui_py_node_" and the process id.
"""
Expand All @@ -48,6 +49,7 @@ def __init__(self, context):
def shutdown_plugin(self):
"""
Shutdown and clean up the plugin before unloading.
I.e. unregister subscribers and stop timers.
"""
pass
18 changes: 10 additions & 8 deletions rqt_gui_py/src/rqt_gui_py/ros_py_plugin_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@

import rospy

from python_qt_binding.QtCore import qDebug, Qt, Signal
from python_qt_binding.QtWidgets import QMessageBox

from qt_gui.composite_plugin_provider import CompositePluginProvider
from qt_gui.errors import PluginLoadError

from python_qt_binding.QtCore import qDebug, Qt, qWarning, Signal
from python_qt_binding.QtWidgets import QMessageBox

from rqt_gui.rospkg_plugin_provider import RospkgPluginProvider


Expand Down Expand Up @@ -70,11 +70,13 @@ def _check_for_master(self):
# spawn thread to detect when master becomes available
self._wait_for_master_thread = threading.Thread(target=self._wait_for_master)
self._wait_for_master_thread.start()
self._wait_for_master_dialog = QMessageBox(QMessageBox.Question,
self.tr('Waiting for ROS master'),
self.tr("Could not find ROS master. Either start a 'roscore' or "
"abort loading the plugin."),
QMessageBox.Abort)
self._wait_for_master_dialog = QMessageBox(
QMessageBox.Question,
self.tr('Waiting for ROS master'),
self.tr(
"Could not find ROS master. Either start a 'roscore' or abort loading the plugin."),
QMessageBox.Abort)

self._master_found_signal.connect(self._wait_for_master_dialog.done, Qt.QueuedConnection)
button = self._wait_for_master_dialog.exec_()
# check if master existence was not detected by background thread
Expand Down

0 comments on commit ffcab92

Please sign in to comment.