Skip to content
Snippets Groups Projects
Commit 94465e97 authored by Pierre Gergondet's avatar Pierre Gergondet Committed by Pierre Gergondet
Browse files

Improve run_command script handling

* Check for the existence of the script provided
* Pass an absolute path to the service
parent d17639e1
No related branches found
No related tags found
No related merge requests found
...@@ -70,6 +70,7 @@ class RosShell(InteractiveConsole): ...@@ -70,6 +70,7 @@ class RosShell(InteractiveConsole):
if __name__ == '__main__': if __name__ == '__main__':
import optparse import optparse
import os.path
manifest = roslib.manifest.load_manifest('dynamic_graph_bridge') manifest = roslib.manifest.load_manifest('dynamic_graph_bridge')
rospy.init_node('run_command', argv=sys.argv) rospy.init_node('run_command', argv=sys.argv)
sys.argv = rospy.myargv(argv=None) sys.argv = rospy.myargv(argv=None)
...@@ -82,12 +83,14 @@ if __name__ == '__main__': ...@@ -82,12 +83,14 @@ if __name__ == '__main__':
if args[:]: if args[:]:
infile = args[0] infile = args[0]
source = open(infile).read() if os.path.isfile(infile):
if not sh.client: if not sh.client:
print("Connection to remote server has been lost.") print("Connection to remote server has been lost.")
sys.exit(1) sys.exit(1)
response = sh.scriptClient(infile) response = sh.scriptClient(os.path.abspath(infile))
if not response: if not response:
print("Error while file parsing ") print("Error while file parsing ")
else:
print("Provided file does not exist: %s"%(infile))
else: else:
sh.interact("Interacting with remote server.") sh.interact("Interacting with remote server.")
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment