Revision 98332cb6 examples/xterms.py

View differences:

examples/xterms.py
7 7

  
8 8
import os, re
9 9
from subprocess import Popen
10
from mininet import init, TreeNet, Cli, quietRun
10
from mininet import init, TreeNet, quietRun
11 11

  
12 12
def makeXterm( node, title ):
13 13
   "Run screen on a node, and hook up an xterm."
14
   node.cmdPrint( 'screen -dmS ' + node.name )
15 14
   title += ': ' + node.name
16 15
   if not node.inNamespace: title += ' (root)'
17
   cmd = [ 'xterm', '-title', title ]
18
   cmd += [ '-e', 'screen', '-D', '-RR', '-S', node.name ]
16
   cmd = [ 'xterm', '-title', title, '-e' ]
17
   if not node.execed:
18
      node.cmdPrint( 'screen -dmS ' + node.name )
19
      cmd += [ 'screen', '-D', '-RR', '-S', node.name ]
20
   else:
21
      cmd += [ 'sh', '-c', 'exec tail -f /tmp/' + node.name + '*.log' ]
19 22
   return Popen( cmd )
20 23

  
21 24
def cleanUpScreens():
......
28 31
         quietRun( 'screen -S ' + m.group( 1 ) + ' -X kill' )
29 32
   
30 33
def makeXterms( nodes, title ):
31
   terms = []
32
   for node in nodes:
33
      if not node.execed:
34
         terms += [ makeXterm( node, title ) ]
35
   return terms
34
   return [ makeXterm( node, title) for node in nodes]
36 35

  
37 36
def xterms( controllers, switches, hosts ):
38 37
   cleanUpScreens()
39
   terms = []
40
   terms += makeXterms( controllers, 'controller' )
38
   terms = makeXterms( controllers, 'controller' )
41 39
   terms += makeXterms( switches, 'switch' )
42 40
   terms += makeXterms( hosts, 'host' )
43 41
   # Wait for xterms to exit

Also available in: Unified diff