From 5d48a2c9f1fea946ae50f259d86bc1999a8c98a4 Mon Sep 17 00:00:00 2001 From: corot Date: Fri, 28 Nov 2014 15:52:34 +0100 Subject: [PATCH] Separate running script from the package, following catkin conventions --- world_canvas_server/CMakeLists.txt | 3 +++ world_canvas_server/launch/add_map.launch | 2 +- .../launch/world_canvas_server.launch | 2 +- world_canvas_server/scripts/world_canvas_server | 17 +++++++++++++++++ world_canvas_server/setup.py | 12 ++++++++++++ .../src/world_canvas_server/__init__.py | 3 +++ .../annotations_server.py | 11 ----------- .../{ => world_canvas_server}/map_manager.py | 0 .../{ => world_canvas_server}/yaml_database.py | 0 9 files changed, 37 insertions(+), 13 deletions(-) create mode 100755 world_canvas_server/scripts/world_canvas_server create mode 100644 world_canvas_server/setup.py create mode 100644 world_canvas_server/src/world_canvas_server/__init__.py rename world_canvas_server/src/{ => world_canvas_server}/annotations_server.py (98%) rename world_canvas_server/src/{ => world_canvas_server}/map_manager.py (100%) rename world_canvas_server/src/{ => world_canvas_server}/yaml_database.py (100%) diff --git a/world_canvas_server/CMakeLists.txt b/world_canvas_server/CMakeLists.txt index 4015235..e65716b 100644 --- a/world_canvas_server/CMakeLists.txt +++ b/world_canvas_server/CMakeLists.txt @@ -4,7 +4,10 @@ project(world_canvas_server) find_package(catkin REQUIRED) catkin_package() +catkin_python_setup() +catkin_install_python(PROGRAMS scripts/world_canvas_server + DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}) FILE(GLOB_RECURSE script_files scripts/*.py) diff --git a/world_canvas_server/launch/add_map.launch b/world_canvas_server/launch/add_map.launch index 1ececcd..f650a47 100644 --- a/world_canvas_server/launch/add_map.launch +++ b/world_canvas_server/launch/add_map.launch @@ -7,7 +7,7 @@ - + diff --git a/world_canvas_server/launch/world_canvas_server.launch b/world_canvas_server/launch/world_canvas_server.launch index 2b9cdc6..97c9305 100644 --- a/world_canvas_server/launch/world_canvas_server.launch +++ b/world_canvas_server/launch/world_canvas_server.launch @@ -8,7 +8,7 @@ --> - + diff --git a/world_canvas_server/scripts/world_canvas_server b/world_canvas_server/scripts/world_canvas_server new file mode 100755 index 0000000..1b6bbc9 --- /dev/null +++ b/world_canvas_server/scripts/world_canvas_server @@ -0,0 +1,17 @@ +#! /usr/bin/env python + +import sys +import rospy + +import world_canvas_server + +if __name__ == '__main__': + if len(sys.argv) > 1 and sys.argv[1] == 'true': + # Only (optional) argument is a debug='true'/'false' flag + rospy.init_node('world_canvas_server', log_level=rospy.DEBUG) + else: + rospy.init_node('world_canvas_server') + + world_canvas_server.AnnotationsServer() + + rospy.spin() diff --git a/world_canvas_server/setup.py b/world_canvas_server/setup.py new file mode 100644 index 0000000..8e57f9b --- /dev/null +++ b/world_canvas_server/setup.py @@ -0,0 +1,12 @@ +#!/usr/bin/env python + +from distutils.core import setup +from catkin_pkg.python_setup import generate_distutils_setup + +d = generate_distutils_setup( + packages=['world_canvas_server'], + package_dir={'': 'src'}, + requires=['roslib', 'rospy', 'world_canvas_msgs', 'world_canvas_libs'] +) + +setup(**d) diff --git a/world_canvas_server/src/world_canvas_server/__init__.py b/world_canvas_server/src/world_canvas_server/__init__.py new file mode 100644 index 0000000..a0c1e3b --- /dev/null +++ b/world_canvas_server/src/world_canvas_server/__init__.py @@ -0,0 +1,3 @@ +from .annotations_server import * +from .yaml_database import * +from .map_manager import * diff --git a/world_canvas_server/src/annotations_server.py b/world_canvas_server/src/world_canvas_server/annotations_server.py similarity index 98% rename from world_canvas_server/src/annotations_server.py rename to world_canvas_server/src/world_canvas_server/annotations_server.py index 27ce4e6..d16da77 100755 --- a/world_canvas_server/src/annotations_server.py +++ b/world_canvas_server/src/world_canvas_server/annotations_server.py @@ -476,14 +476,3 @@ def service_error(self, response, message): response.message = message response.result = False return response - -if __name__ == "__main__": - if len(sys.argv) > 1 and sys.argv[1] == 'true': - # Only (optional) argument is a debug='true'/'false' flag - rospy.init_node('world_canvas_server', log_level=rospy.DEBUG) - else: - rospy.init_node('world_canvas_server') - - AnnotationsServer() - - rospy.spin() diff --git a/world_canvas_server/src/map_manager.py b/world_canvas_server/src/world_canvas_server/map_manager.py similarity index 100% rename from world_canvas_server/src/map_manager.py rename to world_canvas_server/src/world_canvas_server/map_manager.py diff --git a/world_canvas_server/src/yaml_database.py b/world_canvas_server/src/world_canvas_server/yaml_database.py similarity index 100% rename from world_canvas_server/src/yaml_database.py rename to world_canvas_server/src/world_canvas_server/yaml_database.py