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/dpclidriver.py b/TestON/drivers/common/cli/dpclidriver.py
index 057a3f1..ee26bde 100644
--- a/TestON/drivers/common/cli/dpclidriver.py
+++ b/TestON/drivers/common/cli/dpclidriver.py
@@ -1,16 +1,8 @@
"""
Driver for blank dataplane VMs. Created for SDNIP test.
"""
-import time
import pexpect
-import struct
-import fcntl
-import os
import sys
-import signal
-import sys
-import re
-import json
sys.path.append( "../" )
from drivers.common.clidriver import CLI
@@ -95,15 +87,15 @@
self.handle.sendline( "" )
self.handle.expect( "\$" )
- self.handle.sendline( "scp " + str( destlogin ) + "@" +
- str( destip ) + ":/tmp/local_ip.txt /tmp/ip_table" +
- str( net ) + ".txt" )
-
- i = self.handle.expect( [
- "100%",
+ self.handle.sendline( "scp " + str( destlogin ) + "@" +
+ str( destip ) + ":/tmp/local_ip.txt /tmp/ip_table" +
+ str( netsrc ) + ".txt" )
+
+ i = self.handle.expect( [
+ "100%",
"password",
pexpect.TIMEOUT ],
- timeout=30 )
+ timeout=30 )
if i == 0:
main.log.info( "Copied ping file successfully" )
@@ -120,20 +112,20 @@
self.handle.expect( "\$" )
main.log.info( "Pinging interfaces on the " + str( netdst ) +
- " network from " + str( netsrc ) + "." +
- str( netstrt ) + ".1.1" )
+ " network from " + str( netsrc ) + "." +
+ str( netstrt ) + ".1.1" )
self.handle.sendline( "sudo fping -S " + str( netsrc ) + "." +
- str( netstrt ) + ".1.1 -f /tmp/ip_table" +
- str( netdst ) + ".txt" )
+ str( netstrt ) + ".1.1 -f /tmp/ip_table" +
+ str( netdst ) + ".txt" )
while 1:
i = self.handle.expect( [
- "reachable",
+ "reachable",
"unreachable",
"\$",
"password",
pexpect.TIMEOUT,
"not installed" ],
- timeout=45 )
+ timeout=45 )
if i == 0:
result = main.TRUE
elif i == 1:
@@ -142,6 +134,7 @@
return result
elif i == 2:
main.log.info( "All interfaces reachable" )
+ result = main.FALSE
return result
elif i == 3:
self.handle.sendline( self.pwd )
@@ -183,8 +176,8 @@
try:
self.handle.sendline( "exit" )
self.handle.expect( "closed" )
- except:
- main.log.error( "Connection failed to the host" )
+ except Exception:
+ main.log.exception( "Connection failed to the host" )
response = main.FALSE
return response
diff --git a/TestON/drivers/common/cli/emulator/flowvisordriver.py b/TestON/drivers/common/cli/emulator/flowvisordriver.py
index d0e6ea5..46c47a7 100644
--- a/TestON/drivers/common/cli/emulator/flowvisordriver.py
+++ b/TestON/drivers/common/cli/emulator/flowvisordriver.py
@@ -21,17 +21,10 @@
FlowVisorDriver is the basic driver which will handle the Mininet functions
"""
-import pexpect
-import struct
-import fcntl
-import os
-import signal
import re
import sys
-import core.teston
sys.path.append( "../" )
from drivers.common.cli.emulatordriver import Emulator
-from drivers.common.clidriver import CLI
class FlowVisorDriver( Emulator ):
@@ -147,15 +140,15 @@
try :
if self.dl_src and self.nw_dst:
flowspace = "any 100 dl_type=0x806,dl_src="+self.dl_src+",nw_dst="+self.nw_dst+" Slice:"+self.Slice+"=4"
- except :
+ except Exception:
try :
if self.nw_src and self.tp_dst:
flowspace = "any 100 dl_type=0x800,nw_proto=6,nw_src="+self.nw_src+",tp_dst="+self.tp_dst+" Slice:"+self.Slice+"=4"
- except :
+ except Exception:
try :
if self.nw_src and self.tp_src:
flowspace = "any 100 dl_type=0x800,nw_proto=6,nw_src="+self.nw_src+",tp_src="+self.tp_dst+" Slice:"+self.Slice+"=4"
- except :
+ except Exception:
main.log.error( "Please specify flowspace properly" )
"""
# self.execute( cmd="clear",prompt="\$",timeout=10 )
diff --git a/TestON/drivers/common/cli/emulator/lincoedriver.py b/TestON/drivers/common/cli/emulator/lincoedriver.py
index 82179a5..b1bc05a 100644
--- a/TestON/drivers/common/cli/emulator/lincoedriver.py
+++ b/TestON/drivers/common/cli/emulator/lincoedriver.py
@@ -14,20 +14,11 @@
OCT 20 2014
"""
-import traceback
+
import pexpect
-import struct
-import fcntl
-import os
-import signal
-import re
import sys
-import core.teston
-import time
sys.path.append( "../" )
-from math import pow
from drivers.common.cli.emulatordriver import Emulator
-from drivers.common.clidriver import CLI
class LincOEDriver( Emulator ):
@@ -45,7 +36,6 @@
"""
Create ssh handle for Linc-OE cli
"""
- import time
for key in connectargs:
vars( self )[ key ] = connectargs[ key ]
@@ -127,10 +117,8 @@
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( self.name + " :::::::" )
+ except Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
@@ -153,10 +141,8 @@
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( self.name + " :::::::" )
+ except Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
@@ -175,10 +161,8 @@
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( self.name + " :::::::" )
+ except Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
@@ -197,10 +181,8 @@
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( self.name + " :::::::" )
+ except Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
@@ -220,10 +202,8 @@
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( self.name + " :::::::" )
+ except Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
@@ -242,10 +222,8 @@
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( self.name + " :::::::" )
+ except Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
@@ -265,10 +243,8 @@
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( self.name + " :::::::" )
+ except Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
@@ -288,10 +264,8 @@
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( self.name + " :::::::" )
+ except Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
@@ -339,10 +313,8 @@
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( self.name + " :::::::" )
+ except Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
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()
diff --git a/TestON/drivers/common/cli/emulator/remotemininetdriver.py b/TestON/drivers/common/cli/emulator/remotemininetdriver.py
index 9c9585a..d842cbb 100644
--- a/TestON/drivers/common/cli/emulator/remotemininetdriver.py
+++ b/TestON/drivers/common/cli/emulator/remotemininetdriver.py
@@ -21,7 +21,6 @@
MininetCliDriver is the basic driver which will handle the Mininet functions
"""
-import traceback
import pexpect
import re
import sys
@@ -323,11 +322,8 @@
main.log.error( self.name + ": " + self.handle.before )
main.cleanup()
main.exit()
- except:
- main.log.info(
- self.name + ":" * 60 )
- main.log.error( traceback.print_exc() )
- main.log.info( ":" * 80 )
+ except Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
@@ -342,11 +338,8 @@
main.log.error( self.name + ": " + self.handle.before )
main.cleanup()
main.exit()
- except:
- main.log.info(
- self.name + ":" * 60 )
- main.log.error( traceback.print_exc() )
- main.log.info( ":" * 80 )
+ except Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
@@ -583,8 +576,9 @@
main.log.error(
self.name +
": Timeout exception in setIpTables function" )
- except:
- main.log.error( traceback.print_exc() )
+ except Exception:
+ main.log.exception( self.name +
+ ": Uncaught exception!" )
main.cleanup()
main.exit()
else:
@@ -596,6 +590,7 @@
if actionType == 'remove':
# -D is the 'delete' rule of iptables
actionRemove = '-D'
+ # noinspection PyBroadException
try:
self.handle.sendline( "" )
# Delete a specific rule specified into the function
@@ -626,8 +621,9 @@
main.log.error(
self.name +
": Timeout exception in setIpTables function" )
- except:
- main.log.error( traceback.print_exc() )
+ except Exception:
+ main.log.exception( self.name +
+ ": Uncaught exception!" )
main.cleanup()
main.exit()
else:
diff --git a/TestON/drivers/common/cli/onosclidriver.py b/TestON/drivers/common/cli/onosclidriver.py
index cb8a9a7..02922af 100644
--- a/TestON/drivers/common/cli/onosclidriver.py
+++ b/TestON/drivers/common/cli/onosclidriver.py
@@ -71,7 +71,7 @@
main.log.error( self.name + ": " + self.handle.before )
main.cleanup()
main.exit()
- except:
+ except Exception:
main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
@@ -93,7 +93,7 @@
except pexpect.EOF:
main.log.error( self.name + ": EOF exception found" )
main.log.error( self.name + ": " + self.handle.before )
- except:
+ except Exception:
main.log.exception( self.name + ": Connection failed to the host" )
response = main.FALSE
return response
@@ -122,7 +122,7 @@
self.handle.before )
main.cleanup()
main.exit()
- except:
+ except Exception:
main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
@@ -164,7 +164,7 @@
main.log.error( self.name + ": " + self.handle.before )
main.cleanup()
main.exit()
- except:
+ except Exception:
main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
@@ -242,7 +242,7 @@
main.log.error( self.name + ": " + self.handle.before )
main.cleanup()
main.exit()
- except:
+ except Exception:
main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
@@ -275,7 +275,7 @@
main.log.error( self.name + ": " + self.handle.before )
main.cleanup()
main.exit()
- except:
+ except Exception:
main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
@@ -314,7 +314,7 @@
main.log.error( self.name + ": " + self.handle.before )
main.cleanup()
main.exit()
- except:
+ except Exception:
main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
@@ -354,7 +354,7 @@
main.log.error( self.name + ": " + self.handle.before )
main.cleanup()
main.exit()
- except:
+ except Exception:
main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
@@ -382,7 +382,7 @@
main.log.error( self.name + ": " + self.handle.before )
main.cleanup()
main.exit()
- except:
+ except Exception:
main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
@@ -405,7 +405,7 @@
main.log.error( self.name + ": " + self.handle.before )
main.cleanup()
main.exit()
- except:
+ except Exception:
main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
@@ -429,7 +429,7 @@
main.log.error( self.name + ": " + self.handle.before )
main.cleanup()
main.exit()
- except:
+ except Exception:
main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
@@ -454,7 +454,7 @@
main.log.report( "Exiting test" )
main.cleanup()
main.exit()
- except:
+ except Exception:
main.log.exception( self.name + ": Uncaught exception!" )
main.log.report( "Failed to install feature" )
main.log.report( "Exiting test" )
@@ -484,7 +484,7 @@
main.log.error( self.name + ": " + self.handle.before )
main.cleanup()
main.exit()
- except:
+ except Exception:
main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
@@ -527,7 +527,7 @@
main.log.error( self.name + ": " + self.handle.before )
main.cleanup()
main.exit()
- except:
+ except Exception:
main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
@@ -551,7 +551,7 @@
main.log.error( self.name + ": " + self.handle.before )
main.cleanup()
main.exit()
- except:
+ except Exception:
main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
@@ -594,7 +594,7 @@
main.log.error( self.name + ": " + self.handle.before )
main.cleanup()
main.exit()
- except:
+ except Exception:
main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
@@ -638,7 +638,7 @@
main.log.error( self.name + ": " + self.handle.before )
main.cleanup()
main.exit()
- except:
+ except Exception:
main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
@@ -684,7 +684,7 @@
main.log.error( self.name + ": " + self.handle.before )
main.cleanup()
main.exit()
- except:
+ except Exception:
main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
@@ -720,7 +720,7 @@
main.log.error( self.name + ": " + self.handle.before )
main.cleanup()
main.exit()
- except:
+ except Exception:
main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
@@ -750,7 +750,7 @@
main.log.error( self.name + ": " + self.handle.before )
main.cleanup()
main.exit()
- except:
+ except Exception:
main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
@@ -778,7 +778,7 @@
main.log.error( self.name + ": " + self.handle.before )
main.cleanup()
main.exit()
- except:
+ except Exception:
main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
@@ -821,7 +821,7 @@
main.log.error( self.name + ": " + self.handle.before )
main.cleanup()
main.exit()
- except:
+ except Exception:
main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
@@ -858,7 +858,7 @@
main.log.error( self.name + ": " + self.handle.before )
main.cleanup()
main.exit()
- except:
+ except Exception:
main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
@@ -900,7 +900,7 @@
main.log.error( self.name + ": " + self.handle.before )
main.cleanup()
main.exit()
- except:
+ except Exception:
main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
@@ -940,7 +940,7 @@
main.log.error( self.name + ": " + self.handle.before )
main.cleanup()
main.exit()
- except:
+ except Exception:
main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
@@ -983,7 +983,7 @@
main.log.error( self.name + ": " + self.handle.before )
main.cleanup()
main.exit()
- except:
+ except Exception:
main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
@@ -1115,7 +1115,7 @@
main.log.error( self.name + ": " + self.handle.before )
main.cleanup()
main.exit()
- except:
+ except Exception:
main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
@@ -1278,7 +1278,7 @@
main.log.error( self.name + ": " + self.handle.before )
main.cleanup()
main.exit()
- except:
+ except Exception:
main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
@@ -1318,7 +1318,7 @@
main.log.error( self.name + ": " + self.handle.before )
main.cleanup()
main.exit()
- except:
+ except Exception:
main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
@@ -1350,7 +1350,7 @@
main.log.error( self.name + ": " + self.handle.before )
main.cleanup()
main.exit()
- except:
+ except Exception:
main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
@@ -1380,7 +1380,7 @@
main.log.error( self.name + ": " + self.handle.before )
main.cleanup()
main.exit()
- except:
+ except Exception:
main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
@@ -1440,7 +1440,7 @@
main.log.error( self.name + ": " + self.handle.before )
main.cleanup()
main.exit()
- except:
+ except Exception:
main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
@@ -1473,7 +1473,7 @@
main.log.error( self.name + ": " + self.handle.before )
main.cleanup()
main.exit()
- except:
+ except Exception:
main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
@@ -1532,7 +1532,7 @@
main.log.error( self.name + ": " + self.handle.before )
main.cleanup()
main.exit()
- except:
+ except Exception:
main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
@@ -1562,7 +1562,7 @@
main.log.error( self.name + ": " + self.handle.before )
main.cleanup()
main.exit()
- except:
+ except Exception:
main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
@@ -1592,7 +1592,7 @@
main.log.error( self.name + ": " + self.handle.before )
main.cleanup()
main.exit()
- except:
+ except Exception:
main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
@@ -1631,7 +1631,7 @@
main.log.error( self.name + ": " + self.handle.before )
main.cleanup()
main.exit()
- except:
+ except Exception:
main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
@@ -1651,7 +1651,7 @@
main.log.error( self.name + ": " + self.handle.before )
main.cleanup()
main.exit()
- except:
+ except Exception:
main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
@@ -1697,7 +1697,7 @@
main.log.error( self.name + ": " + self.handle.before )
main.cleanup()
main.exit()
- except:
+ except Exception:
main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
@@ -1737,7 +1737,7 @@
main.log.error( self.name + ": " + self.handle.before )
main.cleanup()
main.exit()
- except:
+ except Exception:
main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
@@ -1768,7 +1768,7 @@
main.log.error( self.name + ": " + self.handle.before )
main.cleanup()
main.exit()
- except:
+ except Exception:
main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
@@ -1834,7 +1834,7 @@
main.log.error( self.name + ": " + self.handle.before )
main.cleanup()
main.exit()
- except:
+ except Exception:
main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
@@ -1877,7 +1877,7 @@
main.log.error( self.name + ": " + self.handle.before )
main.cleanup()
main.exit()
- except:
+ except Exception:
main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
@@ -1920,7 +1920,7 @@
main.log.error( self.name + ": " + self.handle.before )
main.cleanup()
main.exit()
- except:
+ except Exception:
main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
@@ -1972,7 +1972,7 @@
main.log.error( self.name + ": " + self.handle.before )
main.cleanup()
main.exit()
- except:
+ except Exception:
main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
@@ -2013,7 +2013,7 @@
main.log.error( self.name + ": " + self.handle.before )
main.cleanup()
main.exit()
- except:
+ except Exception:
main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
@@ -2054,7 +2054,7 @@
main.log.error( self.name + ": " + self.handle.before )
main.cleanup()
main.exit()
- except:
+ except Exception:
main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
@@ -2080,7 +2080,7 @@
main.log.error( self.name + ": " + self.handle.before )
main.cleanup()
main.exit()
- except:
+ except Exception:
main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
@@ -2106,7 +2106,7 @@
main.log.error( self.name + ": " + self.handle.before )
main.cleanup()
main.exit()
- except:
+ except Exception:
main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
@@ -2131,7 +2131,7 @@
main.log.error( self.name + ": " + self.handle.before )
main.cleanup()
main.exit()
- except:
+ except Exception:
main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
@@ -2157,7 +2157,7 @@
main.log.error( self.name + ": " + self.handle.before )
main.cleanup()
main.exit()
- except:
+ except Exception:
main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
diff --git a/TestON/drivers/common/cli/onosdriver.py b/TestON/drivers/common/cli/onosdriver.py
index 328ac0e..ff331d4 100644
--- a/TestON/drivers/common/cli/onosdriver.py
+++ b/TestON/drivers/common/cli/onosdriver.py
@@ -19,7 +19,6 @@
import sys
import time
import pexpect
-import traceback
import os.path
sys.path.append( "../" )
from drivers.common.clidriver import CLI
@@ -68,10 +67,8 @@
main.log.error( self.name + ": " + self.handle.before )
main.cleanup()
main.exit()
- except:
- main.log.info( self.name + ":" * 30 )
- main.log.error( traceback.print_exc() )
- main.log.info( ":" * 30 )
+ except Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
@@ -88,8 +85,8 @@
except pexpect.EOF:
main.log.error( self.name + ": EOF exception found" )
main.log.error( self.name + ": " + self.handle.before )
- except:
- main.log.error( self.name + ": Connection failed to the host" )
+ except Exception:
+ main.log.exception( self.name + ": Connection failed to the host" )
response = main.FALSE
return response
@@ -113,8 +110,8 @@
except pexpect.EOF:
main.log.error( self.name + ": EOF exception found" )
main.log.error( self.name + ": " + self.handle.before )
- except:
- main.log.error( "Failed to package ONOS" )
+ except Exception:
+ main.log.exception( "Failed to package ONOS" )
main.cleanup()
main.exit()
@@ -143,8 +140,8 @@
except pexpect.EOF:
main.log.error( self.name + ": EOF exception found" )
main.log.error( self.name + ": " + self.handle.before )
- except:
- main.log.error( "Failed to build ONOS" )
+ except Exception:
+ main.log.exception( "Failed to build ONOS" )
main.cleanup()
main.exit()
@@ -215,10 +212,8 @@
main.log.error( self.name + ": " + self.handle.before )
main.cleanup()
main.exit()
- except:
- main.log.info( self.name + ":" * 60 )
- main.log.error( traceback.print_exc() )
- main.log.info( ":" * 60 )
+ except Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
@@ -320,10 +315,8 @@
main.log.error( self.name + ": " + self.handle.before )
main.cleanup()
main.exit()
- except:
- main.log.info( self.name + ":" * 60 )
- main.log.error( traceback.print_exc() )
- main.log.info( ":" * 80 )
+ except Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
@@ -442,10 +435,8 @@
main.log.error( self.name + ": " + self.handle.before )
main.cleanup()
main.exit()
- except:
- main.log.info( self.name + ":" * 60 )
- main.log.error( traceback.print_exc() )
- main.log.info( ":" * 80 )
+ except Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
@@ -492,10 +483,8 @@
main.log.error( self.name + ": " + self.handle.before )
main.cleanup()
main.exit()
- except:
- main.log.info( self.name + ":" * 60 )
- main.log.error( traceback.print_exc() )
- main.log.info( ":" * 80 )
+ except Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
@@ -576,10 +565,8 @@
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()
@@ -615,10 +602,8 @@
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( self.name + " ::::::" )
+ except Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
@@ -650,10 +635,8 @@
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( self.name + " ::::::" )
+ except Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
@@ -711,10 +694,8 @@
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( self.name + " ::::::" )
+ except Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
@@ -766,10 +747,8 @@
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( self.name + " ::::::" )
+ except Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
@@ -804,10 +783,8 @@
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( self.name + " ::::::" )
+ except Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
@@ -842,10 +819,8 @@
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( self.name + " ::::::" )
+ except Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
@@ -871,10 +846,8 @@
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( self.name + " ::::::" )
+ except Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
@@ -904,10 +877,8 @@
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( self.name + " ::::::" )
+ except Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
@@ -950,10 +921,8 @@
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( self.name + " ::::::" )
+ except Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
@@ -987,10 +956,8 @@
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( self.name + " ::::::" )
+ except Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
@@ -1026,10 +993,8 @@
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( self.name + " ::::::" )
+ except Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
@@ -1060,10 +1025,8 @@
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( self.name + " ::::::" )
+ except Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
@@ -1124,10 +1087,8 @@
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( self.name + " ::::::" )
+ except Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
@@ -1172,10 +1133,8 @@
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( self.name + " ::::::" )
+ except Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
@@ -1242,10 +1201,8 @@
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( self.name + " ::::::" )
+ except Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
@@ -1258,19 +1215,29 @@
* interface: interface to capture
* dir: directory/filename to store pcap
"""
- self.handle.sendline( "" )
- self.handle.expect( "\$" )
+ try:
+ self.handle.sendline( "" )
+ self.handle.expect( "\$" )
- self.handle.sendline( "tshark -i " + str( interface ) +
- " -t e -w " + str( dirFile ) + " &" )
- self.handle.sendline( "\r" )
- self.handle.expect( "Capturing on" )
- self.handle.sendline( "\r" )
- self.handle.expect( "\$" )
+ self.handle.sendline( "tshark -i " + str( interface ) +
+ " -t e -w " + str( dirFile ) + " &" )
+ self.handle.sendline( "\r" )
+ self.handle.expect( "Capturing on" )
+ self.handle.sendline( "\r" )
+ self.handle.expect( "\$" )
- main.log.info( "Tshark started capturing files on " +
- str( interface ) + " and saving to directory: " +
- str( dirFile ) )
+ main.log.info( "Tshark started capturing files on " +
+ str( interface ) + " and saving to directory: " +
+ str( dirFile ) )
+ except pexpect.EOF:
+ main.log.error( self.name + ": EOF exception found" )
+ main.log.error( self.name + ": " + self.handle.before )
+ main.cleanup()
+ main.exit()
+ except Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
+ main.cleanup()
+ main.exit()
def runOnosTopoCfg( self, instanceName, jsonFile ):
"""
@@ -1291,8 +1258,15 @@
self.handle.sendline( "cd ~" )
self.handle.expect( "\$" )
return main.TRUE
- except:
- 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 Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
+ main.cleanup()
+ main.exit()
def tsharkGrep( self, grep, directory, interface='eth0' ):
"""
@@ -1306,33 +1280,55 @@
and stores the results to specified directory.
The timestamp is hardcoded to be in epoch
"""
- self.handle.sendline( "" )
- self.handle.expect( "\$" )
- self.handle.sendline( "" )
- self.handle.sendline(
- "tshark -i " +
- str( interface ) +
- " -t e | grep --line-buffered \"" +
- str(grep) +
- "\" >" +
- directory +
- " &" )
- self.handle.sendline( "\r" )
- self.handle.expect( "Capturing on" )
- self.handle.sendline( "\r" )
- self.handle.expect( "\$" )
+ try:
+ self.handle.sendline( "" )
+ self.handle.expect( "\$" )
+ self.handle.sendline( "" )
+ self.handle.sendline(
+ "tshark -i " +
+ str( interface ) +
+ " -t e | grep --line-buffered \"" +
+ str(grep) +
+ "\" >" +
+ directory +
+ " &" )
+ self.handle.sendline( "\r" )
+ self.handle.expect( "Capturing on" )
+ self.handle.sendline( "\r" )
+ self.handle.expect( "\$" )
+ except pexpect.EOF:
+ main.log.error( self.name + ": EOF exception found" )
+ main.log.error( self.name + ": " + self.handle.before )
+ main.cleanup()
+ main.exit()
+ except Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
+ main.cleanup()
+ main.exit()
+
def tsharkStop( self ):
"""
Removes wireshark files from /tmp and kills all tshark processes
"""
# Remove all pcap from previous captures
- self.execute( cmd="sudo rm /tmp/wireshark*" )
- self.handle.sendline( "" )
- self.handle.sendline( "sudo kill -9 `ps -ef | grep \"tshark -i\" |" +
- " grep -v grep | awk '{print $2}'`" )
- self.handle.sendline( "" )
- main.log.info( "Tshark stopped" )
+ try:
+ self.execute( cmd="sudo rm /tmp/wireshark*" )
+ self.handle.sendline( "" )
+ self.handle.sendline( "sudo kill -9 `ps -ef | grep \"tshark -i\" |" +
+ " grep -v grep | awk '{print $2}'`" )
+ self.handle.sendline( "" )
+ main.log.info( "Tshark stopped" )
+ except pexpect.EOF:
+ main.log.error( self.name + ": EOF exception found" )
+ main.log.error( self.name + ": " + self.handle.before )
+ main.cleanup()
+ main.exit()
+ except Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
+ main.cleanup()
+ main.exit()
+
def ptpd( self, args ):
"""
@@ -1367,10 +1363,8 @@
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( self.name + " ::::::" )
+ except Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
@@ -1407,13 +1401,9 @@
destDir += "/"
if copyFileName:
- self.handle.sendline(
- "cp " +
- str( logToCopy ) +
- " " +
- str( destDir ) +
- str( copyFileName ) +
- localtime )
+ self.handle.sendline( "cp " + str( logToCopy ) + " " +
+ str( destDir ) + str( copyFileName ) +
+ localtime )
self.handle.expect( "cp" )
self.handle.expect( "\$" )
else:
@@ -1428,11 +1418,9 @@
main.log.error( "Copying files failed" )
main.log.error( self.name + ": EOF exception found" )
main.log.error( self.name + ": " + self.handle.before )
- except:
- main.log.error( "Copying files failed" )
- main.log.info( self.name + " ::::::" )
- main.log.error( traceback.print_exc() )
- main.log.info( self.name + " ::::::" )
+ except Exception:
+ main.log.exception( "Copying files failed" )
+
def checkLogs( self, onosIp ):
"""
@@ -1450,11 +1438,10 @@
main.log.error( "Lost ssh connection" )
main.log.error( self.name + ": EOF exception found" )
main.log.error( self.name + ": " + self.handle.before )
- except:
- main.log.error( "Some error in check_logs:" )
- main.log.info( self.name + " ::::::" )
- main.log.error( traceback.print_exc() )
- main.log.info( self.name + " ::::::" )
+ except Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
+ main.cleanup()
+ main.exit()
def onosStatus( self, node="" ):
"""
@@ -1485,10 +1472,8 @@
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( self.name + " ::::::" )
+ except Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
@@ -1585,8 +1570,8 @@
main.log.error( self.name + ": " + self.handle.before )
main.cleanup()
main.exit()
- except:
- main.log.exception( "Unknown error:")
+ except Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
@@ -1631,8 +1616,8 @@
main.log.error( self.name + ": " + self.handle.before )
main.cleanup()
main.exit()
- except:
- main.log.exception( "Unknown error:")
+ except Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
diff --git a/TestON/drivers/common/cli/quaggaclidriver.py b/TestON/drivers/common/cli/quaggaclidriver.py
index 98f83d2..5631c9b 100644
--- a/TestON/drivers/common/cli/quaggaclidriver.py
+++ b/TestON/drivers/common/cli/quaggaclidriver.py
@@ -2,13 +2,7 @@
import time
import pexpect
-import struct
-import fcntl
-import os
import sys
-import signal
-import sys
-import re
import json
sys.path.append( "../" )
from drivers.common.clidriver import CLI
@@ -87,7 +81,7 @@
try:
self.handle.sendline( "" )
self.handle.expect( "bgpd#" )
- except:
+ except Exception:
main.log.warn( "Probably not currently in enable mode!" )
self.disconnect()
return main.FALSE
@@ -98,7 +92,7 @@
self.handle.sendline( routerAS )
self.handle.expect( "config-router", timeout=5 )
return main.TRUE
- except:
+ except Exception:
return main.FALSE
def generatePrefixes( self, net, numRoutes ):
@@ -335,7 +329,7 @@
self.handle.sendline( "" )
# self.handle.expect( "config-router" )
self.handle.expect( "config-router", timeout=5 )
- except:
+ except Exception:
main.log.warn( "Probably not in config-router mode!" )
self.disconnect()
main.log.info( "Start to add routes" )
@@ -345,7 +339,7 @@
try:
self.handle.sendline( routeCmd )
self.handle.expect( "bgpd", timeout=5 )
- except:
+ except Exception:
main.log.warn( "Failed to add route" )
self.disconnect()
# waitTimer = 1.00 / routeRate
@@ -363,7 +357,7 @@
self.handle.sendline( "" )
# self.handle.expect( "config-router" )
self.handle.expect( "config-router", timeout=5 )
- except:
+ except Exception:
main.log.warn( "Probably not in config-router mode!" )
self.disconnect()
main.log.info( "Start to delete routes" )
@@ -373,7 +367,7 @@
try:
self.handle.sendline( routeCmd )
self.handle.expect( "bgpd", timeout=5 )
- except:
+ except Exception:
main.log.warn( "Failed to delete route" )
self.disconnect()
# waitTimer = 1.00 / routeRate
@@ -417,7 +411,7 @@
try:
self.handle.sendline( "" )
self.handle.expect( "config-router" )
- except:
+ except Exception:
main.log.warn( "Probably not in config-router mode!" )
self.disconnect()
main.log.info( "Adding Routes" )
@@ -438,7 +432,7 @@
try:
self.handle.sendline( routeCmd )
self.handle.expect( "bgpd" )
- except:
+ except Exception:
main.log.warn( "failed to add route" )
self.disconnect()
waitTimer = 1.00 / routeRate
@@ -452,9 +446,9 @@
try:
self.handle.sendline( routeCmd )
self.handle.expect( "bgpd" )
- except:
+ except Exception:
main.log.warn( "failed to add route" )
- self.disconnect
+ self.disconnect()
waitTimer = 1.00 / routeRate
time.sleep( waitTimer )
routesAdded = routesAdded + 1
@@ -467,7 +461,7 @@
try:
self.handle.sendline( "" )
self.handle.expect( "config-router" )
- except:
+ except Exception:
main.log.warn( "Probably not in config-router mode!" )
self.disconnect()
main.log.info( "Deleting Routes" )
@@ -488,7 +482,7 @@
try:
self.handle.sendline( routeCmd )
self.handle.expect( "bgpd" )
- except:
+ except Exception:
main.log.warn( "Failed to delete route" )
self.disconnect()
waitTimer = 1.00 / routeRate
@@ -502,7 +496,7 @@
try:
self.handle.sendline( routeCmd )
self.handle.expect( "bgpd" )
- except:
+ except Exception:
main.log.warn( "Failed to delete route" )
self.disconnect()
waitTimer = 1.00 / routeRate
@@ -578,7 +572,7 @@
response = ''
try:
self.handle.close()
- except:
+ except Exception:
main.log.error( "Connection failed to the host" )
response = main.FALSE
return response