The requested changes are too big and content was truncated. Show full diff
@@ -1,1142 +1,1145 | |||||
1 | ''' |
|
1 | ''' | |
2 | Created on September , 2012 |
|
2 | Created on September , 2012 | |
3 | @author: |
|
3 | @author: | |
4 | ''' |
|
4 | ''' | |
5 | from xml.etree.ElementTree import ElementTree, Element, SubElement, tostring |
|
5 | from xml.etree.ElementTree import ElementTree, Element, SubElement, tostring | |
6 | from xml.dom import minidom |
|
6 | from xml.dom import minidom | |
7 |
|
7 | |||
8 | from model import * |
|
8 | from model import * | |
9 | from time import sleep |
|
9 | from time import sleep | |
10 |
|
10 | |||
11 | import sys |
|
11 | import sys | |
12 | import ast |
|
12 | import ast | |
13 | import traceback |
|
13 | import traceback | |
14 |
|
14 | |||
15 | SCHAIN_MAIL = "miguel.urco@jro.igp.gob.pe" |
|
15 | SCHAIN_MAIL = "miguel.urco@jro.igp.gob.pe" | |
16 | EMAIL_SERVER = "jro.igp.gob.pe" |
|
16 | EMAIL_SERVER = "jro.igp.gob.pe" | |
17 |
|
17 | |||
18 | def prettify(elem): |
|
18 | def prettify(elem): | |
19 | """Return a pretty-printed XML string for the Element. |
|
19 | """Return a pretty-printed XML string for the Element. | |
20 | """ |
|
20 | """ | |
21 | rough_string = tostring(elem, 'utf-8') |
|
21 | rough_string = tostring(elem, 'utf-8') | |
22 | reparsed = minidom.parseString(rough_string) |
|
22 | reparsed = minidom.parseString(rough_string) | |
23 | return reparsed.toprettyxml(indent=" ") |
|
23 | return reparsed.toprettyxml(indent=" ") | |
24 |
|
24 | |||
25 | class ParameterConf(): |
|
25 | class ParameterConf(): | |
26 |
|
26 | |||
27 | id = None |
|
27 | id = None | |
28 | name = None |
|
28 | name = None | |
29 | value = None |
|
29 | value = None | |
30 | format = None |
|
30 | format = None | |
31 |
|
31 | |||
32 | __formated_value = None |
|
32 | __formated_value = None | |
33 |
|
33 | |||
34 | ELEMENTNAME = 'Parameter' |
|
34 | ELEMENTNAME = 'Parameter' | |
35 |
|
35 | |||
36 | def __init__(self): |
|
36 | def __init__(self): | |
37 |
|
37 | |||
38 | self.format = 'str' |
|
38 | self.format = 'str' | |
39 |
|
39 | |||
40 | def getElementName(self): |
|
40 | def getElementName(self): | |
41 |
|
41 | |||
42 | return self.ELEMENTNAME |
|
42 | return self.ELEMENTNAME | |
43 |
|
43 | |||
44 | def getValue(self): |
|
44 | def getValue(self): | |
45 |
|
45 | |||
46 | value = self.value |
|
46 | value = self.value | |
47 | format = self.format |
|
47 | format = self.format | |
48 |
|
48 | |||
49 | if self.__formated_value != None: |
|
49 | if self.__formated_value != None: | |
50 |
|
50 | |||
51 | return self.__formated_value |
|
51 | return self.__formated_value | |
52 |
|
52 | |||
53 | if format == 'str': |
|
53 | if format == 'str': | |
54 | self.__formated_value = str(value) |
|
54 | self.__formated_value = str(value) | |
55 | return self.__formated_value |
|
55 | return self.__formated_value | |
56 |
|
56 | |||
57 | if value == '': |
|
57 | if value == '': | |
58 | raise ValueError, "%s: This parameter value is empty" %self.name |
|
58 | raise ValueError, "%s: This parameter value is empty" %self.name | |
59 |
|
||||
60 | if format == 'bool': |
|
|||
61 | value = int(value) |
|
|||
62 |
|
59 | |||
63 | if format == 'list': |
|
60 | if format == 'list': | |
64 | strList = value.split(',') |
|
61 | strList = value.split(',') | |
65 |
|
62 | |||
66 | self.__formated_value = strList |
|
63 | self.__formated_value = strList | |
67 |
|
64 | |||
68 | return self.__formated_value |
|
65 | return self.__formated_value | |
69 |
|
66 | |||
70 | if format == 'intlist': |
|
67 | if format == 'intlist': | |
71 | """ |
|
68 | """ | |
72 | Example: |
|
69 | Example: | |
73 | value = (0,1,2) |
|
70 | value = (0,1,2) | |
74 | """ |
|
71 | """ | |
75 | value = value.replace('(', '') |
|
72 | value = value.replace('(', '') | |
76 | value = value.replace(')', '') |
|
73 | value = value.replace(')', '') | |
77 |
|
74 | |||
78 | value = value.replace('[', '') |
|
75 | value = value.replace('[', '') | |
79 | value = value.replace(']', '') |
|
76 | value = value.replace(']', '') | |
80 |
|
77 | |||
81 | strList = value.split(',') |
|
78 | strList = value.split(',') | |
82 | intList = [int(float(x)) for x in strList] |
|
79 | intList = [int(float(x)) for x in strList] | |
83 |
|
80 | |||
84 | self.__formated_value = intList |
|
81 | self.__formated_value = intList | |
85 |
|
82 | |||
86 | return self.__formated_value |
|
83 | return self.__formated_value | |
87 |
|
84 | |||
88 | if format == 'floatlist': |
|
85 | if format == 'floatlist': | |
89 | """ |
|
86 | """ | |
90 | Example: |
|
87 | Example: | |
91 | value = (0.5, 1.4, 2.7) |
|
88 | value = (0.5, 1.4, 2.7) | |
92 | """ |
|
89 | """ | |
93 |
|
90 | |||
94 | value = value.replace('(', '') |
|
91 | value = value.replace('(', '') | |
95 | value = value.replace(')', '') |
|
92 | value = value.replace(')', '') | |
96 |
|
93 | |||
97 | value = value.replace('[', '') |
|
94 | value = value.replace('[', '') | |
98 | value = value.replace(']', '') |
|
95 | value = value.replace(']', '') | |
99 |
|
96 | |||
100 | strList = value.split(',') |
|
97 | strList = value.split(',') | |
101 | floatList = [float(x) for x in strList] |
|
98 | floatList = [float(x) for x in strList] | |
102 |
|
99 | |||
103 | self.__formated_value = floatList |
|
100 | self.__formated_value = floatList | |
104 |
|
101 | |||
105 | return self.__formated_value |
|
102 | return self.__formated_value | |
106 |
|
103 | |||
107 | if format == 'date': |
|
104 | if format == 'date': | |
108 | strList = value.split('/') |
|
105 | strList = value.split('/') | |
109 | intList = [int(x) for x in strList] |
|
106 | intList = [int(x) for x in strList] | |
110 | date = datetime.date(intList[0], intList[1], intList[2]) |
|
107 | date = datetime.date(intList[0], intList[1], intList[2]) | |
111 |
|
108 | |||
112 | self.__formated_value = date |
|
109 | self.__formated_value = date | |
113 |
|
110 | |||
114 | return self.__formated_value |
|
111 | return self.__formated_value | |
115 |
|
112 | |||
116 | if format == 'time': |
|
113 | if format == 'time': | |
117 | strList = value.split(':') |
|
114 | strList = value.split(':') | |
118 | intList = [int(x) for x in strList] |
|
115 | intList = [int(x) for x in strList] | |
119 | time = datetime.time(intList[0], intList[1], intList[2]) |
|
116 | time = datetime.time(intList[0], intList[1], intList[2]) | |
120 |
|
117 | |||
121 | self.__formated_value = time |
|
118 | self.__formated_value = time | |
122 |
|
119 | |||
123 | return self.__formated_value |
|
120 | return self.__formated_value | |
124 |
|
121 | |||
125 | if format == 'pairslist': |
|
122 | if format == 'pairslist': | |
126 | """ |
|
123 | """ | |
127 | Example: |
|
124 | Example: | |
128 | value = (0,1),(1,2) |
|
125 | value = (0,1),(1,2) | |
129 | """ |
|
126 | """ | |
130 |
|
127 | |||
131 | value = value.replace('(', '') |
|
128 | value = value.replace('(', '') | |
132 | value = value.replace(')', '') |
|
129 | value = value.replace(')', '') | |
133 |
|
130 | |||
134 | value = value.replace('[', '') |
|
131 | value = value.replace('[', '') | |
135 | value = value.replace(']', '') |
|
132 | value = value.replace(']', '') | |
136 |
|
133 | |||
137 | strList = value.split(',') |
|
134 | strList = value.split(',') | |
138 | intList = [int(item) for item in strList] |
|
135 | intList = [int(item) for item in strList] | |
139 | pairList = [] |
|
136 | pairList = [] | |
140 | for i in range(len(intList)/2): |
|
137 | for i in range(len(intList)/2): | |
141 | pairList.append((intList[i*2], intList[i*2 + 1])) |
|
138 | pairList.append((intList[i*2], intList[i*2 + 1])) | |
142 |
|
139 | |||
143 | self.__formated_value = pairList |
|
140 | self.__formated_value = pairList | |
144 |
|
141 | |||
145 | return self.__formated_value |
|
142 | return self.__formated_value | |
146 |
|
143 | |||
147 | if format == 'multilist': |
|
144 | if format == 'multilist': | |
148 | """ |
|
145 | """ | |
149 | Example: |
|
146 | Example: | |
150 | value = (0,1,2),(3,4,5) |
|
147 | value = (0,1,2),(3,4,5) | |
151 | """ |
|
148 | """ | |
152 | multiList = ast.literal_eval(value) |
|
149 | multiList = ast.literal_eval(value) | |
153 |
|
150 | |||
154 | if type(multiList[0]) == int: |
|
151 | if type(multiList[0]) == int: | |
155 | multiList = ast.literal_eval("(" + value + ")") |
|
152 | multiList = ast.literal_eval("(" + value + ")") | |
156 |
|
153 | |||
157 | self.__formated_value = multiList |
|
154 | self.__formated_value = multiList | |
158 |
|
155 | |||
159 | return self.__formated_value |
|
156 | return self.__formated_value | |
160 |
|
157 | |||
|
158 | if format == 'bool': | |||
|
159 | value = int(value) | |||
|
160 | ||||
|
161 | if format == 'int': | |||
|
162 | value = float(value) | |||
|
163 | ||||
161 | format_func = eval(format) |
|
164 | format_func = eval(format) | |
162 |
|
165 | |||
163 | self.__formated_value = format_func(value) |
|
166 | self.__formated_value = format_func(value) | |
164 |
|
167 | |||
165 | return self.__formated_value |
|
168 | return self.__formated_value | |
166 |
|
169 | |||
167 | def updateId(self, new_id): |
|
170 | def updateId(self, new_id): | |
168 |
|
171 | |||
169 | self.id = str(new_id) |
|
172 | self.id = str(new_id) | |
170 |
|
173 | |||
171 | def setup(self, id, name, value, format='str'): |
|
174 | def setup(self, id, name, value, format='str'): | |
172 |
|
175 | |||
173 | self.id = str(id) |
|
176 | self.id = str(id) | |
174 | self.name = name |
|
177 | self.name = name | |
175 | self.value = str(value) |
|
178 | self.value = str(value) | |
176 | self.format = str.lower(format) |
|
179 | self.format = str.lower(format) | |
177 |
|
180 | |||
178 | try: |
|
181 | try: | |
179 | self.getValue() |
|
182 | self.getValue() | |
180 | except: |
|
183 | except: | |
181 | return 0 |
|
184 | return 0 | |
182 |
|
185 | |||
183 | return 1 |
|
186 | return 1 | |
184 |
|
187 | |||
185 | def update(self, name, value, format='str'): |
|
188 | def update(self, name, value, format='str'): | |
186 |
|
189 | |||
187 | self.name = name |
|
190 | self.name = name | |
188 | self.value = str(value) |
|
191 | self.value = str(value) | |
189 | self.format = format |
|
192 | self.format = format | |
190 |
|
193 | |||
191 | def makeXml(self, opElement): |
|
194 | def makeXml(self, opElement): | |
192 |
|
195 | |||
193 | parmElement = SubElement(opElement, self.ELEMENTNAME) |
|
196 | parmElement = SubElement(opElement, self.ELEMENTNAME) | |
194 | parmElement.set('id', str(self.id)) |
|
197 | parmElement.set('id', str(self.id)) | |
195 | parmElement.set('name', self.name) |
|
198 | parmElement.set('name', self.name) | |
196 | parmElement.set('value', self.value) |
|
199 | parmElement.set('value', self.value) | |
197 | parmElement.set('format', self.format) |
|
200 | parmElement.set('format', self.format) | |
198 |
|
201 | |||
199 | def readXml(self, parmElement): |
|
202 | def readXml(self, parmElement): | |
200 |
|
203 | |||
201 | self.id = parmElement.get('id') |
|
204 | self.id = parmElement.get('id') | |
202 | self.name = parmElement.get('name') |
|
205 | self.name = parmElement.get('name') | |
203 | self.value = parmElement.get('value') |
|
206 | self.value = parmElement.get('value') | |
204 | self.format = str.lower(parmElement.get('format')) |
|
207 | self.format = str.lower(parmElement.get('format')) | |
205 |
|
208 | |||
206 | #Compatible with old signal chain version |
|
209 | #Compatible with old signal chain version | |
207 | if self.format == 'int' and self.name == 'idfigure': |
|
210 | if self.format == 'int' and self.name == 'idfigure': | |
208 | self.name = 'id' |
|
211 | self.name = 'id' | |
209 |
|
212 | |||
210 | def printattr(self): |
|
213 | def printattr(self): | |
211 |
|
214 | |||
212 | print "Parameter[%s]: name = %s, value = %s, format = %s" %(self.id, self.name, self.value, self.format) |
|
215 | print "Parameter[%s]: name = %s, value = %s, format = %s" %(self.id, self.name, self.value, self.format) | |
213 |
|
216 | |||
214 | class OperationConf(): |
|
217 | class OperationConf(): | |
215 |
|
218 | |||
216 | id = None |
|
219 | id = None | |
217 | name = None |
|
220 | name = None | |
218 | priority = None |
|
221 | priority = None | |
219 | type = None |
|
222 | type = None | |
220 |
|
223 | |||
221 | parmConfObjList = [] |
|
224 | parmConfObjList = [] | |
222 |
|
225 | |||
223 | ELEMENTNAME = 'Operation' |
|
226 | ELEMENTNAME = 'Operation' | |
224 |
|
227 | |||
225 | def __init__(self): |
|
228 | def __init__(self): | |
226 |
|
229 | |||
227 | self.id = '0' |
|
230 | self.id = '0' | |
228 | self.name = None |
|
231 | self.name = None | |
229 | self.priority = None |
|
232 | self.priority = None | |
230 | self.type = 'self' |
|
233 | self.type = 'self' | |
231 |
|
234 | |||
232 |
|
235 | |||
233 | def __getNewId(self): |
|
236 | def __getNewId(self): | |
234 |
|
237 | |||
235 | return int(self.id)*10 + len(self.parmConfObjList) + 1 |
|
238 | return int(self.id)*10 + len(self.parmConfObjList) + 1 | |
236 |
|
239 | |||
237 | def updateId(self, new_id): |
|
240 | def updateId(self, new_id): | |
238 |
|
241 | |||
239 | self.id = str(new_id) |
|
242 | self.id = str(new_id) | |
240 |
|
243 | |||
241 | n = 1 |
|
244 | n = 1 | |
242 | for parmObj in self.parmConfObjList: |
|
245 | for parmObj in self.parmConfObjList: | |
243 |
|
246 | |||
244 | idParm = str(int(new_id)*10 + n) |
|
247 | idParm = str(int(new_id)*10 + n) | |
245 | parmObj.updateId(idParm) |
|
248 | parmObj.updateId(idParm) | |
246 |
|
249 | |||
247 | n += 1 |
|
250 | n += 1 | |
248 |
|
251 | |||
249 | def getElementName(self): |
|
252 | def getElementName(self): | |
250 |
|
253 | |||
251 | return self.ELEMENTNAME |
|
254 | return self.ELEMENTNAME | |
252 |
|
255 | |||
253 | def getParameterObjList(self): |
|
256 | def getParameterObjList(self): | |
254 |
|
257 | |||
255 | return self.parmConfObjList |
|
258 | return self.parmConfObjList | |
256 |
|
259 | |||
257 | def getParameterObj(self, parameterName): |
|
260 | def getParameterObj(self, parameterName): | |
258 |
|
261 | |||
259 | for parmConfObj in self.parmConfObjList: |
|
262 | for parmConfObj in self.parmConfObjList: | |
260 |
|
263 | |||
261 | if parmConfObj.name != parameterName: |
|
264 | if parmConfObj.name != parameterName: | |
262 | continue |
|
265 | continue | |
263 |
|
266 | |||
264 | return parmConfObj |
|
267 | return parmConfObj | |
265 |
|
268 | |||
266 | return None |
|
269 | return None | |
267 |
|
270 | |||
268 | def getParameterObjfromValue(self, parameterValue): |
|
271 | def getParameterObjfromValue(self, parameterValue): | |
269 |
|
272 | |||
270 | for parmConfObj in self.parmConfObjList: |
|
273 | for parmConfObj in self.parmConfObjList: | |
271 |
|
274 | |||
272 | if parmConfObj.getValue() != parameterValue: |
|
275 | if parmConfObj.getValue() != parameterValue: | |
273 | continue |
|
276 | continue | |
274 |
|
277 | |||
275 | return parmConfObj.getValue() |
|
278 | return parmConfObj.getValue() | |
276 |
|
279 | |||
277 | return None |
|
280 | return None | |
278 |
|
281 | |||
279 | def getParameterValue(self, parameterName): |
|
282 | def getParameterValue(self, parameterName): | |
280 |
|
283 | |||
281 | parameterObj = self.getParameterObj(parameterName) |
|
284 | parameterObj = self.getParameterObj(parameterName) | |
282 |
|
285 | |||
283 | # if not parameterObj: |
|
286 | # if not parameterObj: | |
284 | # return None |
|
287 | # return None | |
285 |
|
288 | |||
286 | value = parameterObj.getValue() |
|
289 | value = parameterObj.getValue() | |
287 |
|
290 | |||
288 | return value |
|
291 | return value | |
289 |
|
292 | |||
290 | def setup(self, id, name, priority, type): |
|
293 | def setup(self, id, name, priority, type): | |
291 |
|
294 | |||
292 | self.id = str(id) |
|
295 | self.id = str(id) | |
293 | self.name = name |
|
296 | self.name = name | |
294 | self.type = type |
|
297 | self.type = type | |
295 | self.priority = priority |
|
298 | self.priority = priority | |
296 |
|
299 | |||
297 | self.parmConfObjList = [] |
|
300 | self.parmConfObjList = [] | |
298 |
|
301 | |||
299 | def removeParameters(self): |
|
302 | def removeParameters(self): | |
300 |
|
303 | |||
301 | for obj in self.parmConfObjList: |
|
304 | for obj in self.parmConfObjList: | |
302 | del obj |
|
305 | del obj | |
303 |
|
306 | |||
304 | self.parmConfObjList = [] |
|
307 | self.parmConfObjList = [] | |
305 |
|
308 | |||
306 | def addParameter(self, name, value, format='str'): |
|
309 | def addParameter(self, name, value, format='str'): | |
307 |
|
310 | |||
308 | id = self.__getNewId() |
|
311 | id = self.__getNewId() | |
309 |
|
312 | |||
310 | parmConfObj = ParameterConf() |
|
313 | parmConfObj = ParameterConf() | |
311 | if not parmConfObj.setup(id, name, value, format): |
|
314 | if not parmConfObj.setup(id, name, value, format): | |
312 | return None |
|
315 | return None | |
313 |
|
316 | |||
314 | self.parmConfObjList.append(parmConfObj) |
|
317 | self.parmConfObjList.append(parmConfObj) | |
315 |
|
318 | |||
316 | return parmConfObj |
|
319 | return parmConfObj | |
317 |
|
320 | |||
318 | def changeParameter(self, name, value, format='str'): |
|
321 | def changeParameter(self, name, value, format='str'): | |
319 |
|
322 | |||
320 | parmConfObj = self.getParameterObj(name) |
|
323 | parmConfObj = self.getParameterObj(name) | |
321 | parmConfObj.update(name, value, format) |
|
324 | parmConfObj.update(name, value, format) | |
322 |
|
325 | |||
323 | return parmConfObj |
|
326 | return parmConfObj | |
324 |
|
327 | |||
325 | def makeXml(self, upElement): |
|
328 | def makeXml(self, upElement): | |
326 |
|
329 | |||
327 | opElement = SubElement(upElement, self.ELEMENTNAME) |
|
330 | opElement = SubElement(upElement, self.ELEMENTNAME) | |
328 | opElement.set('id', str(self.id)) |
|
331 | opElement.set('id', str(self.id)) | |
329 | opElement.set('name', self.name) |
|
332 | opElement.set('name', self.name) | |
330 | opElement.set('type', self.type) |
|
333 | opElement.set('type', self.type) | |
331 | opElement.set('priority', str(self.priority)) |
|
334 | opElement.set('priority', str(self.priority)) | |
332 |
|
335 | |||
333 | for parmConfObj in self.parmConfObjList: |
|
336 | for parmConfObj in self.parmConfObjList: | |
334 | parmConfObj.makeXml(opElement) |
|
337 | parmConfObj.makeXml(opElement) | |
335 |
|
338 | |||
336 | def readXml(self, opElement): |
|
339 | def readXml(self, opElement): | |
337 |
|
340 | |||
338 | self.id = opElement.get('id') |
|
341 | self.id = opElement.get('id') | |
339 | self.name = opElement.get('name') |
|
342 | self.name = opElement.get('name') | |
340 | self.type = opElement.get('type') |
|
343 | self.type = opElement.get('type') | |
341 | self.priority = opElement.get('priority') |
|
344 | self.priority = opElement.get('priority') | |
342 |
|
345 | |||
343 | #Compatible with old signal chain version |
|
346 | #Compatible with old signal chain version | |
344 | #Use of 'run' method instead 'init' |
|
347 | #Use of 'run' method instead 'init' | |
345 | if self.type == 'self' and self.name == 'init': |
|
348 | if self.type == 'self' and self.name == 'init': | |
346 | self.name = 'run' |
|
349 | self.name = 'run' | |
347 |
|
350 | |||
348 | self.parmConfObjList = [] |
|
351 | self.parmConfObjList = [] | |
349 |
|
352 | |||
350 | parmElementList = opElement.getiterator(ParameterConf().getElementName()) |
|
353 | parmElementList = opElement.getiterator(ParameterConf().getElementName()) | |
351 |
|
354 | |||
352 | for parmElement in parmElementList: |
|
355 | for parmElement in parmElementList: | |
353 | parmConfObj = ParameterConf() |
|
356 | parmConfObj = ParameterConf() | |
354 | parmConfObj.readXml(parmElement) |
|
357 | parmConfObj.readXml(parmElement) | |
355 |
|
358 | |||
356 | #Compatible with old signal chain version |
|
359 | #Compatible with old signal chain version | |
357 | #If an 'plot' OPERATION is found, changes name operation by the value of its type PARAMETER |
|
360 | #If an 'plot' OPERATION is found, changes name operation by the value of its type PARAMETER | |
358 | if self.type != 'self' and self.name == 'Plot': |
|
361 | if self.type != 'self' and self.name == 'Plot': | |
359 | if parmConfObj.format == 'str' and parmConfObj.name == 'type': |
|
362 | if parmConfObj.format == 'str' and parmConfObj.name == 'type': | |
360 | self.name = parmConfObj.value |
|
363 | self.name = parmConfObj.value | |
361 | continue |
|
364 | continue | |
362 |
|
365 | |||
363 | self.parmConfObjList.append(parmConfObj) |
|
366 | self.parmConfObjList.append(parmConfObj) | |
364 |
|
367 | |||
365 | def printattr(self): |
|
368 | def printattr(self): | |
366 |
|
369 | |||
367 | print "%s[%s]: name = %s, type = %s, priority = %s" %(self.ELEMENTNAME, |
|
370 | print "%s[%s]: name = %s, type = %s, priority = %s" %(self.ELEMENTNAME, | |
368 | self.id, |
|
371 | self.id, | |
369 | self.name, |
|
372 | self.name, | |
370 | self.type, |
|
373 | self.type, | |
371 | self.priority) |
|
374 | self.priority) | |
372 |
|
375 | |||
373 | for parmConfObj in self.parmConfObjList: |
|
376 | for parmConfObj in self.parmConfObjList: | |
374 | parmConfObj.printattr() |
|
377 | parmConfObj.printattr() | |
375 |
|
378 | |||
376 | def createObject(self): |
|
379 | def createObject(self): | |
377 |
|
380 | |||
378 | if self.type == 'self': |
|
381 | if self.type == 'self': | |
379 | raise ValueError, "This operation type cannot be created" |
|
382 | raise ValueError, "This operation type cannot be created" | |
380 |
|
383 | |||
381 | if self.type == 'external' or self.type == 'other': |
|
384 | if self.type == 'external' or self.type == 'other': | |
382 | className = eval(self.name) |
|
385 | className = eval(self.name) | |
383 | opObj = className() |
|
386 | opObj = className() | |
384 |
|
387 | |||
385 | return opObj |
|
388 | return opObj | |
386 |
|
389 | |||
387 | class ProcUnitConf(): |
|
390 | class ProcUnitConf(): | |
388 |
|
391 | |||
389 | id = None |
|
392 | id = None | |
390 | name = None |
|
393 | name = None | |
391 | datatype = None |
|
394 | datatype = None | |
392 | inputId = None |
|
395 | inputId = None | |
393 | parentId = None |
|
396 | parentId = None | |
394 |
|
397 | |||
395 | opConfObjList = [] |
|
398 | opConfObjList = [] | |
396 |
|
399 | |||
397 | procUnitObj = None |
|
400 | procUnitObj = None | |
398 | opObjList = [] |
|
401 | opObjList = [] | |
399 |
|
402 | |||
400 | ELEMENTNAME = 'ProcUnit' |
|
403 | ELEMENTNAME = 'ProcUnit' | |
401 |
|
404 | |||
402 | def __init__(self): |
|
405 | def __init__(self): | |
403 |
|
406 | |||
404 | self.id = None |
|
407 | self.id = None | |
405 | self.datatype = None |
|
408 | self.datatype = None | |
406 | self.name = None |
|
409 | self.name = None | |
407 | self.inputId = None |
|
410 | self.inputId = None | |
408 |
|
411 | |||
409 | self.opConfObjList = [] |
|
412 | self.opConfObjList = [] | |
410 |
|
413 | |||
411 | self.procUnitObj = None |
|
414 | self.procUnitObj = None | |
412 | self.opObjDict = {} |
|
415 | self.opObjDict = {} | |
413 |
|
416 | |||
414 | def __getPriority(self): |
|
417 | def __getPriority(self): | |
415 |
|
418 | |||
416 | return len(self.opConfObjList)+1 |
|
419 | return len(self.opConfObjList)+1 | |
417 |
|
420 | |||
418 | def __getNewId(self): |
|
421 | def __getNewId(self): | |
419 |
|
422 | |||
420 | return int(self.id)*10 + len(self.opConfObjList) + 1 |
|
423 | return int(self.id)*10 + len(self.opConfObjList) + 1 | |
421 |
|
424 | |||
422 | def getElementName(self): |
|
425 | def getElementName(self): | |
423 |
|
426 | |||
424 | return self.ELEMENTNAME |
|
427 | return self.ELEMENTNAME | |
425 |
|
428 | |||
426 | def getId(self): |
|
429 | def getId(self): | |
427 |
|
430 | |||
428 | return self.id |
|
431 | return self.id | |
429 |
|
432 | |||
430 | def updateId(self, new_id, parentId=parentId): |
|
433 | def updateId(self, new_id, parentId=parentId): | |
431 |
|
434 | |||
432 |
|
435 | |||
433 | new_id = int(parentId)*10 + (int(self.id) % 10) |
|
436 | new_id = int(parentId)*10 + (int(self.id) % 10) | |
434 | new_inputId = int(parentId)*10 + (int(self.inputId) % 10) |
|
437 | new_inputId = int(parentId)*10 + (int(self.inputId) % 10) | |
435 |
|
438 | |||
436 | #If this proc unit has not inputs |
|
439 | #If this proc unit has not inputs | |
437 | if self.inputId == '0': |
|
440 | if self.inputId == '0': | |
438 | new_inputId = 0 |
|
441 | new_inputId = 0 | |
439 |
|
442 | |||
440 | n = 1 |
|
443 | n = 1 | |
441 | for opConfObj in self.opConfObjList: |
|
444 | for opConfObj in self.opConfObjList: | |
442 |
|
445 | |||
443 | idOp = str(int(new_id)*10 + n) |
|
446 | idOp = str(int(new_id)*10 + n) | |
444 | opConfObj.updateId(idOp) |
|
447 | opConfObj.updateId(idOp) | |
445 |
|
448 | |||
446 | n += 1 |
|
449 | n += 1 | |
447 |
|
450 | |||
448 | self.parentId = str(parentId) |
|
451 | self.parentId = str(parentId) | |
449 | self.id = str(new_id) |
|
452 | self.id = str(new_id) | |
450 | self.inputId = str(new_inputId) |
|
453 | self.inputId = str(new_inputId) | |
451 |
|
454 | |||
452 |
|
455 | |||
453 | def getInputId(self): |
|
456 | def getInputId(self): | |
454 |
|
457 | |||
455 | return self.inputId |
|
458 | return self.inputId | |
456 |
|
459 | |||
457 | def getOperationObjList(self): |
|
460 | def getOperationObjList(self): | |
458 |
|
461 | |||
459 | return self.opConfObjList |
|
462 | return self.opConfObjList | |
460 |
|
463 | |||
461 | def getOperationObj(self, name=None): |
|
464 | def getOperationObj(self, name=None): | |
462 |
|
465 | |||
463 | for opConfObj in self.opConfObjList: |
|
466 | for opConfObj in self.opConfObjList: | |
464 |
|
467 | |||
465 | if opConfObj.name != name: |
|
468 | if opConfObj.name != name: | |
466 | continue |
|
469 | continue | |
467 |
|
470 | |||
468 | return opConfObj |
|
471 | return opConfObj | |
469 |
|
472 | |||
470 | return None |
|
473 | return None | |
471 |
|
474 | |||
472 | def getOpObjfromParamValue(self, value=None): |
|
475 | def getOpObjfromParamValue(self, value=None): | |
473 |
|
476 | |||
474 | for opConfObj in self.opConfObjList: |
|
477 | for opConfObj in self.opConfObjList: | |
475 | if opConfObj.getParameterObjfromValue(parameterValue=value) != value: |
|
478 | if opConfObj.getParameterObjfromValue(parameterValue=value) != value: | |
476 | continue |
|
479 | continue | |
477 | return opConfObj |
|
480 | return opConfObj | |
478 | return None |
|
481 | return None | |
479 |
|
482 | |||
480 | def getProcUnitObj(self): |
|
483 | def getProcUnitObj(self): | |
481 |
|
484 | |||
482 | return self.procUnitObj |
|
485 | return self.procUnitObj | |
483 |
|
486 | |||
484 | def setup(self, id, name, datatype, inputId, parentId=None): |
|
487 | def setup(self, id, name, datatype, inputId, parentId=None): | |
485 |
|
488 | |||
486 | #Compatible with old signal chain version |
|
489 | #Compatible with old signal chain version | |
487 | if datatype==None and name==None: |
|
490 | if datatype==None and name==None: | |
488 | raise ValueError, "datatype or name should be defined" |
|
491 | raise ValueError, "datatype or name should be defined" | |
489 |
|
492 | |||
490 | if name==None: |
|
493 | if name==None: | |
491 | if 'Proc' in datatype: |
|
494 | if 'Proc' in datatype: | |
492 | name = datatype |
|
495 | name = datatype | |
493 | else: |
|
496 | else: | |
494 | name = '%sProc' %(datatype) |
|
497 | name = '%sProc' %(datatype) | |
495 |
|
498 | |||
496 | if datatype==None: |
|
499 | if datatype==None: | |
497 | datatype = name.replace('Proc','') |
|
500 | datatype = name.replace('Proc','') | |
498 |
|
501 | |||
499 | self.id = str(id) |
|
502 | self.id = str(id) | |
500 | self.name = name |
|
503 | self.name = name | |
501 | self.datatype = datatype |
|
504 | self.datatype = datatype | |
502 | self.inputId = inputId |
|
505 | self.inputId = inputId | |
503 | self.parentId = parentId |
|
506 | self.parentId = parentId | |
504 |
|
507 | |||
505 | self.opConfObjList = [] |
|
508 | self.opConfObjList = [] | |
506 |
|
509 | |||
507 | self.addOperation(name='run', optype='self') |
|
510 | self.addOperation(name='run', optype='self') | |
508 |
|
511 | |||
509 | def removeOperations(self): |
|
512 | def removeOperations(self): | |
510 |
|
513 | |||
511 | for obj in self.opConfObjList: |
|
514 | for obj in self.opConfObjList: | |
512 | del obj |
|
515 | del obj | |
513 |
|
516 | |||
514 | self.opConfObjList = [] |
|
517 | self.opConfObjList = [] | |
515 | self.addOperation(name='run') |
|
518 | self.addOperation(name='run') | |
516 |
|
519 | |||
517 | def addParameter(self, **kwargs): |
|
520 | def addParameter(self, **kwargs): | |
518 | ''' |
|
521 | ''' | |
519 | Add parameters to "run" operation |
|
522 | Add parameters to "run" operation | |
520 | ''' |
|
523 | ''' | |
521 | opObj = self.opConfObjList[0] |
|
524 | opObj = self.opConfObjList[0] | |
522 |
|
525 | |||
523 | opObj.addParameter(**kwargs) |
|
526 | opObj.addParameter(**kwargs) | |
524 |
|
527 | |||
525 | return opObj |
|
528 | return opObj | |
526 |
|
529 | |||
527 | def addOperation(self, name, optype='self'): |
|
530 | def addOperation(self, name, optype='self'): | |
528 |
|
531 | |||
529 | id = self.__getNewId() |
|
532 | id = self.__getNewId() | |
530 | priority = self.__getPriority() |
|
533 | priority = self.__getPriority() | |
531 |
|
534 | |||
532 | opConfObj = OperationConf() |
|
535 | opConfObj = OperationConf() | |
533 | opConfObj.setup(id, name=name, priority=priority, type=optype) |
|
536 | opConfObj.setup(id, name=name, priority=priority, type=optype) | |
534 |
|
537 | |||
535 | self.opConfObjList.append(opConfObj) |
|
538 | self.opConfObjList.append(opConfObj) | |
536 |
|
539 | |||
537 | return opConfObj |
|
540 | return opConfObj | |
538 |
|
541 | |||
539 | def makeXml(self, procUnitElement): |
|
542 | def makeXml(self, procUnitElement): | |
540 |
|
543 | |||
541 | upElement = SubElement(procUnitElement, self.ELEMENTNAME) |
|
544 | upElement = SubElement(procUnitElement, self.ELEMENTNAME) | |
542 | upElement.set('id', str(self.id)) |
|
545 | upElement.set('id', str(self.id)) | |
543 | upElement.set('name', self.name) |
|
546 | upElement.set('name', self.name) | |
544 | upElement.set('datatype', self.datatype) |
|
547 | upElement.set('datatype', self.datatype) | |
545 | upElement.set('inputId', str(self.inputId)) |
|
548 | upElement.set('inputId', str(self.inputId)) | |
546 |
|
549 | |||
547 | for opConfObj in self.opConfObjList: |
|
550 | for opConfObj in self.opConfObjList: | |
548 | opConfObj.makeXml(upElement) |
|
551 | opConfObj.makeXml(upElement) | |
549 |
|
552 | |||
550 | def readXml(self, upElement): |
|
553 | def readXml(self, upElement): | |
551 |
|
554 | |||
552 | self.id = upElement.get('id') |
|
555 | self.id = upElement.get('id') | |
553 | self.name = upElement.get('name') |
|
556 | self.name = upElement.get('name') | |
554 | self.datatype = upElement.get('datatype') |
|
557 | self.datatype = upElement.get('datatype') | |
555 | self.inputId = upElement.get('inputId') |
|
558 | self.inputId = upElement.get('inputId') | |
556 |
|
559 | |||
557 | if self.ELEMENTNAME == "ReadUnit": |
|
560 | if self.ELEMENTNAME == "ReadUnit": | |
558 | self.datatype = self.datatype.replace("Reader", "") |
|
561 | self.datatype = self.datatype.replace("Reader", "") | |
559 |
|
562 | |||
560 | if self.ELEMENTNAME == "ProcUnit": |
|
563 | if self.ELEMENTNAME == "ProcUnit": | |
561 | self.datatype = self.datatype.replace("Proc", "") |
|
564 | self.datatype = self.datatype.replace("Proc", "") | |
562 |
|
565 | |||
563 | if self.inputId == 'None': |
|
566 | if self.inputId == 'None': | |
564 | self.inputId = '0' |
|
567 | self.inputId = '0' | |
565 |
|
568 | |||
566 | self.opConfObjList = [] |
|
569 | self.opConfObjList = [] | |
567 |
|
570 | |||
568 | opElementList = upElement.getiterator(OperationConf().getElementName()) |
|
571 | opElementList = upElement.getiterator(OperationConf().getElementName()) | |
569 |
|
572 | |||
570 | for opElement in opElementList: |
|
573 | for opElement in opElementList: | |
571 | opConfObj = OperationConf() |
|
574 | opConfObj = OperationConf() | |
572 | opConfObj.readXml(opElement) |
|
575 | opConfObj.readXml(opElement) | |
573 | self.opConfObjList.append(opConfObj) |
|
576 | self.opConfObjList.append(opConfObj) | |
574 |
|
577 | |||
575 | def printattr(self): |
|
578 | def printattr(self): | |
576 |
|
579 | |||
577 | print "%s[%s]: name = %s, datatype = %s, inputId = %s" %(self.ELEMENTNAME, |
|
580 | print "%s[%s]: name = %s, datatype = %s, inputId = %s" %(self.ELEMENTNAME, | |
578 | self.id, |
|
581 | self.id, | |
579 | self.name, |
|
582 | self.name, | |
580 | self.datatype, |
|
583 | self.datatype, | |
581 | self.inputId) |
|
584 | self.inputId) | |
582 |
|
585 | |||
583 | for opConfObj in self.opConfObjList: |
|
586 | for opConfObj in self.opConfObjList: | |
584 | opConfObj.printattr() |
|
587 | opConfObj.printattr() | |
585 |
|
588 | |||
586 | def createObjects(self): |
|
589 | def createObjects(self): | |
587 |
|
590 | |||
588 | className = eval(self.name) |
|
591 | className = eval(self.name) | |
589 | procUnitObj = className() |
|
592 | procUnitObj = className() | |
590 |
|
593 | |||
591 | for opConfObj in self.opConfObjList: |
|
594 | for opConfObj in self.opConfObjList: | |
592 |
|
595 | |||
593 | if opConfObj.type == 'self': |
|
596 | if opConfObj.type == 'self': | |
594 | continue |
|
597 | continue | |
595 |
|
598 | |||
596 | opObj = opConfObj.createObject() |
|
599 | opObj = opConfObj.createObject() | |
597 |
|
600 | |||
598 | self.opObjDict[opConfObj.id] = opObj |
|
601 | self.opObjDict[opConfObj.id] = opObj | |
599 | procUnitObj.addOperation(opObj, opConfObj.id) |
|
602 | procUnitObj.addOperation(opObj, opConfObj.id) | |
600 |
|
603 | |||
601 | self.procUnitObj = procUnitObj |
|
604 | self.procUnitObj = procUnitObj | |
602 |
|
605 | |||
603 | return procUnitObj |
|
606 | return procUnitObj | |
604 |
|
607 | |||
605 | def run(self): |
|
608 | def run(self): | |
606 |
|
609 | |||
607 | is_ok = False |
|
610 | is_ok = False | |
608 |
|
611 | |||
609 | for opConfObj in self.opConfObjList: |
|
612 | for opConfObj in self.opConfObjList: | |
610 |
|
613 | |||
611 | kwargs = {} |
|
614 | kwargs = {} | |
612 | for parmConfObj in opConfObj.getParameterObjList(): |
|
615 | for parmConfObj in opConfObj.getParameterObjList(): | |
613 | if opConfObj.name == 'run' and parmConfObj.name == 'datatype': |
|
616 | if opConfObj.name == 'run' and parmConfObj.name == 'datatype': | |
614 | continue |
|
617 | continue | |
615 |
|
618 | |||
616 | kwargs[parmConfObj.name] = parmConfObj.getValue() |
|
619 | kwargs[parmConfObj.name] = parmConfObj.getValue() | |
617 |
|
620 | |||
618 | #print "\tRunning the '%s' operation with %s" %(opConfObj.name, opConfObj.id) |
|
621 | #print "\tRunning the '%s' operation with %s" %(opConfObj.name, opConfObj.id) | |
619 | sts = self.procUnitObj.call(opType = opConfObj.type, |
|
622 | sts = self.procUnitObj.call(opType = opConfObj.type, | |
620 | opName = opConfObj.name, |
|
623 | opName = opConfObj.name, | |
621 | opId = opConfObj.id, |
|
624 | opId = opConfObj.id, | |
622 | **kwargs) |
|
625 | **kwargs) | |
623 | is_ok = is_ok or sts |
|
626 | is_ok = is_ok or sts | |
624 |
|
627 | |||
625 | return is_ok |
|
628 | return is_ok | |
626 |
|
629 | |||
627 | def close(self): |
|
630 | def close(self): | |
628 |
|
631 | |||
629 | for opConfObj in self.opConfObjList: |
|
632 | for opConfObj in self.opConfObjList: | |
630 | if opConfObj.type == 'self': |
|
633 | if opConfObj.type == 'self': | |
631 | continue |
|
634 | continue | |
632 |
|
635 | |||
633 | opObj = self.procUnitObj.getOperationObj(opConfObj.id) |
|
636 | opObj = self.procUnitObj.getOperationObj(opConfObj.id) | |
634 | opObj.close() |
|
637 | opObj.close() | |
635 |
|
638 | |||
636 | self.procUnitObj.close() |
|
639 | self.procUnitObj.close() | |
637 |
|
640 | |||
638 | return |
|
641 | return | |
639 |
|
642 | |||
640 | class ReadUnitConf(ProcUnitConf): |
|
643 | class ReadUnitConf(ProcUnitConf): | |
641 |
|
644 | |||
642 | path = None |
|
645 | path = None | |
643 | startDate = None |
|
646 | startDate = None | |
644 | endDate = None |
|
647 | endDate = None | |
645 | startTime = None |
|
648 | startTime = None | |
646 | endTime = None |
|
649 | endTime = None | |
647 |
|
650 | |||
648 | ELEMENTNAME = 'ReadUnit' |
|
651 | ELEMENTNAME = 'ReadUnit' | |
649 |
|
652 | |||
650 | def __init__(self): |
|
653 | def __init__(self): | |
651 |
|
654 | |||
652 | self.id = None |
|
655 | self.id = None | |
653 | self.datatype = None |
|
656 | self.datatype = None | |
654 | self.name = None |
|
657 | self.name = None | |
655 | self.inputId = None |
|
658 | self.inputId = None | |
656 |
|
659 | |||
657 | self.parentId = None |
|
660 | self.parentId = None | |
658 |
|
661 | |||
659 | self.opConfObjList = [] |
|
662 | self.opConfObjList = [] | |
660 | self.opObjList = [] |
|
663 | self.opObjList = [] | |
661 |
|
664 | |||
662 | def getElementName(self): |
|
665 | def getElementName(self): | |
663 |
|
666 | |||
664 | return self.ELEMENTNAME |
|
667 | return self.ELEMENTNAME | |
665 |
|
668 | |||
666 | def setup(self, id, name, datatype, path, startDate="", endDate="", startTime="", endTime="", parentId=None, **kwargs): |
|
669 | def setup(self, id, name, datatype, path, startDate="", endDate="", startTime="", endTime="", parentId=None, **kwargs): | |
667 |
|
670 | |||
668 | #Compatible with old signal chain version |
|
671 | #Compatible with old signal chain version | |
669 | if datatype==None and name==None: |
|
672 | if datatype==None and name==None: | |
670 | raise ValueError, "datatype or name should be defined" |
|
673 | raise ValueError, "datatype or name should be defined" | |
671 |
|
674 | |||
672 | if name==None: |
|
675 | if name==None: | |
673 | if 'Reader' in datatype: |
|
676 | if 'Reader' in datatype: | |
674 | name = datatype |
|
677 | name = datatype | |
675 | else: |
|
678 | else: | |
676 | name = '%sReader' %(datatype) |
|
679 | name = '%sReader' %(datatype) | |
677 |
|
680 | |||
678 | if datatype==None: |
|
681 | if datatype==None: | |
679 | datatype = name.replace('Reader','') |
|
682 | datatype = name.replace('Reader','') | |
680 |
|
683 | |||
681 | self.id = id |
|
684 | self.id = id | |
682 | self.name = name |
|
685 | self.name = name | |
683 | self.datatype = datatype |
|
686 | self.datatype = datatype | |
684 |
|
687 | |||
685 | self.path = path |
|
688 | self.path = path | |
686 | self.startDate = startDate |
|
689 | self.startDate = startDate | |
687 | self.endDate = endDate |
|
690 | self.endDate = endDate | |
688 | self.startTime = startTime |
|
691 | self.startTime = startTime | |
689 | self.endTime = endTime |
|
692 | self.endTime = endTime | |
690 |
|
693 | |||
691 | self.inputId = '0' |
|
694 | self.inputId = '0' | |
692 | self.parentId = parentId |
|
695 | self.parentId = parentId | |
693 |
|
696 | |||
694 | self.addRunOperation(**kwargs) |
|
697 | self.addRunOperation(**kwargs) | |
695 |
|
698 | |||
696 | def update(self, datatype, path, startDate, endDate, startTime, endTime, parentId=None, name=None, **kwargs): |
|
699 | def update(self, datatype, path, startDate, endDate, startTime, endTime, parentId=None, name=None, **kwargs): | |
697 |
|
700 | |||
698 | #Compatible with old signal chain version |
|
701 | #Compatible with old signal chain version | |
699 | if datatype==None and name==None: |
|
702 | if datatype==None and name==None: | |
700 | raise ValueError, "datatype or name should be defined" |
|
703 | raise ValueError, "datatype or name should be defined" | |
701 |
|
704 | |||
702 | if name==None: |
|
705 | if name==None: | |
703 | if 'Reader' in datatype: |
|
706 | if 'Reader' in datatype: | |
704 | name = datatype |
|
707 | name = datatype | |
705 | else: |
|
708 | else: | |
706 | name = '%sReader' %(datatype) |
|
709 | name = '%sReader' %(datatype) | |
707 |
|
710 | |||
708 | if datatype==None: |
|
711 | if datatype==None: | |
709 | datatype = name.replace('Reader','') |
|
712 | datatype = name.replace('Reader','') | |
710 |
|
713 | |||
711 | self.datatype = datatype |
|
714 | self.datatype = datatype | |
712 | self.name = name |
|
715 | self.name = name | |
713 | self.path = path |
|
716 | self.path = path | |
714 | self.startDate = startDate |
|
717 | self.startDate = startDate | |
715 | self.endDate = endDate |
|
718 | self.endDate = endDate | |
716 | self.startTime = startTime |
|
719 | self.startTime = startTime | |
717 | self.endTime = endTime |
|
720 | self.endTime = endTime | |
718 |
|
721 | |||
719 | self.inputId = '0' |
|
722 | self.inputId = '0' | |
720 | self.parentId = parentId |
|
723 | self.parentId = parentId | |
721 |
|
724 | |||
722 | self.updateRunOperation(**kwargs) |
|
725 | self.updateRunOperation(**kwargs) | |
723 |
|
726 | |||
724 | def addRunOperation(self, **kwargs): |
|
727 | def addRunOperation(self, **kwargs): | |
725 |
|
728 | |||
726 | opObj = self.addOperation(name = 'run', optype = 'self') |
|
729 | opObj = self.addOperation(name = 'run', optype = 'self') | |
727 |
|
730 | |||
728 | opObj.addParameter(name='datatype' , value=self.datatype, format='str') |
|
731 | opObj.addParameter(name='datatype' , value=self.datatype, format='str') | |
729 | opObj.addParameter(name='path' , value=self.path, format='str') |
|
732 | opObj.addParameter(name='path' , value=self.path, format='str') | |
730 | opObj.addParameter(name='startDate' , value=self.startDate, format='date') |
|
733 | opObj.addParameter(name='startDate' , value=self.startDate, format='date') | |
731 | opObj.addParameter(name='endDate' , value=self.endDate, format='date') |
|
734 | opObj.addParameter(name='endDate' , value=self.endDate, format='date') | |
732 | opObj.addParameter(name='startTime' , value=self.startTime, format='time') |
|
735 | opObj.addParameter(name='startTime' , value=self.startTime, format='time') | |
733 | opObj.addParameter(name='endTime' , value=self.endTime, format='time') |
|
736 | opObj.addParameter(name='endTime' , value=self.endTime, format='time') | |
734 |
|
737 | |||
735 | for key, value in kwargs.items(): |
|
738 | for key, value in kwargs.items(): | |
736 | opObj.addParameter(name=key, value=value, format=type(value).__name__) |
|
739 | opObj.addParameter(name=key, value=value, format=type(value).__name__) | |
737 |
|
740 | |||
738 | return opObj |
|
741 | return opObj | |
739 |
|
742 | |||
740 | def updateRunOperation(self, **kwargs): |
|
743 | def updateRunOperation(self, **kwargs): | |
741 |
|
744 | |||
742 | opObj = self.getOperationObj(name = 'run') |
|
745 | opObj = self.getOperationObj(name = 'run') | |
743 | opObj.removeParameters() |
|
746 | opObj.removeParameters() | |
744 |
|
747 | |||
745 | opObj.addParameter(name='datatype' , value=self.datatype, format='str') |
|
748 | opObj.addParameter(name='datatype' , value=self.datatype, format='str') | |
746 | opObj.addParameter(name='path' , value=self.path, format='str') |
|
749 | opObj.addParameter(name='path' , value=self.path, format='str') | |
747 | opObj.addParameter(name='startDate' , value=self.startDate, format='date') |
|
750 | opObj.addParameter(name='startDate' , value=self.startDate, format='date') | |
748 | opObj.addParameter(name='endDate' , value=self.endDate, format='date') |
|
751 | opObj.addParameter(name='endDate' , value=self.endDate, format='date') | |
749 | opObj.addParameter(name='startTime' , value=self.startTime, format='time') |
|
752 | opObj.addParameter(name='startTime' , value=self.startTime, format='time') | |
750 | opObj.addParameter(name='endTime' , value=self.endTime, format='time') |
|
753 | opObj.addParameter(name='endTime' , value=self.endTime, format='time') | |
751 |
|
754 | |||
752 | for key, value in kwargs.items(): |
|
755 | for key, value in kwargs.items(): | |
753 | opObj.addParameter(name=key, value=value, format=type(value).__name__) |
|
756 | opObj.addParameter(name=key, value=value, format=type(value).__name__) | |
754 |
|
757 | |||
755 | return opObj |
|
758 | return opObj | |
756 |
|
759 | |||
757 | class Project(): |
|
760 | class Project(): | |
758 |
|
761 | |||
759 | id = None |
|
762 | id = None | |
760 | name = None |
|
763 | name = None | |
761 | description = None |
|
764 | description = None | |
762 | # readUnitConfObjList = None |
|
765 | # readUnitConfObjList = None | |
763 | procUnitConfObjDict = None |
|
766 | procUnitConfObjDict = None | |
764 |
|
767 | |||
765 | ELEMENTNAME = 'Project' |
|
768 | ELEMENTNAME = 'Project' | |
766 |
|
769 | |||
767 | def __init__(self): |
|
770 | def __init__(self): | |
768 |
|
771 | |||
769 | self.id = None |
|
772 | self.id = None | |
770 | self.name = None |
|
773 | self.name = None | |
771 | self.description = None |
|
774 | self.description = None | |
772 |
|
775 | |||
773 | self.procUnitConfObjDict = {} |
|
776 | self.procUnitConfObjDict = {} | |
774 |
|
777 | |||
775 | def __getNewId(self): |
|
778 | def __getNewId(self): | |
776 |
|
779 | |||
777 | id = int(self.id)*10 + len(self.procUnitConfObjDict) + 1 |
|
780 | id = int(self.id)*10 + len(self.procUnitConfObjDict) + 1 | |
778 |
|
781 | |||
779 | return str(id) |
|
782 | return str(id) | |
780 |
|
783 | |||
781 | def getElementName(self): |
|
784 | def getElementName(self): | |
782 |
|
785 | |||
783 | return self.ELEMENTNAME |
|
786 | return self.ELEMENTNAME | |
784 |
|
787 | |||
785 | def getId(self): |
|
788 | def getId(self): | |
786 |
|
789 | |||
787 | return self.id |
|
790 | return self.id | |
788 |
|
791 | |||
789 | def updateId(self, new_id): |
|
792 | def updateId(self, new_id): | |
790 |
|
793 | |||
791 | self.id = str(new_id) |
|
794 | self.id = str(new_id) | |
792 |
|
795 | |||
793 | keyList = self.procUnitConfObjDict.keys() |
|
796 | keyList = self.procUnitConfObjDict.keys() | |
794 | keyList.sort() |
|
797 | keyList.sort() | |
795 |
|
798 | |||
796 | n = 1 |
|
799 | n = 1 | |
797 | newProcUnitConfObjDict = {} |
|
800 | newProcUnitConfObjDict = {} | |
798 |
|
801 | |||
799 | for procKey in keyList: |
|
802 | for procKey in keyList: | |
800 |
|
803 | |||
801 | procUnitConfObj = self.procUnitConfObjDict[procKey] |
|
804 | procUnitConfObj = self.procUnitConfObjDict[procKey] | |
802 | idProcUnit = str(int(self.id)*10 + n) |
|
805 | idProcUnit = str(int(self.id)*10 + n) | |
803 | procUnitConfObj.updateId(idProcUnit, parentId = self.id) |
|
806 | procUnitConfObj.updateId(idProcUnit, parentId = self.id) | |
804 |
|
807 | |||
805 | newProcUnitConfObjDict[idProcUnit] = procUnitConfObj |
|
808 | newProcUnitConfObjDict[idProcUnit] = procUnitConfObj | |
806 | n += 1 |
|
809 | n += 1 | |
807 |
|
810 | |||
808 | self.procUnitConfObjDict = newProcUnitConfObjDict |
|
811 | self.procUnitConfObjDict = newProcUnitConfObjDict | |
809 |
|
812 | |||
810 | def setup(self, id, name, description): |
|
813 | def setup(self, id, name, description): | |
811 |
|
814 | |||
812 | self.id = str(id) |
|
815 | self.id = str(id) | |
813 | self.name = name |
|
816 | self.name = name | |
814 | self.description = description |
|
817 | self.description = description | |
815 |
|
818 | |||
816 | def update(self, name, description): |
|
819 | def update(self, name, description): | |
817 |
|
820 | |||
818 | self.name = name |
|
821 | self.name = name | |
819 | self.description = description |
|
822 | self.description = description | |
820 |
|
823 | |||
821 | def addReadUnit(self, datatype=None, name=None, **kwargs): |
|
824 | def addReadUnit(self, datatype=None, name=None, **kwargs): | |
822 |
|
825 | |||
823 | idReadUnit = self.__getNewId() |
|
826 | idReadUnit = self.__getNewId() | |
824 |
|
827 | |||
825 | readUnitConfObj = ReadUnitConf() |
|
828 | readUnitConfObj = ReadUnitConf() | |
826 | readUnitConfObj.setup(idReadUnit, name, datatype, parentId=self.id, **kwargs) |
|
829 | readUnitConfObj.setup(idReadUnit, name, datatype, parentId=self.id, **kwargs) | |
827 |
|
830 | |||
828 | self.procUnitConfObjDict[readUnitConfObj.getId()] = readUnitConfObj |
|
831 | self.procUnitConfObjDict[readUnitConfObj.getId()] = readUnitConfObj | |
829 |
|
832 | |||
830 | return readUnitConfObj |
|
833 | return readUnitConfObj | |
831 |
|
834 | |||
832 | def addProcUnit(self, inputId='0', datatype=None, name=None): |
|
835 | def addProcUnit(self, inputId='0', datatype=None, name=None): | |
833 |
|
836 | |||
834 | idProcUnit = self.__getNewId() |
|
837 | idProcUnit = self.__getNewId() | |
835 |
|
838 | |||
836 | procUnitConfObj = ProcUnitConf() |
|
839 | procUnitConfObj = ProcUnitConf() | |
837 | procUnitConfObj.setup(idProcUnit, name, datatype, inputId, parentId=self.id) |
|
840 | procUnitConfObj.setup(idProcUnit, name, datatype, inputId, parentId=self.id) | |
838 |
|
841 | |||
839 | self.procUnitConfObjDict[procUnitConfObj.getId()] = procUnitConfObj |
|
842 | self.procUnitConfObjDict[procUnitConfObj.getId()] = procUnitConfObj | |
840 |
|
843 | |||
841 | return procUnitConfObj |
|
844 | return procUnitConfObj | |
842 |
|
845 | |||
843 | def removeProcUnit(self, id): |
|
846 | def removeProcUnit(self, id): | |
844 |
|
847 | |||
845 | if id in self.procUnitConfObjDict.keys(): |
|
848 | if id in self.procUnitConfObjDict.keys(): | |
846 | self.procUnitConfObjDict.pop(id) |
|
849 | self.procUnitConfObjDict.pop(id) | |
847 |
|
850 | |||
848 | def getReadUnitId(self): |
|
851 | def getReadUnitId(self): | |
849 |
|
852 | |||
850 | readUnitConfObj = self.getReadUnitObj() |
|
853 | readUnitConfObj = self.getReadUnitObj() | |
851 |
|
854 | |||
852 | return readUnitConfObj.id |
|
855 | return readUnitConfObj.id | |
853 |
|
856 | |||
854 | def getReadUnitObj(self): |
|
857 | def getReadUnitObj(self): | |
855 |
|
858 | |||
856 | for obj in self.procUnitConfObjDict.values(): |
|
859 | for obj in self.procUnitConfObjDict.values(): | |
857 | if obj.getElementName() == "ReadUnit": |
|
860 | if obj.getElementName() == "ReadUnit": | |
858 | return obj |
|
861 | return obj | |
859 |
|
862 | |||
860 | return None |
|
863 | return None | |
861 |
|
864 | |||
862 | def getProcUnitObj(self, id=None, name=None): |
|
865 | def getProcUnitObj(self, id=None, name=None): | |
863 |
|
866 | |||
864 | if id != None: |
|
867 | if id != None: | |
865 | return self.procUnitConfObjDict[id] |
|
868 | return self.procUnitConfObjDict[id] | |
866 |
|
869 | |||
867 | if name != None: |
|
870 | if name != None: | |
868 | return self.getProcUnitObjByName(name) |
|
871 | return self.getProcUnitObjByName(name) | |
869 |
|
872 | |||
870 | return None |
|
873 | return None | |
871 |
|
874 | |||
872 | def getProcUnitObjByName(self, name): |
|
875 | def getProcUnitObjByName(self, name): | |
873 |
|
876 | |||
874 | for obj in self.procUnitConfObjDict.values(): |
|
877 | for obj in self.procUnitConfObjDict.values(): | |
875 | if obj.name == name: |
|
878 | if obj.name == name: | |
876 | return obj |
|
879 | return obj | |
877 |
|
880 | |||
878 | return None |
|
881 | return None | |
879 |
|
882 | |||
880 | def procUnitItems(self): |
|
883 | def procUnitItems(self): | |
881 |
|
884 | |||
882 | return self.procUnitConfObjDict.items() |
|
885 | return self.procUnitConfObjDict.items() | |
883 |
|
886 | |||
884 | def makeXml(self): |
|
887 | def makeXml(self): | |
885 |
|
888 | |||
886 | projectElement = Element('Project') |
|
889 | projectElement = Element('Project') | |
887 | projectElement.set('id', str(self.id)) |
|
890 | projectElement.set('id', str(self.id)) | |
888 | projectElement.set('name', self.name) |
|
891 | projectElement.set('name', self.name) | |
889 | projectElement.set('description', self.description) |
|
892 | projectElement.set('description', self.description) | |
890 |
|
893 | |||
891 | for procUnitConfObj in self.procUnitConfObjDict.values(): |
|
894 | for procUnitConfObj in self.procUnitConfObjDict.values(): | |
892 | procUnitConfObj.makeXml(projectElement) |
|
895 | procUnitConfObj.makeXml(projectElement) | |
893 |
|
896 | |||
894 | self.projectElement = projectElement |
|
897 | self.projectElement = projectElement | |
895 |
|
898 | |||
896 | def writeXml(self, filename): |
|
899 | def writeXml(self, filename): | |
897 |
|
900 | |||
898 | self.makeXml() |
|
901 | self.makeXml() | |
899 |
|
902 | |||
900 | #print prettify(self.projectElement) |
|
903 | #print prettify(self.projectElement) | |
901 |
|
904 | |||
902 | ElementTree(self.projectElement).write(filename, method='xml') |
|
905 | ElementTree(self.projectElement).write(filename, method='xml') | |
903 |
|
906 | |||
904 | def readXml(self, filename): |
|
907 | def readXml(self, filename): | |
905 |
|
908 | |||
906 | self.projectElement = None |
|
909 | self.projectElement = None | |
907 | self.procUnitConfObjDict = {} |
|
910 | self.procUnitConfObjDict = {} | |
908 |
|
911 | |||
909 | self.projectElement = ElementTree().parse(filename) |
|
912 | self.projectElement = ElementTree().parse(filename) | |
910 |
|
913 | |||
911 | self.project = self.projectElement.tag |
|
914 | self.project = self.projectElement.tag | |
912 |
|
915 | |||
913 | self.id = self.projectElement.get('id') |
|
916 | self.id = self.projectElement.get('id') | |
914 | self.name = self.projectElement.get('name') |
|
917 | self.name = self.projectElement.get('name') | |
915 | self.description = self.projectElement.get('description') |
|
918 | self.description = self.projectElement.get('description') | |
916 |
|
919 | |||
917 | readUnitElementList = self.projectElement.getiterator(ReadUnitConf().getElementName()) |
|
920 | readUnitElementList = self.projectElement.getiterator(ReadUnitConf().getElementName()) | |
918 |
|
921 | |||
919 | for readUnitElement in readUnitElementList: |
|
922 | for readUnitElement in readUnitElementList: | |
920 | readUnitConfObj = ReadUnitConf() |
|
923 | readUnitConfObj = ReadUnitConf() | |
921 | readUnitConfObj.readXml(readUnitElement) |
|
924 | readUnitConfObj.readXml(readUnitElement) | |
922 |
|
925 | |||
923 | if readUnitConfObj.parentId == None: |
|
926 | if readUnitConfObj.parentId == None: | |
924 | readUnitConfObj.parentId = self.id |
|
927 | readUnitConfObj.parentId = self.id | |
925 |
|
928 | |||
926 | self.procUnitConfObjDict[readUnitConfObj.getId()] = readUnitConfObj |
|
929 | self.procUnitConfObjDict[readUnitConfObj.getId()] = readUnitConfObj | |
927 |
|
930 | |||
928 | procUnitElementList = self.projectElement.getiterator(ProcUnitConf().getElementName()) |
|
931 | procUnitElementList = self.projectElement.getiterator(ProcUnitConf().getElementName()) | |
929 |
|
932 | |||
930 | for procUnitElement in procUnitElementList: |
|
933 | for procUnitElement in procUnitElementList: | |
931 | procUnitConfObj = ProcUnitConf() |
|
934 | procUnitConfObj = ProcUnitConf() | |
932 | procUnitConfObj.readXml(procUnitElement) |
|
935 | procUnitConfObj.readXml(procUnitElement) | |
933 |
|
936 | |||
934 | if procUnitConfObj.parentId == None: |
|
937 | if procUnitConfObj.parentId == None: | |
935 | procUnitConfObj.parentId = self.id |
|
938 | procUnitConfObj.parentId = self.id | |
936 |
|
939 | |||
937 | self.procUnitConfObjDict[procUnitConfObj.getId()] = procUnitConfObj |
|
940 | self.procUnitConfObjDict[procUnitConfObj.getId()] = procUnitConfObj | |
938 |
|
941 | |||
939 | def printattr(self): |
|
942 | def printattr(self): | |
940 |
|
943 | |||
941 | print "Project[%s]: name = %s, description = %s" %(self.id, |
|
944 | print "Project[%s]: name = %s, description = %s" %(self.id, | |
942 | self.name, |
|
945 | self.name, | |
943 | self.description) |
|
946 | self.description) | |
944 |
|
947 | |||
945 | for procUnitConfObj in self.procUnitConfObjDict.values(): |
|
948 | for procUnitConfObj in self.procUnitConfObjDict.values(): | |
946 | procUnitConfObj.printattr() |
|
949 | procUnitConfObj.printattr() | |
947 |
|
950 | |||
948 | def createObjects(self): |
|
951 | def createObjects(self): | |
949 |
|
952 | |||
950 | for procUnitConfObj in self.procUnitConfObjDict.values(): |
|
953 | for procUnitConfObj in self.procUnitConfObjDict.values(): | |
951 | procUnitConfObj.createObjects() |
|
954 | procUnitConfObj.createObjects() | |
952 |
|
955 | |||
953 | def __connect(self, objIN, thisObj): |
|
956 | def __connect(self, objIN, thisObj): | |
954 |
|
957 | |||
955 | thisObj.setInput(objIN.getOutputObj()) |
|
958 | thisObj.setInput(objIN.getOutputObj()) | |
956 |
|
959 | |||
957 | def connectObjects(self): |
|
960 | def connectObjects(self): | |
958 |
|
961 | |||
959 | for thisPUConfObj in self.procUnitConfObjDict.values(): |
|
962 | for thisPUConfObj in self.procUnitConfObjDict.values(): | |
960 |
|
963 | |||
961 | inputId = thisPUConfObj.getInputId() |
|
964 | inputId = thisPUConfObj.getInputId() | |
962 |
|
965 | |||
963 | if int(inputId) == 0: |
|
966 | if int(inputId) == 0: | |
964 | continue |
|
967 | continue | |
965 |
|
968 | |||
966 | #Get input object |
|
969 | #Get input object | |
967 | puConfINObj = self.procUnitConfObjDict[inputId] |
|
970 | puConfINObj = self.procUnitConfObjDict[inputId] | |
968 | puObjIN = puConfINObj.getProcUnitObj() |
|
971 | puObjIN = puConfINObj.getProcUnitObj() | |
969 |
|
972 | |||
970 | #Get current object |
|
973 | #Get current object | |
971 | thisPUObj = thisPUConfObj.getProcUnitObj() |
|
974 | thisPUObj = thisPUConfObj.getProcUnitObj() | |
972 |
|
975 | |||
973 | self.__connect(puObjIN, thisPUObj) |
|
976 | self.__connect(puObjIN, thisPUObj) | |
974 |
|
977 | |||
975 | def isPaused(self): |
|
978 | def isPaused(self): | |
976 | return 0 |
|
979 | return 0 | |
977 |
|
980 | |||
978 | def isStopped(self): |
|
981 | def isStopped(self): | |
979 | return 0 |
|
982 | return 0 | |
980 |
|
983 | |||
981 | def runController(self): |
|
984 | def runController(self): | |
982 | """ |
|
985 | """ | |
983 | returns 0 when this process has been stopped, 1 otherwise |
|
986 | returns 0 when this process has been stopped, 1 otherwise | |
984 | """ |
|
987 | """ | |
985 |
|
988 | |||
986 | if self.isPaused(): |
|
989 | if self.isPaused(): | |
987 | print "Process suspended" |
|
990 | print "Process suspended" | |
988 |
|
991 | |||
989 | while True: |
|
992 | while True: | |
990 | sleep(0.1) |
|
993 | sleep(0.1) | |
991 |
|
994 | |||
992 | if not self.isPaused(): |
|
995 | if not self.isPaused(): | |
993 | break |
|
996 | break | |
994 |
|
997 | |||
995 | if self.isStopped(): |
|
998 | if self.isStopped(): | |
996 | break |
|
999 | break | |
997 |
|
1000 | |||
998 | print "Process reinitialized" |
|
1001 | print "Process reinitialized" | |
999 |
|
1002 | |||
1000 | if self.isStopped(): |
|
1003 | if self.isStopped(): | |
1001 | print "Process stopped" |
|
1004 | print "Process stopped" | |
1002 | return 0 |
|
1005 | return 0 | |
1003 |
|
1006 | |||
1004 | return 1 |
|
1007 | return 1 | |
1005 |
|
1008 | |||
1006 | def run(self): |
|
1009 | def run(self): | |
1007 |
|
1010 | |||
1008 |
|
1011 | |||
1009 | print "*"*60 |
|
1012 | print "*"*60 | |
1010 | print " Starting SIGNAL CHAIN PROCESSING " |
|
1013 | print " Starting SIGNAL CHAIN PROCESSING " | |
1011 | print "*"*60 |
|
1014 | print "*"*60 | |
1012 |
|
1015 | |||
1013 |
|
1016 | |||
1014 | keyList = self.procUnitConfObjDict.keys() |
|
1017 | keyList = self.procUnitConfObjDict.keys() | |
1015 | keyList.sort() |
|
1018 | keyList.sort() | |
1016 |
|
1019 | |||
1017 | while(True): |
|
1020 | while(True): | |
1018 |
|
1021 | |||
1019 | is_ok = False |
|
1022 | is_ok = False | |
1020 |
|
1023 | |||
1021 | for procKey in keyList: |
|
1024 | for procKey in keyList: | |
1022 | # print "Running the '%s' process with %s" %(procUnitConfObj.name, procUnitConfObj.id) |
|
1025 | # print "Running the '%s' process with %s" %(procUnitConfObj.name, procUnitConfObj.id) | |
1023 |
|
1026 | |||
1024 | procUnitConfObj = self.procUnitConfObjDict[procKey] |
|
1027 | procUnitConfObj = self.procUnitConfObjDict[procKey] | |
1025 |
|
1028 | |||
1026 | message = "" |
|
1029 | message = "" | |
1027 | try: |
|
1030 | try: | |
1028 | sts = procUnitConfObj.run() |
|
1031 | sts = procUnitConfObj.run() | |
1029 | is_ok = is_ok or sts |
|
1032 | is_ok = is_ok or sts | |
1030 | except: |
|
1033 | except: | |
1031 | sleep(1) |
|
1034 | sleep(1) | |
1032 | err = traceback.format_exception(sys.exc_info()[0], |
|
1035 | err = traceback.format_exception(sys.exc_info()[0], | |
1033 | sys.exc_info()[1], |
|
1036 | sys.exc_info()[1], | |
1034 | sys.exc_info()[2]) |
|
1037 | sys.exc_info()[2]) | |
1035 |
|
1038 | |||
1036 | for thisLine in err: |
|
1039 | for thisLine in err: | |
1037 | message += thisLine |
|
1040 | message += thisLine | |
1038 |
|
1041 | |||
1039 | print message |
|
1042 | print message | |
1040 | # self.sendReport(message) |
|
1043 | # self.sendReport(message) | |
1041 | sleep(0.1) |
|
1044 | sleep(0.1) | |
1042 | is_ok = False |
|
1045 | is_ok = False | |
1043 |
|
1046 | |||
1044 | break |
|
1047 | break | |
1045 |
|
1048 | |||
1046 | #If every process unit finished so end process |
|
1049 | #If every process unit finished so end process | |
1047 | if not(is_ok): |
|
1050 | if not(is_ok): | |
1048 | print message |
|
1051 | print message | |
1049 | print "Every process unit have finished" |
|
1052 | print "Every process unit have finished" | |
1050 | break |
|
1053 | break | |
1051 |
|
1054 | |||
1052 | if not self.runController(): |
|
1055 | if not self.runController(): | |
1053 | break |
|
1056 | break | |
1054 |
|
1057 | |||
1055 | #Closing every process |
|
1058 | #Closing every process | |
1056 | for procKey in keyList: |
|
1059 | for procKey in keyList: | |
1057 | procUnitConfObj = self.procUnitConfObjDict[procKey] |
|
1060 | procUnitConfObj = self.procUnitConfObjDict[procKey] | |
1058 | procUnitConfObj.close() |
|
1061 | procUnitConfObj.close() | |
1059 |
|
1062 | |||
1060 | print "Process finished" |
|
1063 | print "Process finished" | |
1061 |
|
1064 | |||
1062 | def start(self, filename): |
|
1065 | def start(self, filename): | |
1063 |
|
1066 | |||
1064 | self.writeXml(filename) |
|
1067 | self.writeXml(filename) | |
1065 | self.readXml(filename) |
|
1068 | self.readXml(filename) | |
1066 |
|
1069 | |||
1067 | self.createObjects() |
|
1070 | self.createObjects() | |
1068 | self.connectObjects() |
|
1071 | self.connectObjects() | |
1069 | self.run() |
|
1072 | self.run() | |
1070 |
|
1073 | |||
1071 | def sendReport(self, message, subject="Error occurred in Signal Chain", email=SCHAIN_MAIL): |
|
1074 | def sendReport(self, message, subject="Error occurred in Signal Chain", email=SCHAIN_MAIL): | |
1072 |
|
1075 | |||
1073 | import smtplib |
|
1076 | import smtplib | |
1074 |
|
1077 | |||
1075 | print subject |
|
1078 | print subject | |
1076 | print "Sending report to %s ..." %email |
|
1079 | print "Sending report to %s ..." %email | |
1077 |
|
1080 | |||
1078 | message = 'From: (Python Signal Chain API) ' + email + '\n' + \ |
|
1081 | message = 'From: (Python Signal Chain API) ' + email + '\n' + \ | |
1079 | 'To: ' + email + '\n' + \ |
|
1082 | 'To: ' + email + '\n' + \ | |
1080 | 'Subject: ' + str(subject) + '\n' + \ |
|
1083 | 'Subject: ' + str(subject) + '\n' + \ | |
1081 | 'Content-type: text/html\n\n' + message |
|
1084 | 'Content-type: text/html\n\n' + message | |
1082 |
|
1085 | |||
1083 | server = smtplib.SMTP(EMAIL_SERVER) |
|
1086 | server = smtplib.SMTP(EMAIL_SERVER) | |
1084 | server.sendmail(email.split(',')[0], |
|
1087 | server.sendmail(email.split(',')[0], | |
1085 | email.split(','), message) |
|
1088 | email.split(','), message) | |
1086 | server.quit() |
|
1089 | server.quit() | |
1087 |
|
1090 | |||
1088 | if __name__ == '__main__': |
|
1091 | if __name__ == '__main__': | |
1089 |
|
1092 | |||
1090 | desc = "Segundo Test" |
|
1093 | desc = "Segundo Test" | |
1091 | filename = "schain.xml" |
|
1094 | filename = "schain.xml" | |
1092 |
|
1095 | |||
1093 | controllerObj = Project() |
|
1096 | controllerObj = Project() | |
1094 |
|
1097 | |||
1095 | controllerObj.setup(id = '191', name='test01', description=desc) |
|
1098 | controllerObj.setup(id = '191', name='test01', description=desc) | |
1096 |
|
1099 | |||
1097 | readUnitConfObj = controllerObj.addReadUnit(datatype='Voltage', |
|
1100 | readUnitConfObj = controllerObj.addReadUnit(datatype='Voltage', | |
1098 | path='data/rawdata/', |
|
1101 | path='data/rawdata/', | |
1099 | startDate='2011/01/01', |
|
1102 | startDate='2011/01/01', | |
1100 | endDate='2012/12/31', |
|
1103 | endDate='2012/12/31', | |
1101 | startTime='00:00:00', |
|
1104 | startTime='00:00:00', | |
1102 | endTime='23:59:59', |
|
1105 | endTime='23:59:59', | |
1103 | online=1, |
|
1106 | online=1, | |
1104 | walk=1) |
|
1107 | walk=1) | |
1105 |
|
1108 | |||
1106 | procUnitConfObj0 = controllerObj.addProcUnit(datatype='Voltage', inputId=readUnitConfObj.getId()) |
|
1109 | procUnitConfObj0 = controllerObj.addProcUnit(datatype='Voltage', inputId=readUnitConfObj.getId()) | |
1107 |
|
1110 | |||
1108 | opObj10 = procUnitConfObj0.addOperation(name='selectChannels') |
|
1111 | opObj10 = procUnitConfObj0.addOperation(name='selectChannels') | |
1109 | opObj10.addParameter(name='channelList', value='3,4,5', format='intlist') |
|
1112 | opObj10.addParameter(name='channelList', value='3,4,5', format='intlist') | |
1110 |
|
1113 | |||
1111 | opObj10 = procUnitConfObj0.addOperation(name='selectHeights') |
|
1114 | opObj10 = procUnitConfObj0.addOperation(name='selectHeights') | |
1112 | opObj10.addParameter(name='minHei', value='90', format='float') |
|
1115 | opObj10.addParameter(name='minHei', value='90', format='float') | |
1113 | opObj10.addParameter(name='maxHei', value='180', format='float') |
|
1116 | opObj10.addParameter(name='maxHei', value='180', format='float') | |
1114 |
|
1117 | |||
1115 | opObj12 = procUnitConfObj0.addOperation(name='CohInt', optype='external') |
|
1118 | opObj12 = procUnitConfObj0.addOperation(name='CohInt', optype='external') | |
1116 | opObj12.addParameter(name='n', value='10', format='int') |
|
1119 | opObj12.addParameter(name='n', value='10', format='int') | |
1117 |
|
1120 | |||
1118 | procUnitConfObj1 = controllerObj.addProcUnit(datatype='Spectra', inputId=procUnitConfObj0.getId()) |
|
1121 | procUnitConfObj1 = controllerObj.addProcUnit(datatype='Spectra', inputId=procUnitConfObj0.getId()) | |
1119 | procUnitConfObj1.addParameter(name='nFFTPoints', value='32', format='int') |
|
1122 | procUnitConfObj1.addParameter(name='nFFTPoints', value='32', format='int') | |
1120 | # procUnitConfObj1.addParameter(name='pairList', value='(0,1),(0,2),(1,2)', format='') |
|
1123 | # procUnitConfObj1.addParameter(name='pairList', value='(0,1),(0,2),(1,2)', format='') | |
1121 |
|
1124 | |||
1122 |
|
1125 | |||
1123 | opObj11 = procUnitConfObj1.addOperation(name='SpectraPlot', optype='external') |
|
1126 | opObj11 = procUnitConfObj1.addOperation(name='SpectraPlot', optype='external') | |
1124 | opObj11.addParameter(name='idfigure', value='1', format='int') |
|
1127 | opObj11.addParameter(name='idfigure', value='1', format='int') | |
1125 | opObj11.addParameter(name='wintitle', value='SpectraPlot0', format='str') |
|
1128 | opObj11.addParameter(name='wintitle', value='SpectraPlot0', format='str') | |
1126 | opObj11.addParameter(name='zmin', value='40', format='int') |
|
1129 | opObj11.addParameter(name='zmin', value='40', format='int') | |
1127 | opObj11.addParameter(name='zmax', value='90', format='int') |
|
1130 | opObj11.addParameter(name='zmax', value='90', format='int') | |
1128 | opObj11.addParameter(name='showprofile', value='1', format='int') |
|
1131 | opObj11.addParameter(name='showprofile', value='1', format='int') | |
1129 |
|
1132 | |||
1130 | print "Escribiendo el archivo XML" |
|
1133 | print "Escribiendo el archivo XML" | |
1131 |
|
1134 | |||
1132 | controllerObj.writeXml(filename) |
|
1135 | controllerObj.writeXml(filename) | |
1133 |
|
1136 | |||
1134 | print "Leyendo el archivo XML" |
|
1137 | print "Leyendo el archivo XML" | |
1135 | controllerObj.readXml(filename) |
|
1138 | controllerObj.readXml(filename) | |
1136 | #controllerObj.printattr() |
|
1139 | #controllerObj.printattr() | |
1137 |
|
1140 | |||
1138 | controllerObj.createObjects() |
|
1141 | controllerObj.createObjects() | |
1139 | controllerObj.connectObjects() |
|
1142 | controllerObj.connectObjects() | |
1140 | controllerObj.run() |
|
1143 | controllerObj.run() | |
1141 |
|
1144 | |||
1142 | No newline at end of file |
|
1145 |
1 | NO CONTENT: modified file |
|
NO CONTENT: modified file | ||
The requested commit or file is too big and content was truncated. Show full diff |
@@ -1,342 +1,342 | |||||
1 | # -*- coding: utf-8 -*- |
|
1 | # -*- coding: utf-8 -*- | |
2 |
|
2 | |||
3 | # Form implementation generated from reading ui file '/home/alex/ui/MainWindow_21_02_13_v49.ui' |
|
3 | # Form implementation generated from reading ui file '/home/alex/ui/MainWindow_21_02_13_v49.ui' | |
4 | # |
|
4 | # | |
5 | # Created: Mon Mar 24 13:28:36 2014 |
|
5 | # Created: Mon Mar 24 13:28:36 2014 | |
6 | # by: PyQt4 UI code generator 4.10 |
|
6 | # by: PyQt4 UI code generator 4.10 | |
7 | # |
|
7 | # | |
8 | # WARNING! All changes made in this file will be lost! |
|
8 | # WARNING! All changes made in this file will be lost! | |
9 |
|
9 | |||
10 | from PyQt4 import QtCore, QtGui |
|
10 | from PyQt4 import QtCore, QtGui | |
11 | from windows import * |
|
11 | from windows import * | |
12 |
|
12 | |||
13 | try: |
|
13 | try: | |
14 | _fromUtf8 = QtCore.QString.fromUtf8 |
|
14 | _fromUtf8 = QtCore.QString.fromUtf8 | |
15 | except AttributeError: |
|
15 | except AttributeError: | |
16 | def _fromUtf8(s): |
|
16 | def _fromUtf8(s): | |
17 | return s |
|
17 | return s | |
18 |
|
18 | |||
19 | try: |
|
19 | try: | |
20 | _encoding = QtGui.QApplication.UnicodeUTF8 |
|
20 | _encoding = QtGui.QApplication.UnicodeUTF8 | |
21 | def _translate(context, text, disambig): |
|
21 | def _translate(context, text, disambig): | |
22 | return QtGui.QApplication.translate(context, text, disambig, _encoding) |
|
22 | return QtGui.QApplication.translate(context, text, disambig, _encoding) | |
23 | except AttributeError: |
|
23 | except AttributeError: | |
24 | def _translate(context, text, disambig): |
|
24 | def _translate(context, text, disambig): | |
25 | return QtGui.QApplication.translate(context, text, disambig) |
|
25 | return QtGui.QApplication.translate(context, text, disambig) | |
26 |
|
26 | |||
27 | import os |
|
27 | import os | |
28 | from schainpy.gui.figures import tools |
|
28 | from schainpy.gui.figures import tools | |
29 | from schainpy import __version__ |
|
29 | from schainpy import __version__ | |
30 |
|
30 | |||
31 | FIGURES_PATH = tools.get_path() |
|
31 | FIGURES_PATH = tools.get_path() | |
32 |
|
32 | |||
33 | class Ui_EnvWindow(object): |
|
33 | class Ui_EnvWindow(object): | |
34 | paused = False |
|
34 | paused = False | |
35 |
|
35 | |||
36 | def restorePauseIcon(self): |
|
36 | def restorePauseIcon(self): | |
37 |
|
37 | |||
38 | icon_name = "pause.png" |
|
38 | icon_name = "pause.png" | |
39 | iconPause = QtGui.QIcon() |
|
39 | iconPause = QtGui.QIcon() | |
40 | iconPause.addPixmap(QtGui.QPixmap(_fromUtf8( os.path.join(FIGURES_PATH, icon_name) )), QtGui.QIcon.Normal, QtGui.QIcon.Off) |
|
40 | iconPause.addPixmap(QtGui.QPixmap(_fromUtf8( os.path.join(FIGURES_PATH, icon_name) )), QtGui.QIcon.Normal, QtGui.QIcon.Off) | |
41 | self.actionPauseToolbar.setIcon(iconPause) |
|
41 | self.actionPauseToolbar.setIcon(iconPause) | |
42 |
|
42 | |||
43 | def restoreStartIcon(self): |
|
43 | def restoreStartIcon(self): | |
44 |
|
44 | |||
45 | icon_name = "start.png" |
|
45 | icon_name = "start.png" | |
46 | iconStart = QtGui.QIcon() |
|
46 | iconStart = QtGui.QIcon() | |
47 | iconStart.addPixmap(QtGui.QPixmap(_fromUtf8( os.path.join(FIGURES_PATH, icon_name) )), QtGui.QIcon.Normal, QtGui.QIcon.Off) |
|
47 | iconStart.addPixmap(QtGui.QPixmap(_fromUtf8( os.path.join(FIGURES_PATH, icon_name) )), QtGui.QIcon.Normal, QtGui.QIcon.Off) | |
48 | self.actionStarToolbar.setIcon(iconStart) |
|
48 | self.actionStarToolbar.setIcon(iconStart) | |
49 |
|
49 | |||
50 | def changePauseIcon(self, paused=False): |
|
50 | def changePauseIcon(self, paused=False): | |
51 |
|
51 | |||
52 | if paused == True: |
|
52 | if paused == True: | |
53 | icon_name = "pausered.png" |
|
53 | icon_name = "pausered.png" | |
54 | else: |
|
54 | else: | |
55 | icon_name = "pause.png" |
|
55 | icon_name = "pause.png" | |
56 |
|
56 | |||
57 | iconPause = QtGui.QIcon() |
|
57 | iconPause = QtGui.QIcon() | |
58 | iconPause.addPixmap(QtGui.QPixmap(_fromUtf8( os.path.join(FIGURES_PATH, icon_name) )), QtGui.QIcon.Normal, QtGui.QIcon.Off) |
|
58 | iconPause.addPixmap(QtGui.QPixmap(_fromUtf8( os.path.join(FIGURES_PATH, icon_name) )), QtGui.QIcon.Normal, QtGui.QIcon.Off) | |
59 | self.actionPauseToolbar.setIcon(iconPause) |
|
59 | self.actionPauseToolbar.setIcon(iconPause) | |
60 |
|
60 | |||
61 | return |
|
61 | return | |
62 |
|
62 | |||
63 | def changeStartIcon(self, started=False): |
|
63 | def changeStartIcon(self, started=False): | |
64 |
|
64 | |||
65 | if started == True: |
|
65 | if started == True: | |
66 | icon_name = "startred.png" |
|
66 | icon_name = "startred.png" | |
67 | else: |
|
67 | else: | |
68 | icon_name = "start.png" |
|
68 | icon_name = "start.png" | |
69 |
|
69 | |||
70 | iconStart = QtGui.QIcon() |
|
70 | iconStart = QtGui.QIcon() | |
71 | iconStart.addPixmap(QtGui.QPixmap(_fromUtf8( os.path.join(FIGURES_PATH, icon_name) )), QtGui.QIcon.Normal, QtGui.QIcon.Off) |
|
71 | iconStart.addPixmap(QtGui.QPixmap(_fromUtf8( os.path.join(FIGURES_PATH, icon_name) )), QtGui.QIcon.Normal, QtGui.QIcon.Off) | |
72 | self.actionStarToolbar.setIcon(iconStart) |
|
72 | self.actionStarToolbar.setIcon(iconStart) | |
73 |
|
|
73 | ||
74 | return |
|
74 | return | |
75 |
|
75 | |||
76 | def setupUi(self, MainWindow): |
|
76 | def setupUi(self, MainWindow): | |
77 |
|
77 | |||
78 | self.paused=False |
|
78 | self.paused=False | |
79 |
|
79 | |||
80 | MainWindow.setObjectName(_fromUtf8("MainWindow")) |
|
80 | MainWindow.setObjectName(_fromUtf8("MainWindow")) | |
81 | MainWindow.resize(1200, 800) |
|
81 | MainWindow.resize(1200, 800) | |
82 |
|
82 | |||
83 | self.centralWidget = QtGui.QWidget(MainWindow) |
|
83 | self.centralWidget = QtGui.QWidget(MainWindow) | |
84 | self.centralWidget.setObjectName(_fromUtf8("centralWidget")) |
|
84 | self.centralWidget.setObjectName(_fromUtf8("centralWidget")) | |
85 | self.gridLayout_16 = QtGui.QGridLayout(self.centralWidget) |
|
85 | self.gridLayout_16 = QtGui.QGridLayout(self.centralWidget) | |
86 | self.gridLayout_16.setObjectName(_fromUtf8("gridLayout_16")) |
|
86 | self.gridLayout_16.setObjectName(_fromUtf8("gridLayout_16")) | |
87 | self.splitter_2 = QtGui.QSplitter(self.centralWidget) |
|
87 | self.splitter_2 = QtGui.QSplitter(self.centralWidget) | |
88 | self.splitter_2.setOrientation(QtCore.Qt.Horizontal) |
|
88 | self.splitter_2.setOrientation(QtCore.Qt.Horizontal) | |
89 | self.splitter_2.setObjectName(_fromUtf8("splitter_2")) |
|
89 | self.splitter_2.setObjectName(_fromUtf8("splitter_2")) | |
90 | self.projectExplorerTree = QtGui.QTreeView(self.splitter_2) |
|
90 | self.projectExplorerTree = QtGui.QTreeView(self.splitter_2) | |
91 | self.projectExplorerTree.setObjectName(_fromUtf8("projectExplorerTree")) |
|
91 | self.projectExplorerTree.setObjectName(_fromUtf8("projectExplorerTree")) | |
92 | self.splitter = QtGui.QSplitter(self.splitter_2) |
|
92 | self.splitter = QtGui.QSplitter(self.splitter_2) | |
93 | self.splitter.setOrientation(QtCore.Qt.Vertical) |
|
93 | self.splitter.setOrientation(QtCore.Qt.Vertical) | |
94 | self.splitter.setObjectName(_fromUtf8("splitter")) |
|
94 | self.splitter.setObjectName(_fromUtf8("splitter")) | |
95 | self.tabWidgetProject = QtGui.QTabWidget(self.splitter) |
|
95 | self.tabWidgetProject = QtGui.QTabWidget(self.splitter) | |
96 | self.tabWidgetProject.setMinimumSize(QtCore.QSize(0, 278)) |
|
96 | self.tabWidgetProject.setMinimumSize(QtCore.QSize(0, 278)) | |
97 | self.tabWidgetProject.setMaximumSize(QtCore.QSize(16777215, 16777215)) |
|
97 | self.tabWidgetProject.setMaximumSize(QtCore.QSize(16777215, 16777215)) | |
98 | self.tabWidgetProject.setObjectName(_fromUtf8("tabWidgetProject")) |
|
98 | self.tabWidgetProject.setObjectName(_fromUtf8("tabWidgetProject")) | |
99 |
|
99 | |||
100 | self.tabConsole = QtGui.QTabWidget(self.splitter) |
|
100 | self.tabConsole = QtGui.QTabWidget(self.splitter) | |
101 | self.tabConsole.setMinimumSize(QtCore.QSize(0, 0)) |
|
101 | self.tabConsole.setMinimumSize(QtCore.QSize(0, 0)) | |
102 | self.tabConsole.setObjectName(_fromUtf8("tabConsole")) |
|
102 | self.tabConsole.setObjectName(_fromUtf8("tabConsole")) | |
103 | self.tab_5 = QtGui.QWidget() |
|
103 | self.tab_5 = QtGui.QWidget() | |
104 | self.tab_5.setObjectName(_fromUtf8("tab_5")) |
|
104 | self.tab_5.setObjectName(_fromUtf8("tab_5")) | |
105 | self.gridLayout_4 = QtGui.QGridLayout(self.tab_5) |
|
105 | self.gridLayout_4 = QtGui.QGridLayout(self.tab_5) | |
106 | self.gridLayout_4.setObjectName(_fromUtf8("gridLayout_4")) |
|
106 | self.gridLayout_4.setObjectName(_fromUtf8("gridLayout_4")) | |
107 | self.console = QtGui.QTextEdit(self.tab_5) |
|
107 | self.console = QtGui.QTextEdit(self.tab_5) | |
108 | self.console.setObjectName(_fromUtf8("console")) |
|
108 | self.console.setObjectName(_fromUtf8("console")) | |
109 | self.gridLayout_4.addWidget(self.console, 0, 0, 1, 1) |
|
109 | self.gridLayout_4.addWidget(self.console, 0, 0, 1, 1) | |
110 | self.tabConsole.addTab(self.tab_5, _fromUtf8("")) |
|
110 | self.tabConsole.addTab(self.tab_5, _fromUtf8("")) | |
111 | self.tabWidget = QtGui.QTabWidget(self.splitter_2) |
|
111 | self.tabWidget = QtGui.QTabWidget(self.splitter_2) | |
112 | self.tabWidget.setObjectName(_fromUtf8("tabWidget")) |
|
112 | self.tabWidget.setObjectName(_fromUtf8("tabWidget")) | |
113 | self.tabProjectProperty = QtGui.QWidget() |
|
113 | self.tabProjectProperty = QtGui.QWidget() | |
114 | self.tabProjectProperty.setObjectName(_fromUtf8("tabProjectProperty")) |
|
114 | self.tabProjectProperty.setObjectName(_fromUtf8("tabProjectProperty")) | |
115 | self.gridLayout_8 = QtGui.QGridLayout(self.tabProjectProperty) |
|
115 | self.gridLayout_8 = QtGui.QGridLayout(self.tabProjectProperty) | |
116 | self.gridLayout_8.setObjectName(_fromUtf8("gridLayout_8")) |
|
116 | self.gridLayout_8.setObjectName(_fromUtf8("gridLayout_8")) | |
117 | self.treeProjectProperties = QtGui.QTreeView(self.tabProjectProperty) |
|
117 | self.treeProjectProperties = QtGui.QTreeView(self.tabProjectProperty) | |
118 | self.treeProjectProperties.setObjectName(_fromUtf8("treeProjectProperties")) |
|
118 | self.treeProjectProperties.setObjectName(_fromUtf8("treeProjectProperties")) | |
119 | self.gridLayout_8.addWidget(self.treeProjectProperties, 0, 0, 1, 1) |
|
119 | self.gridLayout_8.addWidget(self.treeProjectProperties, 0, 0, 1, 1) | |
120 | self.tabWidget.addTab(self.tabProjectProperty, _fromUtf8("")) |
|
120 | self.tabWidget.addTab(self.tabProjectProperty, _fromUtf8("")) | |
121 | self.gridLayout_16.addWidget(self.splitter_2, 1, 0, 1, 1) |
|
121 | self.gridLayout_16.addWidget(self.splitter_2, 1, 0, 1, 1) | |
122 |
|
122 | |||
123 | MainWindow.setCentralWidget(self.centralWidget) |
|
123 | MainWindow.setCentralWidget(self.centralWidget) | |
124 | self.toolBar = QtGui.QToolBar(MainWindow) |
|
124 | self.toolBar = QtGui.QToolBar(MainWindow) | |
125 | self.toolBar.setObjectName(_fromUtf8("toolBar")) |
|
125 | self.toolBar.setObjectName(_fromUtf8("toolBar")) | |
126 | MainWindow.addToolBar(QtCore.Qt.TopToolBarArea, self.toolBar) |
|
126 | MainWindow.addToolBar(QtCore.Qt.TopToolBarArea, self.toolBar) | |
127 |
|
127 | |||
128 | self.menuBar = QtGui.QMenuBar(MainWindow) |
|
128 | self.menuBar = QtGui.QMenuBar(MainWindow) | |
129 | self.menuBar.setGeometry(QtCore.QRect(0, 0, 1065, 25)) |
|
129 | self.menuBar.setGeometry(QtCore.QRect(0, 0, 1065, 25)) | |
130 | self.menuBar.setObjectName(_fromUtf8("menuBar")) |
|
130 | self.menuBar.setObjectName(_fromUtf8("menuBar")) | |
131 | self.menuProject = QtGui.QMenu(self.menuBar) |
|
131 | self.menuProject = QtGui.QMenu(self.menuBar) | |
132 | self.menuProject.setObjectName(_fromUtf8("menuProject")) |
|
132 | self.menuProject.setObjectName(_fromUtf8("menuProject")) | |
133 | self.menuRun = QtGui.QMenu(self.menuBar) |
|
133 | self.menuRun = QtGui.QMenu(self.menuBar) | |
134 | self.menuRun.setObjectName(_fromUtf8("menuRun")) |
|
134 | self.menuRun.setObjectName(_fromUtf8("menuRun")) | |
135 | self.menuOptions = QtGui.QMenu(self.menuBar) |
|
135 | self.menuOptions = QtGui.QMenu(self.menuBar) | |
136 | self.menuOptions.setObjectName(_fromUtf8("menuOptions")) |
|
136 | self.menuOptions.setObjectName(_fromUtf8("menuOptions")) | |
137 | self.menuHelp = QtGui.QMenu(self.menuBar) |
|
137 | self.menuHelp = QtGui.QMenu(self.menuBar) | |
138 | self.menuHelp.setObjectName(_fromUtf8("menuHelp")) |
|
138 | self.menuHelp.setObjectName(_fromUtf8("menuHelp")) | |
139 | MainWindow.setMenuBar(self.menuBar) |
|
139 | MainWindow.setMenuBar(self.menuBar) | |
140 |
|
140 | |||
141 | iconOpen = QtGui.QIcon() |
|
141 | iconOpen = QtGui.QIcon() | |
142 | iconOpen.addPixmap(QtGui.QPixmap(_fromUtf8( os.path.join(FIGURES_PATH,"open.png") )), QtGui.QIcon.Normal, QtGui.QIcon.Off) |
|
142 | iconOpen.addPixmap(QtGui.QPixmap(_fromUtf8( os.path.join(FIGURES_PATH,"open.png") )), QtGui.QIcon.Normal, QtGui.QIcon.Off) | |
143 | iconCreate = QtGui.QIcon() |
|
143 | iconCreate = QtGui.QIcon() | |
144 | iconCreate.addPixmap(QtGui.QPixmap(_fromUtf8( os.path.join(FIGURES_PATH,"new.png") )), QtGui.QIcon.Normal, QtGui.QIcon.Off) |
|
144 | iconCreate.addPixmap(QtGui.QPixmap(_fromUtf8( os.path.join(FIGURES_PATH,"new.png") )), QtGui.QIcon.Normal, QtGui.QIcon.Off) | |
145 | iconSave = QtGui.QIcon() |
|
145 | iconSave = QtGui.QIcon() | |
146 | iconSave.addPixmap(QtGui.QPixmap(_fromUtf8( os.path.join(FIGURES_PATH,"save.png") )), QtGui.QIcon.Normal, QtGui.QIcon.Off) |
|
146 | iconSave.addPixmap(QtGui.QPixmap(_fromUtf8( os.path.join(FIGURES_PATH,"save.png") )), QtGui.QIcon.Normal, QtGui.QIcon.Off) | |
147 | iconStart = QtGui.QIcon() |
|
147 | iconStart = QtGui.QIcon() | |
148 | iconStart.addPixmap(QtGui.QPixmap(_fromUtf8( os.path.join(FIGURES_PATH,"start.png") )), QtGui.QIcon.Normal, QtGui.QIcon.Off) |
|
148 | iconStart.addPixmap(QtGui.QPixmap(_fromUtf8( os.path.join(FIGURES_PATH,"start.png") )), QtGui.QIcon.Normal, QtGui.QIcon.Off) | |
149 | iconStop = QtGui.QIcon() |
|
149 | iconStop = QtGui.QIcon() | |
150 | iconStop.addPixmap(QtGui.QPixmap(_fromUtf8( os.path.join(FIGURES_PATH,"stop.png") )), QtGui.QIcon.Normal, QtGui.QIcon.Off) |
|
150 | iconStop.addPixmap(QtGui.QPixmap(_fromUtf8( os.path.join(FIGURES_PATH,"stop.png") )), QtGui.QIcon.Normal, QtGui.QIcon.Off) | |
151 | iconPause = QtGui.QIcon() |
|
151 | iconPause = QtGui.QIcon() | |
152 | iconPause.addPixmap(QtGui.QPixmap(_fromUtf8( os.path.join(FIGURES_PATH,"pause.png") )), QtGui.QIcon.Normal, QtGui.QIcon.Off) |
|
152 | iconPause.addPixmap(QtGui.QPixmap(_fromUtf8( os.path.join(FIGURES_PATH,"pause.png") )), QtGui.QIcon.Normal, QtGui.QIcon.Off) | |
153 | iconAddPU = QtGui.QIcon() |
|
153 | iconAddPU = QtGui.QIcon() | |
154 | iconAddPU.addPixmap(QtGui.QPixmap(_fromUtf8( os.path.join(FIGURES_PATH,"branch.png") )), QtGui.QIcon.Normal, QtGui.QIcon.Off) |
|
154 | iconAddPU.addPixmap(QtGui.QPixmap(_fromUtf8( os.path.join(FIGURES_PATH,"branch.png") )), QtGui.QIcon.Normal, QtGui.QIcon.Off) | |
155 | iconClose = QtGui.QIcon() |
|
155 | iconClose = QtGui.QIcon() | |
156 | iconClose.addPixmap(QtGui.QPixmap(_fromUtf8( os.path.join(FIGURES_PATH,"close.png") )), QtGui.QIcon.Normal, QtGui.QIcon.Off) |
|
156 | iconClose.addPixmap(QtGui.QPixmap(_fromUtf8( os.path.join(FIGURES_PATH,"close.png") )), QtGui.QIcon.Normal, QtGui.QIcon.Off) | |
157 |
|
157 | |||
158 |
|
158 | |||
159 | self.actionOpen = QtGui.QAction(MainWindow) |
|
159 | self.actionOpen = QtGui.QAction(MainWindow) | |
160 | self.actionOpen.setIcon(iconOpen) |
|
160 | self.actionOpen.setIcon(iconOpen) | |
161 | self.actionOpen.setObjectName(_fromUtf8("actionOpen")) |
|
161 | self.actionOpen.setObjectName(_fromUtf8("actionOpen")) | |
162 | self.actionCreate = QtGui.QAction(MainWindow) |
|
162 | self.actionCreate = QtGui.QAction(MainWindow) | |
163 | self.actionCreate.setIcon(iconCreate) |
|
163 | self.actionCreate.setIcon(iconCreate) | |
164 | self.actionCreate.setObjectName(_fromUtf8("actionCreate")) |
|
164 | self.actionCreate.setObjectName(_fromUtf8("actionCreate")) | |
165 | self.actionSave = QtGui.QAction(MainWindow) |
|
165 | self.actionSave = QtGui.QAction(MainWindow) | |
166 | self.actionSave.setIcon(iconSave) |
|
166 | self.actionSave.setIcon(iconSave) | |
167 | self.actionSave.setObjectName(_fromUtf8("actionSave")) |
|
167 | self.actionSave.setObjectName(_fromUtf8("actionSave")) | |
168 | self.actionClose = QtGui.QAction(MainWindow) |
|
168 | self.actionClose = QtGui.QAction(MainWindow) | |
169 | self.actionClose.setIcon(iconClose) |
|
169 | self.actionClose.setIcon(iconClose) | |
170 | self.actionClose.setObjectName(_fromUtf8("actionClose")) |
|
170 | self.actionClose.setObjectName(_fromUtf8("actionClose")) | |
171 | self.actionStart = QtGui.QAction(MainWindow) |
|
171 | self.actionStart = QtGui.QAction(MainWindow) | |
172 | self.actionStart.setIcon(iconStart) |
|
172 | self.actionStart.setIcon(iconStart) | |
173 | self.actionStart.setObjectName(_fromUtf8("actionStart")) |
|
173 | self.actionStart.setObjectName(_fromUtf8("actionStart")) | |
174 | self.actionPause = QtGui.QAction(MainWindow) |
|
174 | self.actionPause = QtGui.QAction(MainWindow) | |
175 | self.actionPause.setIcon(iconPause) |
|
175 | self.actionPause.setIcon(iconPause) | |
176 | self.actionPause.setObjectName(_fromUtf8("actionPause")) |
|
176 | self.actionPause.setObjectName(_fromUtf8("actionPause")) | |
177 | self.actionStop = QtGui.QAction(MainWindow) |
|
177 | self.actionStop = QtGui.QAction(MainWindow) | |
178 | self.actionStop.setIcon(iconStop) |
|
178 | self.actionStop.setIcon(iconStop) | |
179 | self.actionStop.setObjectName(_fromUtf8("actionStop")) |
|
179 | self.actionStop.setObjectName(_fromUtf8("actionStop")) | |
180 | self.actionAbout = QtGui.QAction(MainWindow) |
|
180 | self.actionAbout = QtGui.QAction(MainWindow) | |
181 | self.actionAbout.setObjectName(_fromUtf8("actionAbout")) |
|
181 | self.actionAbout.setObjectName(_fromUtf8("actionAbout")) | |
182 |
|
182 | |||
183 | self.actionOpenToolbar = QtGui.QAction(MainWindow) |
|
183 | self.actionOpenToolbar = QtGui.QAction(MainWindow) | |
184 | self.actionOpenToolbar.setIcon(iconOpen) |
|
184 | self.actionOpenToolbar.setIcon(iconOpen) | |
185 | self.actionOpenToolbar.setObjectName(_fromUtf8("actionOpenToolbar")) |
|
185 | self.actionOpenToolbar.setObjectName(_fromUtf8("actionOpenToolbar")) | |
186 | self.actionCreateToolbar = QtGui.QAction(MainWindow) |
|
186 | self.actionCreateToolbar = QtGui.QAction(MainWindow) | |
187 | self.actionCreateToolbar.setIcon(iconCreate) |
|
187 | self.actionCreateToolbar.setIcon(iconCreate) | |
188 | self.actionCreateToolbar.setObjectName(_fromUtf8("actionCreateToolbar")) |
|
188 | self.actionCreateToolbar.setObjectName(_fromUtf8("actionCreateToolbar")) | |
189 | self.actionSaveToolbar = QtGui.QAction(MainWindow) |
|
189 | self.actionSaveToolbar = QtGui.QAction(MainWindow) | |
190 | self.actionSaveToolbar.setIcon(iconSave) |
|
190 | self.actionSaveToolbar.setIcon(iconSave) | |
191 | self.actionSaveToolbar.setObjectName(_fromUtf8("actionSaveToolbar")) |
|
191 | self.actionSaveToolbar.setObjectName(_fromUtf8("actionSaveToolbar")) | |
192 | self.actionStarToolbar = QtGui.QAction(MainWindow) |
|
192 | self.actionStarToolbar = QtGui.QAction(MainWindow) | |
193 | self.actionStarToolbar.setIcon(iconStart) |
|
193 | self.actionStarToolbar.setIcon(iconStart) | |
194 | self.actionStarToolbar.setObjectName(_fromUtf8("actionStarToolbar")) |
|
194 | self.actionStarToolbar.setObjectName(_fromUtf8("actionStarToolbar")) | |
195 | self.actionStopToolbar = QtGui.QAction(MainWindow) |
|
195 | self.actionStopToolbar = QtGui.QAction(MainWindow) | |
196 | self.actionStopToolbar.setIcon(iconStop) |
|
196 | self.actionStopToolbar.setIcon(iconStop) | |
197 | self.actionStopToolbar.setObjectName(_fromUtf8("actionStopToolbar")) |
|
197 | self.actionStopToolbar.setObjectName(_fromUtf8("actionStopToolbar")) | |
198 | self.actionPauseToolbar = QtGui.QAction(MainWindow) |
|
198 | self.actionPauseToolbar = QtGui.QAction(MainWindow) | |
199 | self.actionPauseToolbar.setIcon(iconPause) |
|
199 | self.actionPauseToolbar.setIcon(iconPause) | |
200 | self.actionPauseToolbar.setObjectName(_fromUtf8("actionPauseToolbar")) |
|
200 | self.actionPauseToolbar.setObjectName(_fromUtf8("actionPauseToolbar")) | |
201 | self.actionAddPU = QtGui.QAction(MainWindow) |
|
201 | self.actionAddPU = QtGui.QAction(MainWindow) | |
202 | self.actionAddPU.setIcon(iconAddPU) |
|
202 | self.actionAddPU.setIcon(iconAddPU) | |
203 | self.actionAddPU.setObjectName(_fromUtf8("actionAddPU")) |
|
203 | self.actionAddPU.setObjectName(_fromUtf8("actionAddPU")) | |
204 | self.actionFTP = QtGui.QAction(MainWindow) |
|
204 | self.actionFTP = QtGui.QAction(MainWindow) | |
205 | self.actionFTP.setObjectName(_fromUtf8("actionFTP")) |
|
205 | self.actionFTP.setObjectName(_fromUtf8("actionFTP")) | |
206 | self.toolBar.addAction(self.actionOpenToolbar) |
|
206 | self.toolBar.addAction(self.actionOpenToolbar) | |
207 | self.toolBar.addSeparator() |
|
207 | self.toolBar.addSeparator() | |
208 | self.toolBar.addAction(self.actionCreateToolbar) |
|
208 | self.toolBar.addAction(self.actionCreateToolbar) | |
209 | self.toolBar.addSeparator() |
|
209 | self.toolBar.addSeparator() | |
210 | self.toolBar.addAction(self.actionAddPU) |
|
210 | self.toolBar.addAction(self.actionAddPU) | |
211 | self.toolBar.addSeparator() |
|
211 | self.toolBar.addSeparator() | |
212 | self.toolBar.addAction(self.actionSaveToolbar) |
|
212 | self.toolBar.addAction(self.actionSaveToolbar) | |
213 | self.toolBar.addSeparator() |
|
213 | self.toolBar.addSeparator() | |
214 | self.toolBar.addAction(self.actionStarToolbar) |
|
214 | self.toolBar.addAction(self.actionStarToolbar) | |
215 | self.toolBar.addSeparator() |
|
215 | self.toolBar.addSeparator() | |
216 | self.toolBar.addAction(self.actionPauseToolbar) |
|
216 | self.toolBar.addAction(self.actionPauseToolbar) | |
217 | self.toolBar.addSeparator() |
|
217 | self.toolBar.addSeparator() | |
218 | self.toolBar.addAction(self.actionStopToolbar) |
|
218 | self.toolBar.addAction(self.actionStopToolbar) | |
219 | self.toolBar.addSeparator() |
|
219 | self.toolBar.addSeparator() | |
220 |
|
220 | |||
221 | # self.actionPause.triggered.connect(self.changePauseIcon) |
|
221 | # self.actionPause.triggered.connect(self.changePauseIcon) | |
222 | # self.actionPauseToolbar.triggered.connect(self.changePauseIcon) |
|
222 | # self.actionPauseToolbar.triggered.connect(self.changePauseIcon) | |
223 |
|
223 | |||
224 | self.menuProject.addAction(self.actionOpen) |
|
224 | self.menuProject.addAction(self.actionOpen) | |
225 | self.menuProject.addAction(self.actionCreate) |
|
225 | self.menuProject.addAction(self.actionCreate) | |
226 | self.menuProject.addAction(self.actionSave) |
|
226 | self.menuProject.addAction(self.actionSave) | |
227 | self.menuProject.addAction(self.actionClose) |
|
227 | self.menuProject.addAction(self.actionClose) | |
228 | self.menuRun.addAction(self.actionStart) |
|
228 | self.menuRun.addAction(self.actionStart) | |
229 | self.menuRun.addAction(self.actionPause) |
|
229 | self.menuRun.addAction(self.actionPause) | |
230 | self.menuRun.addAction(self.actionStop) |
|
230 | self.menuRun.addAction(self.actionStop) | |
231 | self.menuOptions.addAction(self.actionFTP) |
|
231 | self.menuOptions.addAction(self.actionFTP) | |
232 | self.menuHelp.addAction(self.actionAbout) |
|
232 | self.menuHelp.addAction(self.actionAbout) | |
233 | self.menuBar.addAction(self.menuProject.menuAction()) |
|
233 | self.menuBar.addAction(self.menuProject.menuAction()) | |
234 | self.menuBar.addAction(self.menuRun.menuAction()) |
|
234 | self.menuBar.addAction(self.menuRun.menuAction()) | |
235 | self.menuBar.addAction(self.menuOptions.menuAction()) |
|
235 | self.menuBar.addAction(self.menuOptions.menuAction()) | |
236 | self.menuBar.addAction(self.menuHelp.menuAction()) |
|
236 | self.menuBar.addAction(self.menuHelp.menuAction()) | |
237 |
|
237 | |||
238 | self.tabConsole.setCurrentIndex(0) |
|
238 | self.tabConsole.setCurrentIndex(0) | |
239 | self.tabWidget.setCurrentIndex(0) |
|
239 | self.tabWidget.setCurrentIndex(0) | |
240 |
|
240 | |||
241 | def retranslateUi(self, MainWindow): |
|
241 | def retranslateUi(self, MainWindow): | |
242 |
|
242 | |||
243 | MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow", None)) |
|
243 | MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow", None)) | |
244 |
|
244 | |||
245 | self.tabConsole.setTabText(self.tabConsole.indexOf(self.tab_5), _translate("MainWindow", "Console", None)) |
|
245 | self.tabConsole.setTabText(self.tabConsole.indexOf(self.tab_5), _translate("MainWindow", "Console", None)) | |
246 |
|
246 | |||
247 | self.tabWidget.setTabText(self.tabWidget.indexOf(self.tabProjectProperty), _translate("MainWindow", "Project Property", None)) |
|
247 | self.tabWidget.setTabText(self.tabWidget.indexOf(self.tabProjectProperty), _translate("MainWindow", "Project Property", None)) | |
248 | self.toolBar.setWindowTitle(_translate("MainWindow", "toolBar", None)) |
|
248 | self.toolBar.setWindowTitle(_translate("MainWindow", "toolBar", None)) | |
249 | self.menuProject.setTitle(_translate("MainWindow", "Project", None)) |
|
249 | self.menuProject.setTitle(_translate("MainWindow", "Project", None)) | |
250 | self.menuRun.setTitle(_translate("MainWindow", "Run", None)) |
|
250 | self.menuRun.setTitle(_translate("MainWindow", "Run", None)) | |
251 | self.menuOptions.setTitle(_translate("MainWindow", "Options", None)) |
|
251 | self.menuOptions.setTitle(_translate("MainWindow", "Options", None)) | |
252 | self.menuHelp.setTitle(_translate("MainWindow", "Help", None)) |
|
252 | self.menuHelp.setTitle(_translate("MainWindow", "Help", None)) | |
253 | self.actionOpen.setText(_translate("MainWindow", "Open", None)) |
|
253 | self.actionOpen.setText(_translate("MainWindow", "Open", None)) | |
254 | self.actionCreate.setText(_translate("MainWindow", "Create", None)) |
|
254 | self.actionCreate.setText(_translate("MainWindow", "Create", None)) | |
255 | self.actionSave.setText(_translate("MainWindow", "Save", None)) |
|
255 | self.actionSave.setText(_translate("MainWindow", "Save", None)) | |
256 | self.actionClose.setText(_translate("MainWindow", "Close", None)) |
|
256 | self.actionClose.setText(_translate("MainWindow", "Close", None)) | |
257 | self.actionStart.setText(_translate("MainWindow", "Start", None)) |
|
257 | self.actionStart.setText(_translate("MainWindow", "Start", None)) | |
258 | self.actionPause.setText(_translate("MainWindow", "Pause", None)) |
|
258 | self.actionPause.setText(_translate("MainWindow", "Pause", None)) | |
259 | self.actionStop.setText(_translate("MainWindow", "Stop", None)) |
|
259 | self.actionStop.setText(_translate("MainWindow", "Stop", None)) | |
260 | self.actionAbout.setText(_translate("MainWindow", "About SChain", None)) |
|
260 | self.actionAbout.setText(_translate("MainWindow", "About SChain", None)) | |
261 | self.actionOpenToolbar.setText(_translate("MainWindow", "openToolbar", None)) |
|
261 | self.actionOpenToolbar.setText(_translate("MainWindow", "openToolbar", None)) | |
262 | self.actionOpenToolbar.setToolTip(_translate("MainWindow", "Open a project", None)) |
|
262 | self.actionOpenToolbar.setToolTip(_translate("MainWindow", "Open a project", None)) | |
263 | self.actionCreateToolbar.setText(_translate("MainWindow", "createToolbar", None)) |
|
263 | self.actionCreateToolbar.setText(_translate("MainWindow", "createToolbar", None)) | |
264 | self.actionCreateToolbar.setToolTip(_translate("MainWindow", "Create a new project", None)) |
|
264 | self.actionCreateToolbar.setToolTip(_translate("MainWindow", "Create a new project", None)) | |
265 | self.actionSaveToolbar.setText(_translate("MainWindow", "saveToolbar", None)) |
|
265 | self.actionSaveToolbar.setText(_translate("MainWindow", "saveToolbar", None)) | |
266 | self.actionSaveToolbar.setToolTip(_translate("MainWindow", "Save a project", None)) |
|
266 | self.actionSaveToolbar.setToolTip(_translate("MainWindow", "Save a project", None)) | |
267 | self.actionStarToolbar.setText(_translate("MainWindow", "starToolbar", None)) |
|
267 | self.actionStarToolbar.setText(_translate("MainWindow", "starToolbar", None)) | |
268 | self.actionStarToolbar.setToolTip(_translate("MainWindow", "Start process", None)) |
|
268 | self.actionStarToolbar.setToolTip(_translate("MainWindow", "Start process", None)) | |
269 | self.actionStopToolbar.setText(_translate("MainWindow", "stopToolbar", None)) |
|
269 | self.actionStopToolbar.setText(_translate("MainWindow", "stopToolbar", None)) | |
270 | self.actionStopToolbar.setToolTip(_translate("MainWindow", "Stop process", None)) |
|
270 | self.actionStopToolbar.setToolTip(_translate("MainWindow", "Stop process", None)) | |
271 | self.actionPauseToolbar.setText(_translate("MainWindow", "pauseToolbar", None)) |
|
271 | self.actionPauseToolbar.setText(_translate("MainWindow", "pauseToolbar", None)) | |
272 | self.actionPauseToolbar.setToolTip(_translate("MainWindow", "Pause process", None)) |
|
272 | self.actionPauseToolbar.setToolTip(_translate("MainWindow", "Pause process", None)) | |
273 | self.actionAddPU.setText(_translate("MainWindow", "Add Processing Unit", None)) |
|
273 | self.actionAddPU.setText(_translate("MainWindow", "Add Processing Unit", None)) | |
274 | self.actionFTP.setText(_translate("MainWindow", "FTP", None)) |
|
274 | self.actionFTP.setText(_translate("MainWindow", "FTP", None)) | |
275 |
|
275 | |||
276 | def closeEvent(self, event): |
|
276 | def closeEvent(self, event): | |
277 |
|
277 | |||
278 | reply = QtGui.QMessageBox.question(self, 'Message', |
|
278 | reply = QtGui.QMessageBox.question(self, 'Message', | |
279 | "Are you sure to quit?", QtGui.QMessageBox.Yes | |
|
279 | "Are you sure to quit?", QtGui.QMessageBox.Yes | | |
280 | QtGui.QMessageBox.No, QtGui.QMessageBox.No) |
|
280 | QtGui.QMessageBox.No, QtGui.QMessageBox.No) | |
281 | if reply == QtGui.QMessageBox.Yes: |
|
281 | if reply == QtGui.QMessageBox.Yes: | |
282 | event.accept() |
|
282 | event.accept() | |
283 | else: |
|
283 | else: | |
284 | event.ignore() |
|
284 | event.ignore() | |
285 |
|
285 | |||
286 | def aboutEvent(self): |
|
286 | def aboutEvent(self): | |
287 | title = "Signal Chain Processing Software v%s" %__version__ |
|
287 | title = "Signal Chain Processing Software v%s" %__version__ | |
288 | message = """ |
|
288 | message = """ | |
289 | Developed by Jicamarca Radio Observatory |
|
289 | Developed by Jicamarca Radio Observatory | |
290 | Any comment to miguel.urco@jro.igp.gob.pe |
|
290 | Any comment to miguel.urco@jro.igp.gob.pe | |
291 | """ |
|
291 | """ | |
292 | QtGui.QMessageBox.about(self, title, message) |
|
292 | QtGui.QMessageBox.about(self, title, message) | |
293 |
|
293 | |||
294 |
|
294 | |||
295 | class Ui_BasicWindow(Ui_EnvWindow, Ui_ProjectTab, Ui_VoltageTab, Ui_SpectraTab, Ui_SpectraHeisTab, Ui_CorrelationTab): |
|
295 | class Ui_BasicWindow(Ui_EnvWindow, Ui_ProjectTab, Ui_VoltageTab, Ui_SpectraTab, Ui_SpectraHeisTab, Ui_CorrelationTab): | |
296 |
|
296 | |||
297 | def setupUi(self, MainWindow): |
|
297 | def setupUi(self, MainWindow): | |
298 |
|
298 | |||
299 | Ui_EnvWindow.setupUi(self, MainWindow) |
|
299 | Ui_EnvWindow.setupUi(self, MainWindow) | |
300 |
|
300 | |||
301 | Ui_ProjectTab.setupUi(self) |
|
301 | Ui_ProjectTab.setupUi(self) | |
302 | Ui_VoltageTab.setupUi(self) |
|
302 | Ui_VoltageTab.setupUi(self) | |
303 | Ui_SpectraTab.setupUi(self) |
|
303 | Ui_SpectraTab.setupUi(self) | |
304 | Ui_SpectraHeisTab.setupUi(self) |
|
304 | Ui_SpectraHeisTab.setupUi(self) | |
305 | Ui_CorrelationTab.setupUi(self) |
|
305 | Ui_CorrelationTab.setupUi(self) | |
306 |
|
306 | |||
307 | self.retranslateUi(MainWindow) |
|
307 | self.retranslateUi(MainWindow) | |
308 |
|
308 | |||
309 | QtCore.QMetaObject.connectSlotsByName(MainWindow) |
|
309 | QtCore.QMetaObject.connectSlotsByName(MainWindow) | |
310 |
|
310 | |||
311 | def retranslateUi(self, MainWindow): |
|
311 | def retranslateUi(self, MainWindow): | |
312 |
|
312 | |||
313 | Ui_EnvWindow.retranslateUi(self, MainWindow) |
|
313 | Ui_EnvWindow.retranslateUi(self, MainWindow) | |
314 |
|
314 | |||
315 | Ui_ProjectTab.retranslateUi(self) |
|
315 | Ui_ProjectTab.retranslateUi(self) | |
316 | Ui_VoltageTab.retranslateUi(self) |
|
316 | Ui_VoltageTab.retranslateUi(self) | |
317 | Ui_SpectraTab.retranslateUi(self) |
|
317 | Ui_SpectraTab.retranslateUi(self) | |
318 | Ui_SpectraHeisTab.retranslateUi(self) |
|
318 | Ui_SpectraHeisTab.retranslateUi(self) | |
319 | Ui_CorrelationTab.retranslateUi(self) |
|
319 | Ui_CorrelationTab.retranslateUi(self) | |
320 |
|
320 | |||
321 |
|
321 | |||
322 | class Ui_AdvancedWindow(Ui_EnvWindow): |
|
322 | class Ui_AdvancedWindow(Ui_EnvWindow): | |
323 |
|
323 | |||
324 | def setupUi(self, AdvancedWindow): |
|
324 | def setupUi(self, AdvancedWindow): | |
325 |
|
325 | |||
326 | Ui_MainWindow.setupUi(self, AdvancedWindow) |
|
326 | Ui_MainWindow.setupUi(self, AdvancedWindow) | |
327 |
|
327 | |||
328 | def retranslateUi(self, AdvancedWindow): |
|
328 | def retranslateUi(self, AdvancedWindow): | |
329 |
|
329 | |||
330 | Ui_MainWindow.retranslateUi(self, AdvancedWindow) |
|
330 | Ui_MainWindow.retranslateUi(self, AdvancedWindow) | |
331 |
|
331 | |||
332 |
|
332 | |||
333 |
|
333 | |||
334 | if __name__ == "__main__": |
|
334 | if __name__ == "__main__": | |
335 | import sys |
|
335 | import sys | |
336 | app = QtGui.QApplication(sys.argv) |
|
336 | app = QtGui.QApplication(sys.argv) | |
337 | MainWindow = QtGui.QMainWindow() |
|
337 | MainWindow = QtGui.QMainWindow() | |
338 | ui = Ui_BasicWindow() |
|
338 | ui = Ui_BasicWindow() | |
339 | ui.setupUi(MainWindow) |
|
339 | ui.setupUi(MainWindow) | |
340 | MainWindow.show() |
|
340 | MainWindow.show() | |
341 | sys.exit(app.exec_()) |
|
341 | sys.exit(app.exec_()) | |
342 |
|
342 |
General Comments 0
You need to be logged in to leave comments.
Login now