Skip to content

Commit

Permalink
FIX: updated ssh environment copying to escape special characters for…
Browse files Browse the repository at this point in the history
… posix compatibility
  • Loading branch information
Satrajit Ghosh committed Sep 22, 2010
1 parent 45e3e05 commit 4beba07
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions IPython/kernel/scripts/ipcluster.py
Expand Up @@ -419,6 +419,13 @@ def _make_bsub_wrapper(self):
ps -fu `whoami` | grep '[i]pengine' | awk '{print $2}' | xargs kill -TERM
"""

def escape_strings(val):
val = val.replace('(','\(')
val = val.replace(')','\)')
if ' ' in val:
val = '"%s"'%val
return val

class SSHEngineSet(object):
sshx_template_prefix=sshx_template_prefix
sshx_template_suffix=sshx_template_suffix
Expand All @@ -445,8 +452,9 @@ def __init__(self, engine_hosts, sshx=None, copyenvs=None, ipengine="ipengine"):
f = open(self.sshx, 'w')
f.writelines(self.sshx_template_prefix)
if copyenvs:
for key, val in os.environ.items():
f.writelines('export %s=%s\n'%(key,val))
for key, val in sorted(os.environ.items()):
newval = escape_strings(val)
f.writelines('export %s=%s\n'%(key,newval))
f.writelines(self.sshx_template_suffix)
f.close()
self.engine_command = ipengine
Expand Down

0 comments on commit 4beba07

Please sign in to comment.