From 9ab2cba870b1bbf6cb14d74d1a311259c33622e7 Mon Sep 17 00:00:00 2001 From: Bob Lantz Date: Sat, 10 Apr 2010 23:53:00 -0700 Subject: [PATCH] Fixed gterm support; quote and join -e argument. --- mininet/term.py | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/mininet/term.py b/mininet/term.py index e9381b4..74e8d8e 100644 --- a/mininet/term.py +++ b/mininet/term.py @@ -12,16 +12,10 @@ from subprocess import Popen from mininet.log import error from mininet.util import quietRun -def joinCmd( args ): - "Join args into a string, single-quoting items with spaces." - result = '' - for arg in args: - if ' ' in item: - result += " '%s'" % arg - else: - result += " %s" % arg - return result - +def quoteArg( arg ): + "Quote an argument if it contains spaces." + return repr( arg ) if ' ' in arg else arg + def makeTerm( node, title = 'Node', term = 'xterm' ): """Run screen on a node, and hook up a terminal. node: Node object @@ -44,9 +38,9 @@ def makeTerm( node, title = 'Node', term = 'xterm' ): else: args = [ 'sh', '-c', 'exec tail -f /tmp/' + node.name + '*.log' ] if term == 'gterm': - # Compress these for gnome-terminal, which expects one token to follow - # the -e option . - args = joinCmd( args ) + # Compress these for gnome-terminal, which expects one token + # to follow the -e option + args = [ ' '.join( [ quoteArg( arg ) for arg in args ] ) ] return Popen( cmds[ term ] + args ) def cleanUpScreens():