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/core/iniparser.py b/TestON/core/iniparser.py
index b952f2d..c350a20 100644
--- a/TestON/core/iniparser.py
+++ b/TestON/core/iniparser.py
@@ -48,7 +48,7 @@
try :
parsedInfo = ConfigObj(self.fileName)
return parsedInfo
- except :
+ except Exception:
print "There is no such file to parse "+fileName
else:
return 0
diff --git a/TestON/core/jsonparser.py b/TestON/core/jsonparser.py
index 8726e87..fea797a 100644
--- a/TestON/core/jsonparser.py
+++ b/TestON/core/jsonparser.py
@@ -21,7 +21,6 @@
'''
-import re
import json
class JsonParser:
'''
@@ -37,7 +36,7 @@
response_dict = {}
try :
response_dict = json.loads(json_response)
- except :
+ except Exception:
main.log.error("Json Parser is unable to parse the string")
return response_dict
@@ -50,7 +49,7 @@
json_response = {}
try :
json_response = json.dumps(response_dict)
- except :
+ except Exception:
main.log.error("Json Parser is unable to parse the string")
return json_response
'''
diff --git a/TestON/core/teston.py b/TestON/core/teston.py
index f48d3dd..a169ffd 100644
--- a/TestON/core/teston.py
+++ b/TestON/core/teston.py
@@ -90,8 +90,7 @@
self.logs_path = logs_path
self.driver = ''
self.Thread = Thread
-
-
+
self.configparser()
verifyOptions(options)
load_logger()
@@ -142,7 +141,7 @@
try :
self.configDict = xmldict.xml_to_dict(xml)
return self.configDict
- except :
+ except Exception:
print "There is no such file to parse " + self.configFile
def componentInit(self,component):
@@ -199,14 +198,14 @@
test = testparser.TestParser(testFile)
self.testscript = test.testscript
self.code = test.getStepCode()
- repeat= int(self.params['repeat']) if ('repeat' in self.params) else 1
- main.TOTAL_TC_PLANNED = len(self.testcases_list)*repeat
+ repeat= int(self.params['repeat']) if ('repeat' in self.params) else 1
+ self.TOTAL_TC_PLANNED = len(self.testcases_list)*repeat
result = self.TRUE
- while(repeat):
+ while(repeat):
for self.CurrentTestCaseNumber in self.testcases_list:
result = self.runCase(self.CurrentTestCaseNumber)
- repeat-=1
+ repeat-=1
return result
def runCase(self,testCaseNumber):
@@ -220,15 +219,15 @@
try :
self.stepList = self.code[self.testCaseNumber].keys()
except KeyError:
- main.log.error("There is no Test-Case "+ self.testCaseNumber)
- return main.FALSE
+ self.log.error("There is no Test-Case "+ self.testCaseNumber)
+ return self.FALSE
self.stepCount = 0
while self.stepCount < len(self.code[self.testCaseNumber].keys()):
result = self.runStep(self.stepList,self.code,self.testCaseNumber)
- if result == main.FALSE:
+ if result == self.FALSE:
break
- elif result == main.TRUE :
+ elif result == self.TRUE:
continue
if not stopped :
@@ -436,7 +435,7 @@
xml_match = re.search('^\s*\<', response)
ini_match = re.search('^\s*\[', response)
if json_match :
- main.log.info(" Response is in 'JSON' format and Converting to '"+return_format+"' format")
+ self.log.info(" Response is in 'JSON' format and Converting to '"+return_format+"' format")
# Formatting the json string
response = re.sub(r"{\s*'?(\w)", r'{"\1', response)
@@ -448,12 +447,12 @@
import json
response_dict = json.loads(response)
except Exception, e:
- main.log.exception( e )
- main.log.error("Json Parser is unable to parse the string")
+ self.log.exception( e )
+ self.log.error("Json Parser is unable to parse the string")
return response_dict
elif ini_match :
- main.log.info(" Response is in 'INI' format and Converting to '"+return_format+"' format")
+ self.log.info(" Response is in 'INI' format and Converting to '"+return_format+"' format")
from configobj import ConfigObj
response_file = open("respnse_file.temp",'w')
response_file.write(response)
@@ -462,11 +461,11 @@
return response_dict
elif xml_match :
- main.log.info(" Response is in 'XML' format and Converting to '"+return_format+"' format")
+ self.log.info(" Response is in 'XML' format and Converting to '"+return_format+"' format")
try :
response_dict = xmldict.xml_to_dict("<response> "+str(response)+" </response>")
except Exception, e:
- main.log.exception( e )
+ self.log.exception( e )
return response_dict
def dict_to_return_format(self,response,return_format,response_dict):
@@ -585,7 +584,7 @@
def verifyTestCases(options):
#Getting Test cases list
if options.testcases:
- testcases_list = options.testcases
+ testcases_list = options.testcases
#sys.exit()
testcases_list = re.sub("(\[|\])", "", options.testcases)
main.testcases_list = eval(testcases_list+",")
@@ -594,18 +593,18 @@
temp = eval(main.params['testcases']+",")
list1=[]
if type(temp[0])==list:
- for test in temp:
- for testcase in test:
- if type(testcase)==int:
- testcase=[testcase]
- list1.extend(testcase)
- else :
- temp=list(temp)
- for testcase in temp:
- if type(testcase)==int:
- testcase=[testcase]
- list1.extend(testcase)
- main.testcases_list=list1
+ for test in temp:
+ for testcase in test:
+ if type(testcase)==int:
+ testcase=[testcase]
+ list1.extend(testcase)
+ else :
+ temp=list(temp)
+ for testcase in temp:
+ if type(testcase)==int:
+ testcase=[testcase]
+ list1.extend(testcase)
+ main.testcases_list=list1
else :
print "testcases not specifed in params, please provide in params file or 'testcases' commandline argument"
sys.exit()
diff --git a/TestON/core/utilities.py b/TestON/core/utilities.py
index b6bed3e..671dba5 100644
--- a/TestON/core/utilities.py
+++ b/TestON/core/utilities.py
@@ -29,11 +29,9 @@
'''
import re
from configobj import ConfigObj
-import pydoc
from core import ast as ast
import smtplib
-import mimetypes
import email
import os
import email.mime.application
@@ -265,7 +263,7 @@
try :
parsedInfo = ConfigObj(self.fileName)
return parsedInfo
- except :
+ except Exception:
print "There is no such file to parse "+fileName
else:
return 0
diff --git a/TestON/core/xmldict.py b/TestON/core/xmldict.py
index 34e9cfc..f873014 100644
--- a/TestON/core/xmldict.py
+++ b/TestON/core/xmldict.py
@@ -37,7 +37,7 @@
root = ElementTree.XML(root_or_str)
try :
return {root.tag: _from_xml(root, strict)}
- except :
+ except Exception:
return None
def dict_to_xml(dict_xml):
diff --git a/TestON/core/xmlparser.py b/TestON/core/xmlparser.py
index 3cb4aee..a46750a 100644
--- a/TestON/core/xmlparser.py
+++ b/TestON/core/xmlparser.py
@@ -39,7 +39,7 @@
try :
parsedInfo = xmldict.xml_to_dict(xml)
return parsedInfo
- except :
+ except Exception:
print "There is no such file to parse " + fileName
else :
print "file name is not correct"
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
diff --git a/TestON/tests/HATestClusterRestart/HATestClusterRestart.py b/TestON/tests/HATestClusterRestart/HATestClusterRestart.py
index e9beb0c..72a9c14 100644
--- a/TestON/tests/HATestClusterRestart/HATestClusterRestart.py
+++ b/TestON/tests/HATestClusterRestart/HATestClusterRestart.py
@@ -243,7 +243,7 @@
response = main.Mininet1.getSwController( "s" + str( i ) )
try:
main.log.info( str( response ) )
- except:
+ except Exception:
main.log.info( repr( response ) )
if re.search( "tcp:" + ONOS1Ip, response )\
and re.search( "tcp:" + ONOS2Ip, response )\
@@ -1362,7 +1362,7 @@
print json.dumps( json.loads( ONOS1Intents ),
sort_keys=True, indent=4,
separators=( ',', ': ' ) )
- except:
+ except Exception:
pass
sameIntents = main.FALSE
utilities.assert_equals(
diff --git a/TestON/tests/HATestMinorityRestart/HATestMinorityRestart.py b/TestON/tests/HATestMinorityRestart/HATestMinorityRestart.py
index de26e67..8649f98 100644
--- a/TestON/tests/HATestMinorityRestart/HATestMinorityRestart.py
+++ b/TestON/tests/HATestMinorityRestart/HATestMinorityRestart.py
@@ -243,7 +243,7 @@
response = main.Mininet1.getSwController( "s" + str( i ) )
try:
main.log.info( str( response ) )
- except:
+ except Exception:
main.log.info( repr( response ) )
if re.search( "tcp:" + ONOS1Ip, response )\
and re.search( "tcp:" + ONOS2Ip, response )\
@@ -401,6 +401,7 @@
Assign intents
"""
import time
+ import json
main.log.report( "Adding host intents" )
main.case( "Adding host Intents" )
@@ -493,6 +494,7 @@
"""
Ping across added host intents
"""
+ import json
description = " Ping across added host intents"
main.log.report( description )
main.case( description )
@@ -1136,6 +1138,7 @@
Check state after ONOS failure
"""
import json
+ import time
main.case( "Running ONOS Constant State Tests" )
# Assert that each device has a master
@@ -1363,7 +1366,7 @@
print json.dumps( json.loads( ONOS1Intents ),
sort_keys=True, indent=4,
separators=( ',', ': ' ) )
- except:
+ except Exception:
pass
sameIntents = main.FALSE
utilities.assert_equals(
@@ -1475,8 +1478,8 @@
if result == main.TRUE:
main.log.report( "Constant State Tests Passed" )
utilities.assert_equals( expect=main.TRUE, actual=result,
- onpass="Constant State Tests Passed",
- onfail="Constant state tests failed" )
+ onpass="Constant State Tests Passed",
+ onfail="Constant state tests failed" )
def CASE8( self, main ):
"""
diff --git a/TestON/tests/HATestSanity/HATestSanity.py b/TestON/tests/HATestSanity/HATestSanity.py
index 590ff56..96d0858 100644
--- a/TestON/tests/HATestSanity/HATestSanity.py
+++ b/TestON/tests/HATestSanity/HATestSanity.py
@@ -243,7 +243,7 @@
response = main.Mininet1.getSwController( "s" + str( i ) )
try:
main.log.info( str( response ) )
- except:
+ except Exception:
main.log.info( repr( response ) )
if re.search( "tcp:" + ONOS1Ip, response )\
and re.search( "tcp:" + ONOS2Ip, response )\
@@ -1325,7 +1325,7 @@
print json.dumps( json.loads( ONOS1Intents ),
sort_keys=True, indent=4,
separators=( ',', ': ' ) )
- except:
+ except Exception:
pass
sameIntents = main.FALSE
utilities.assert_equals(
diff --git a/TestON/tests/HATestSingleInstanceRestart/HATestSingleInstanceRestart.py b/TestON/tests/HATestSingleInstanceRestart/HATestSingleInstanceRestart.py
index 44ce741..81b3afd 100644
--- a/TestON/tests/HATestSingleInstanceRestart/HATestSingleInstanceRestart.py
+++ b/TestON/tests/HATestSingleInstanceRestart/HATestSingleInstanceRestart.py
@@ -180,7 +180,7 @@
response = main.Mininet1.getSwController( "s" + str( i ) )
try:
main.log.info( str( response ) )
- except:
+ except Exception:
main.log.info( repr( response ) )
if re.search( "tcp:" + ONOS1Ip, response ):
mastershipCheck = mastershipCheck and main.TRUE
@@ -198,6 +198,7 @@
"""
Assign intents
"""
+ import json
# FIXME: we must reinstall intents until we have a persistant
# datastore!
import time
@@ -280,6 +281,7 @@
"""
Ping across added host intents
"""
+ import json
description = " Ping across added host intents"
main.log.report( description )
main.case( description )
@@ -499,9 +501,9 @@
utilities.assert_equals( expect=main.TRUE, actual=caseResults,
onpass="ONOS restart successful",
onfail="ONOS restart NOT successful" )
- main.log.info(
- "ESTIMATE: ONOS took %s seconds to restart" %
- str( elapsed ) )
+ if elapsed:
+ main.log.info( "ESTIMATE: ONOS took %s seconds to restart" %
+ str( elapsed ) )
time.sleep( 5 )
def CASE7( self, main ):
@@ -613,7 +615,7 @@
print json.dumps( json.loads( ONOS1Intents ),
sort_keys=True, indent=4,
separators=( ',', ': ' ) )
- except:
+ except Exception:
pass
sameIntents = main.FALSE
utilities.assert_equals(
diff --git a/TestON/tests/PingallExample/PingallExample.py b/TestON/tests/PingallExample/PingallExample.py
index 653397e..dab380f 100644
--- a/TestON/tests/PingallExample/PingallExample.py
+++ b/TestON/tests/PingallExample/PingallExample.py
@@ -127,7 +127,7 @@
response = main.Mininet1.getSwController( "s" + str( i ) )
try:
main.log.info( str( response ) )
- except:
+ except Exception:
main.log.info( repr( response ) )
if re.search( "tcp:" + ONOS1Ip, response ):
mastershipCheck = mastershipCheck and main.TRUE