Revision bda2317d bin/mn

View differences:

bin/mn
22 22

  
23 23
from mininet.clean import cleanup
24 24
from mininet.cli import CLI
25
from mininet.log import lg, LEVELS, info
25
from mininet.log import lg, LEVELS, info, debug, error
26 26
from mininet.net import Mininet, MininetWithControlNet, VERSION
27 27
from mininet.node import ( Host, CPULimitedHost, Controller, OVSController,
28 28
                           NOX, RemoteController, UserSwitch, OVSKernelSwitch,
......
278 278

  
279 279

  
280 280
if __name__ == "__main__":
281
    MininetRunner()
281
    try:
282
        MininetRunner()
283
    except KeyboardInterrupt:
284
        info( "Keyboard Interrupt. Shutting down and cleaning up...")
285
        cleanup()
286
    except Exception:
287
        #Print exception
288
        type_, val_, trace_ = sys.exc_info()
289
        errorMsg = ( "-"*80 + "\n" +
290
                     "Caught exception. Cleaning up...\n\n" +
291
                     "%s: %s\n" % ( type_.__name__, val_ ) +
292
                     "-"*80 + "\n" )
293
        error( errorMsg )
294
        # Print stack trace to debug log
295
        import traceback
296
        stackTrace = traceback.format_exc()
297
        debug( stackTrace + "\n" )
298
        cleanup()

Also available in: Unified diff