ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | Q&A
Ask Your Question

Customizing rosh initialization

asked 2011-07-01 06:58:12 -0600

bhaskara gravatar image

updated 2011-07-01 07:50:06 -0600

kwc gravatar image

I notice that rosh doesn't seem to exactly have the same initialization behavior as ipython. For example, in ~/.ipython/ipythonrc, I have the line: importmod os sys

So if I start ipython, I have the os module available in the interactive namespace. But with the same setup, starting rosh does not make those names available.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2011-07-01 07:46:35 -0600

kwc gravatar image

This is probably a bug in rosh. The rosh loader for the shell needs to import os and sys. In order to be 'clean', it then deletes os and sys.

Here's a patch that I think resolves this peculiarity (needs more testing):

diff -r 35d8b08984d6
--- a/  Fri Jul 01 12:45:40 2011 -0700
+++ b/  Fri Jul 01 12:45:42 2011 -0700
@@ -10,6 +10,14 @@
 # import all symbols after initialization
 from rosh import *

+    cleanup_os = 'os' not in sys.modules
+    cleanup_sys = False
+    import sys
+    cleanup_os = 'os' not in sys.modules
+    cleanup_sys = True
 import os, sys
 plugins = sys.argv[1:]

@@ -39,7 +47,9 @@
         del _f

 del plugins
-del sys
-del os
+if cleanup_sys:
+    del sys
+if cleanup_os:
+    del os
 del _roshrcp
 del _rosenv
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2011-07-01 06:58:12 -0600

Seen: 203 times

Last updated: Jul 01 '11