MCPcopy Create free account
hub / github.com/mininet/mininet / CLI

Class CLI

mininet/cli.py:44–492  ·  view source on GitHub ↗

Simple command-line interface to talk to nodes.

Source from the content-addressed store, hash-verified

42 dumpPorts )
43
44class CLI( Cmd ):
45 "Simple command-line interface to talk to nodes."
46
47 prompt = 'mininet> '
48
49 def __init__( self, mininet, stdin=sys.stdin, script=None,
50 **kwargs ):
51 """Start and run interactive or batch mode CLI
52 mininet: Mininet network object
53 stdin: standard input for CLI
54 script: script to run in batch mode"""
55 self.mn = mininet
56 # Local variable bindings for py command
57 self.locals = { 'net': mininet }
58 # Attempt to handle input
59 self.inPoller = poll()
60 self.inPoller.register( stdin )
61 self.inputFile = script
62 Cmd.__init__( self, stdin=stdin, **kwargs )
63 info( '*** Starting CLI:\n' )
64
65 if self.inputFile:
66 self.do_source( self.inputFile )
67 return
68
69 self.initReadline()
70 self.run()
71
72 readlineInited = False
73
74 @classmethod
75 def initReadline( cls ):
76 "Set up history if readline is available"
77 # Only set up readline once to prevent multiplying the history file
78 if cls.readlineInited:
79 return
80 cls.readlineInited = True
81 try:
82 # pylint: disable=import-outside-toplevel
83 from readline import ( read_history_file, write_history_file,
84 set_history_length )
85 except ImportError:
86 pass
87 else:
88 history_path = os.path.expanduser( '~/.mininet_history' )
89 if os.path.isfile( history_path ):
90 read_history_file( history_path )
91 set_history_length( 1000 )
92
93 def writeHistory():
94 "Write out history file"
95 try:
96 write_history_file( history_path )
97 except IOError:
98 # Ignore probably spurious IOError
99 pass
100 atexit.register( writeHistory )
101

Callers 15

interactMethod · 0.90
runFunction · 0.90
multitest.pyFile · 0.90
hwintf.pyFile · 0.90
testHostWithPrivateDirsFunction · 0.90
runFunction · 0.90
runFunction · 0.90
runMultiLinkFunction · 0.90
sshdFunction · 0.90
nat.pyFile · 0.90
emptyNetFunction · 0.90
multiControllerNetFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected