Python script improvements
This commit is contained in:
+25
-11
@@ -9,26 +9,37 @@ global print_log, sendFeedback, sys, inspect, os, traceback
|
||||
import sys, inspect, os, traceback
|
||||
|
||||
class TestingTool:
|
||||
|
||||
"""
|
||||
Common tools for running the test
|
||||
"""
|
||||
|
||||
def __init__(self, testName, testPath, deviceName, testParams):
|
||||
"""
|
||||
Init class with test data
|
||||
"""
|
||||
self.deviceName = deviceName
|
||||
self.testName = testName
|
||||
self.testPath = testPath
|
||||
self.testParams = testParams
|
||||
|
||||
#get specific test parameter
|
||||
#paramName = the name of the parameter for which the value must be read
|
||||
|
||||
|
||||
def getParam(self, paramName):
|
||||
"""
|
||||
get specific test parameter
|
||||
paramName = the name of the parameter for which the value must be read
|
||||
"""
|
||||
try:
|
||||
return self.testParams[paramName]["value"]
|
||||
except:
|
||||
self.log('Could not retrieve testing parameter ' + paramName + ' - Details: ' + traceback.format_exc())
|
||||
return None
|
||||
|
||||
#print/log information
|
||||
#text = the string to be printed/logged
|
||||
|
||||
|
||||
def log(self, text):
|
||||
"""
|
||||
Print/log information
|
||||
text = the string to be printed/logged
|
||||
"""
|
||||
import time
|
||||
time.ctime()
|
||||
now = time.strftime('%Y.%m.%d %H:%M:%S')
|
||||
@@ -44,11 +55,14 @@ class TestingTool:
|
||||
except:
|
||||
#cannot write log
|
||||
print now + ' ' + self.deviceName + ' - ' + self.testName + ': ' + 'cannot write Log in Data'
|
||||
|
||||
#prepare and send feedback to calling tool
|
||||
# returnString = the string containing info on the test result
|
||||
# testPassed = true if the test was successful, false if test had a problem
|
||||
|
||||
|
||||
def sendFeedback(self, returnString, testPassed):
|
||||
"""
|
||||
Prepare and send feedback to calling tool
|
||||
returnString = the string containing info on the test result
|
||||
testPassed = true if the test was successful, false if test had a problem
|
||||
"""
|
||||
self.log('End of test. Result:')
|
||||
#self.log('Device: ' + self.deviceName)
|
||||
#self.log('Test name: ' + self.testName)
|
||||
|
||||
Reference in New Issue
Block a user