Stop catching non error throwables such as SystemExit
* Convert "except:" to "except Exception:"
* Use log.exception instead of directly calling traceback
* Remove unused imports
* Fix a typos
* Replace tabs with spaces for combatibility issues
diff --git a/TestON/drivers/common/cli/emulator/mininetclidriver.py b/TestON/drivers/common/cli/emulator/mininetclidriver.py
index fbd863e..eaed3a2 100644
--- a/TestON/drivers/common/cli/emulator/mininetclidriver.py
+++ b/TestON/drivers/common/cli/emulator/mininetclidriver.py
@@ -35,7 +35,6 @@
Note that you may need to run 'sudo make develop' if your mnexec.c file
changed when switching branches."""
-import traceback
import pexpect
import re
import sys
@@ -83,17 +82,15 @@
self.user_name +
"@" +
self.ip_address )
- msin.log.error( "Failed to connect to the Mininet CLI" )
+ main.log.error( "Failed to connect to the Mininet CLI" )
return main.FALSE
except pexpect.EOF:
main.log.error( self.name + ": EOF exception found" )
main.log.error( self.name + ": " + self.handle.before )
main.cleanup()
main.exit()
- except:
- main.log.info( self.name + ":::::::::::::::::::::::" )
- main.log.error( traceback.print_exc() )
- main.log.info( ":::::::::::::::::::::::" )
+ except Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
@@ -1032,10 +1029,8 @@
main.log.error( self.name + ": " + self.handle.before )
main.cleanup()
main.exit()
- except:
- main.log.info( self.name + ":" * 50 )
- main.log.error( traceback.print_exc() )
- main.log.info( ":" * 50 )
+ except Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
@@ -1342,7 +1337,7 @@
main.log.info( self.name + ": ARP successful" )
self.handle.expect( [ "mininet", pexpect.EOF, pexpect.TIMEOUT ] )
return main.TRUE
- except:
+ except Exception:
main.log.warn( self.name + ": ARP FAILURE" )
self.handle.expect( [ "mininet", pexpect.EOF, pexpect.TIMEOUT ] )
return main.FALSE
@@ -1448,10 +1443,8 @@
main.log.error( self.name + ": " + self.handle.before )
main.cleanup()
main.exit()
- except:
- main.log.info( self.name + ":" * 50 )
- main.log.error( traceback.print_exc() )
- main.log.info( ":" * 50 )
+ except Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
@@ -1467,10 +1460,8 @@
main.log.error( self.name + ": " + self.handle.before )
main.cleanup()
main.exit()
- except:
- main.log.info( self.name + ":" * 50 )
- main.log.error( traceback.print_exc() )
- main.log.info( ":" * 50 )
+ except Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()