Tools/LogAnalyzer: Use more specific exceptions
This commit is contained in:
parent
42f202d0ff
commit
da0c365f3d
@ -40,7 +40,7 @@ class Format(object):
|
||||
return int(value)
|
||||
elif valueType in "nNZ":
|
||||
return str(value)
|
||||
except:
|
||||
except ValueError:
|
||||
pass
|
||||
return value
|
||||
|
||||
@ -261,7 +261,7 @@ class Channel(object):
|
||||
if line >= lineNumber:
|
||||
return (self.listData[index][1], line)
|
||||
index += 1
|
||||
raise Exception("Error finding nearest value for line %d" % lineNumber)
|
||||
raise ValueError("Error finding nearest value for line %d" % lineNumber)
|
||||
|
||||
def getNearestValueBack(self, lineNumber):
|
||||
'''Returns (value,lineNumber)'''
|
||||
@ -272,19 +272,19 @@ class Channel(object):
|
||||
if line <= lineNumber:
|
||||
return (self.listData[index][1], line)
|
||||
index -= 1
|
||||
raise Exception("Error finding nearest value for line %d" % lineNumber)
|
||||
raise ValueError("Error finding nearest value for line %d" % lineNumber)
|
||||
|
||||
def getNearestValue(self, lineNumber, lookForwards=True):
|
||||
'''find the nearest data value to the given lineNumber, defaults to first looking forwards. Returns (value,lineNumber)'''
|
||||
if lookForwards:
|
||||
try:
|
||||
return self.getNearestValueFwd(lineNumber)
|
||||
except:
|
||||
except ValueError:
|
||||
return self.getNearestValueBack(lineNumber)
|
||||
else:
|
||||
try:
|
||||
return self.getNearestValueBack(lineNumber)
|
||||
except:
|
||||
except ValueError:
|
||||
return self.getNearestValueFwd(lineNumber)
|
||||
raise Exception("Error finding nearest value for line %d" % lineNumber)
|
||||
|
||||
@ -797,7 +797,7 @@ class DataflashLog(object):
|
||||
break
|
||||
try:
|
||||
e = typ.from_buffer(data, offset)
|
||||
except:
|
||||
except ValueError:
|
||||
print(
|
||||
"data:{} offset:{} size:{} sizeof:{} sum:{}".format(
|
||||
len(data), offset, typ.SIZE, ctypes.sizeof(typ), offset + typ.SIZE
|
||||
|
@ -154,7 +154,7 @@ class TestSuite(object):
|
||||
xml = sys.stdout
|
||||
else:
|
||||
xml = open(xmlFile, 'w')
|
||||
except:
|
||||
except IOError:
|
||||
sys.stderr.write("Error opening output xml file: %s" % xmlFile)
|
||||
sys.exit(1)
|
||||
|
||||
|
@ -120,7 +120,7 @@ class TestAutotune(Test):
|
||||
line = logdata.channels['ATUN']['RateMax'].getNearestValueFwd(linenext)[1]
|
||||
if line > a.linestop:
|
||||
break
|
||||
except:
|
||||
except ValueError:
|
||||
break
|
||||
atun = class_from_channel('ATUN')()
|
||||
for key in logdata.channels['ATUN']:
|
||||
|
Loading…
Reference in New Issue
Block a user