Fixed gterm support; quote and join -e argument.

This commit is contained in:
Bob Lantz
2010-04-10 23:53:00 -07:00
parent 99c035d9ca
commit 9ab2cba870
+6 -12
View File
@@ -12,15 +12,9 @@ from subprocess import Popen
from mininet.log import error from mininet.log import error
from mininet.util import quietRun from mininet.util import quietRun
def joinCmd( args ): def quoteArg( arg ):
"Join args into a string, single-quoting items with spaces." "Quote an argument if it contains spaces."
result = '' return repr( arg ) if ' ' in arg else arg
for arg in args:
if ' ' in item:
result += " '%s'" % arg
else:
result += " %s" % arg
return result
def makeTerm( node, title = 'Node', term = 'xterm' ): def makeTerm( node, title = 'Node', term = 'xterm' ):
"""Run screen on a node, and hook up a terminal. """Run screen on a node, and hook up a terminal.
@@ -44,9 +38,9 @@ def makeTerm( node, title = 'Node', term = 'xterm' ):
else: else:
args = [ 'sh', '-c', 'exec tail -f /tmp/' + node.name + '*.log' ] args = [ 'sh', '-c', 'exec tail -f /tmp/' + node.name + '*.log' ]
if term == 'gterm': if term == 'gterm':
# Compress these for gnome-terminal, which expects one token to follow # Compress these for gnome-terminal, which expects one token
# the -e option . # to follow the -e option
args = joinCmd( args ) args = [ ' '.join( [ quoteArg( arg ) for arg in args ] ) ]
return Popen( cmds[ term ] + args ) return Popen( cmds[ term ] + args )
def cleanUpScreens(): def cleanUpScreens():