1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
|
from test.helpers.psqldb import PgSQLConnection
from test.helpers.setup_xml import XMLSetup
def find_between( s, first, last ):
try:
start = s.index( first ) + len( first )
end = s.index( last, start )
return s[start:end]
except ValueError:
return ""
class TestSrv_Database(object):
''' TestSrv Database Helper '''
__sqlObject = None
__xml_setup = None
def __init__(self):
pass
def open (self, xmlObj):
self.__xml_setup = xmlObj;
self.__sqlObject = PgSQLConnection()
return self.__sqlObject.db_connect(self.__xml_setup.getdbConnectionStr())
def create_board(self, processor_id, model_id, variant, bmac = None):
'''create a new board'''
if bmac is None:
sql = "SELECT isee.create_board('{}', '{}', '{}', NULL);".format(processor_id, model_id, variant)
else:
sql = "SELECT isee.create_board('{}', '{}', '{}', '{}');".format(processor_id, model_id, variant, bmac)
#print('>>>' + sql)
try:
res = self.__sqlObject.db_execute_query(sql)
#print(res)
return res[0][0];
except Exception as err:
r = find_between(str(err), '#', '#')
#print(r)
return None
def create_model(self, modid, variant, descr, tgid):
'''create new model'''
sql = "SELECT isee.create_model('{}', '{}', '{}', '{}')".format(modid, variant, descr, tgid)
#print('>>>' + sql)
try:
res = self.__sqlObject.db_execute_query(sql)
#print(res)
return res[0][0];
except Exception as err:
r = find_between(str(err), '#', '#')
#print(r)
return None
def create_test_definition(self, testname, testdesc, testfunc):
'''Create a new definition and return definition id on fail (testname already exist) return -1'''
sql = "SELECT isee.define_test('{}', '{}', '{}')".format(testname, testdesc, testfunc)
#print('>>>' + sql)
try:
res = self.__sqlObject.db_execute_query(sql)
#print(res)
return res[0][0];
except Exception as err:
r = find_between(str(err), '#', '#')
#print(r)
return None
def add_testdef_to_group(self, testgroupid, testname, testparam):
'''Assign definition to group test return true on success or false if it fails'''
sql = "SELECT isee.add_test_to_group('{}', '{}', '{}')".format(testgroupid, testname, testparam)
#print('>>>' + sql)
try:
res = self.__sqlObject.db_execute_query(sql)
#print(res)
return res[0][0];
except Exception as err:
r = find_between(str(err), '#', '#')
#print(r)
return None
def getboard_test_list(self, board_uuid):
'''get the board test list'''
sql = "SELECT isee.gettestlist('{}')".format(board_uuid)
#print('>>>' + sql)
try:
res = self.__sqlObject.db_execute_query(sql)
#print(res)
return res;
except Exception as err:
r = find_between(str(err), '#', '#')
#print(r)
return None
def getboard_comp_test_list(self, board_uuid):
'''get the board test list'''
sql = "SELECT * FROM isee.gettestcompletelist('{}')".format(board_uuid)
#print('>>>' + sql)
try:
res = self.__sqlObject.db_execute_query(sql)
#print(res)
return res;
except Exception as err:
r = find_between(str(err), '#', '#')
#print(r)
return None
def getboard_test_variables(self, board_uuid, testdefid):
'''get the board test list'''
sql = "SELECT * FROM isee.getboardtestvariables('{}', '{}')".format(board_uuid, testdefid)
#print('>>>' + sql)
try:
res = self.__sqlObject.db_execute_query(sql)
#print(res)
return res;
except Exception as err:
r = find_between(str(err), '#', '#')
#print(r)
return None
def open_testbatch(self, board_uuid, station):
'''get the board test list'''
sql = "SELECT * FROM isee.open_testbatch('{}','{}')".format(board_uuid, station)
#print('>>>' + sql)
try:
res = str(self.__sqlObject.db_execute_query(sql)[0])
res = res.replace('(', '')
res = res.replace(')', '')
res = res.replace(',', '')
#print(res)
return res;
except Exception as err:
r = find_between(str(err), '#', '#')
#print(r)
return None
def add_test_to_batch(self, board_uuid, testid, testid_ctl, result, groupid, data):
'''get the board test list'''
sql = "SELECT isee.add_test_to_batch_c('{}','{}','{}','{}','{}','{}')".format(board_uuid, testid, testid_ctl, result, groupid, data)
#print('>>>' + sql)
try:
res = self.__sqlObject.db_execute_query(sql)
#print(res)
return res;
except Exception as err:
r = find_between(str(err), '#', '#')
#print(r)
return None
def close_testbatch(self, board_uuid, testid_ctl):
'''get the board test list'''
sql = "SELECT isee.close_testbatch('{}','{}')".format(board_uuid, testid_ctl)
#print('>>>' + sql)
try:
res = self.__sqlObject.db_execute_query(sql)
#print(res)
return res;
except Exception as err:
r = find_between(str(err), '#', '#')
#print(r)
return None
def update_set_test_row(self, nstation, testid_ctl, board_uuid, ctest, cstatus):
'''get the board test list'''
sql = "SELECT isee.update_set_test_row('{}','{}','{}','{}','{}')".format(nstation, testid_ctl ,board_uuid, ctest, cstatus)
#print('>>>' + sql)
try:
res = self.__sqlObject.db_execute_query(sql)
#print(res)
return res;
except Exception as err:
r = find_between(str(err), '#', '#')
#print(r)
return None
|