Revision 23c70f60 mininet/cli.py

View differences:

mininet/cli.py
121 121
        "Run an external shell command"
122 122
        call( line, shell=True )
123 123

  
124
    # do_py() needs to catch any exception during eval()
124
    # do_py() and do_px() need to catch any exception during eval()/exec()
125 125
    # pylint: disable-msg=W0703
126 126

  
127 127
    def do_py( self, line ):
128 128
        """Evaluate a Python expression.
129
           Node names may be used, e.g.: h1.cmd('ls')"""
129
           Node names may be used, e.g.: py h1.cmd('ls')"""
130 130
        try:
131 131
            result = eval( line, globals(), self.locals )
132 132
            if not result:
......
138 138
        except Exception, e:
139 139
            output( str( e ) + '\n' )
140 140

  
141
    # pylint: enable-msg=W0703
141
    # We are in fact using the exec() pseudo-function
142
    # pylint: disable-msg=W0122
143

  
144
    def do_px( self, line ):
145
        """Execute a Python statement.
146
            Node names may be used, e.g.: px print h1.cmd('ls')"""
147
        try:
148
            exec( line, globals(), self.locals )
149
        except Exception, e:
150
            output( str( e ) + '\n' )
151

  
152
    # pylint: enable-msg=W0703,W0122
142 153

  
143 154
    def do_pingall( self, _line ):
144 155
        "Ping between all hosts."

Also available in: Unified diff