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

Method initReadline

mininet/cli.py:75–100  ·  view source on GitHub ↗

Set up history if readline is available

( cls )

Source from the content-addressed store, hash-verified

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
102 def run( self ):
103 "Run our cmdloop(), catching KeyboardInterrupt"

Callers 1

__init__Method · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected