60 lines
2.4 KiB
Python
60 lines
2.4 KiB
Python
###################################################################################################
|
|
# Deployment specific global definitions - executed after startup.py
|
|
###################################################################################################
|
|
|
|
#Uncomment this line to create the simulated devices needed to the tutorial scripts.
|
|
#run("tutorial/devices")
|
|
|
|
global print_log, sendFeedback, sys, inspect, os, traceback
|
|
import sys, inspect, os, traceback
|
|
|
|
class TestingTool:
|
|
|
|
|
|
def __init__(self, testName, testPath, deviceName, testParams):
|
|
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):
|
|
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):
|
|
import time
|
|
time.ctime()
|
|
now = time.strftime('%Y.%m.%d %H:%M:%S')
|
|
logText = self.deviceName + ' - ' + self.testName + ': ' + str(text)
|
|
print now + ' ' + logText
|
|
try:
|
|
log(logText)
|
|
except:
|
|
#cannot write log. maybe busy? Wait and retry
|
|
time.sleep(1)
|
|
try:
|
|
log(logText)
|
|
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):
|
|
self.log('End of test. Result:')
|
|
#self.log('Device: ' + self.deviceName)
|
|
#self.log('Test name: ' + self.testName)
|
|
#self.log('Test path: ' + self.testPath)
|
|
self.log('Test passed: ' + str(testPassed))
|
|
self.log('Return message: ' + returnString)
|
|
ret = [self.testPath, self.deviceName, returnString, testPassed]
|
|
set_return( ret)
|