Fixed gterm support; quote and join -e argument.
This commit is contained in:
+7
-13
@@ -12,16 +12,10 @@ 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.
|
||||||
node: Node object
|
node: Node object
|
||||||
@@ -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():
|
||||||
|
|||||||
Reference in New Issue
Block a user