##// END OF EJS Templates
cli dentro del build de schain
José Chávez -
r939:09d2a48bbf67
parent child
Show More
1 NO CONTENT: new file 100644
@@ -0,0 +1,34
1 from schainpy.controller import Project
2
3 desc = "A schain project"
4
5 controller = Project()
6 controller.setup(id='191', name="project", description=desc)
7
8 readUnitConf = controller.addReadUnit(datatype='VoltageReader',
9 path="/home/nanosat/schain/schainpy",
10 startDate="1970/01/01",
11 endDate="2017/12/31",
12 startTime="00:00:00",
13 endTime="23:59:59",
14 online=0,
15 verbose=1,
16 walk=1,
17 )
18
19 procUnitConf1 = controller.addProcUnit(datatype='VoltageProc', inputId=readUnitConf.getId())
20
21 opObj11 = procUnitConf1.addOperation(name='ProfileSelector', optype='other')
22 opObj11.addParameter(name='profileRangeList', value='120,183', format='intlist')
23
24 opObj11 = procUnitConf1.addOperation(name='RTIPlot', optype='other')
25 opObj11.addParameter(name='wintitle', value='Jicamarca Radio Observatory', format='str')
26 opObj11.addParameter(name='showprofile', value='0', format='int')
27 opObj11.addParameter(name='xmin', value='0', format='int')
28 opObj11.addParameter(name='xmax', value='24', format='int')
29 opObj11.addParameter(name='figpath', value="/home/nanosat/schain/schainpy/figs", format='str')
30 opObj11.addParameter(name='wr_period', value='5', format='int')
31 opObj11.addParameter(name='exp_code', value='22', format='int')
32
33
34 controller.start()
1 NO CONTENT: new file 100644
@@ -0,0 +1,2
1 def log():
2 pass
1 NO CONTENT: file renamed from schain-cli/.gitignore to schaincli/.gitignore
1 NO CONTENT: file renamed from schain-cli/README.md to schaincli/README.md
1 NO CONTENT: file renamed from schain-cli/schaincli/__init__.py to schaincli/__init__.py
1 NO CONTENT: file renamed from schain-cli/asdasd.py to schaincli/asdasd.py
1 NO CONTENT: file renamed from schain-cli/schain.xml to schaincli/schain.xml
@@ -1,77 +1,98
1 1 import click
2 2 import schainpy
3 3 import subprocess
4 4 from multiprocessing import cpu_count
5 from schaincli import templates
5 from schaincli.schaincli import templates
6 from schainpy import controller_api
6 7 import os
7 8 import sys
8 9 import glob
9 10
10 11 def print_version(ctx, param, value):
11 12 if not value or ctx.resilient_parsing:
12 13 return
13 14 click.echo(schainpy.__version__)
14 15 ctx.exit()
15 16
16 17
17 18 @click.command()
18 19 @click.option('--version', '-v', is_flag=True, callback=print_version, help='SChain version', type=str)
19 20 @click.option('--xml', '-x', default=None, help='run an XML file', type=click.Path(exists=True, resolve_path=True))
20 21 @click.argument('command', default='run', required=True)
21 22 @click.argument('nextcommand', default=None, required=False, type=click.Path(exists=True, resolve_path=True))
22 23 def main(command, nextcommand, version, xml):
23 24 """COMMAND LINE INTERFACE FOR SIGNAL CHAIN - JICAMARCA RADIO OBSERVATORY"""
24 25 if xml is not None:
25 subprocess.call(['schain --file=' + xml], shell=True)
26 runFromXML(xml)
26 27 elif command == 'generate':
27 28 generate()
28 29 elif command == 'test':
29 30 test()
30 31 elif command == 'run':
31 32 if nextcommand is None:
32 33 currentfiles = glob.glob('./*.py')
33 34 numberfiles = len(currentfiles)
34 35 print currentfiles
35 36 if numberfiles > 1:
36 37 click.echo('\x1b[6;37;41m[ERROR] - There is more than one file to run\x1b[0m')
37 38 elif numberfiles == 1:
38 39 subprocess.call(['python ' + currentfiles[0]], shell=True)
39 40 else:
40 41 click.echo('\x1b[6;37;41m[ERROR] - There is no file to run.\x1b[0m')
41 42 else:
42 43 subprocess.call(['python ' + nextcommand], shell=True)
43 44 else:
44 45 click.echo('\x1b[6;37;41m[ERROR] - Command is not defined.\x1b[0m')
45 46
47
46 48 def basicInputs():
47 49 inputs = {}
48 50 inputs['desc'] = click.prompt('Enter a description', default="A schain project", type=str)
49 51 inputs['name'] = click.prompt('Name of the project', default="project", type=str)
50 52 inputs['path'] = click.prompt('Data path', default=os.getcwd(), type=click.Path(exists=True, resolve_path=True))
51 53 inputs['startDate'] = click.prompt('Start date', default='1970/01/01', type=str)
52 54 inputs['endDate'] = click.prompt('End date', default='2017/12/31', type=str)
53 55 inputs['startHour'] = click.prompt('Start hour', default='00:00:00', type=str)
54 56 inputs['endHour'] = click.prompt('End hour', default='23:59:59', type=str)
55 57 inputs['figpath'] = inputs['path'] + '/figs'
56 58 return inputs
57 59
60
58 61 def generate():
59 62 inputs = basicInputs()
60 63 inputs['multiprocess'] = click.confirm('Is this a multiprocess script?')
61 64 if inputs['multiprocess']:
62 65 inputs['nProcess'] = click.prompt('How many process?', default=cpu_count(), type=int)
63 66 current = templates.multiprocess.format(**inputs)
64 67 else:
65 68 current = templates.basic.format(**inputs)
66 69 scriptname = inputs['name'] + ".py"
67 70 script = open(scriptname, 'w')
68 71 try:
69 72 script.write(current)
70 73 click.echo('\x1b[6;37;42m[SUCCESS] Script {file} generated\x1b[0m'.format(file=scriptname))
71 74 except Exception as e:
72 75 click.echo('\x1b[6;37;41m[ERROR] I cannot create the file. Do you have writing permissions?\x1b[0m')
73 76
74 77
75 78 def test():
76 print templates.basic.format(name='hola', desc= 'desc', path='path', startDate='0', endDate='0')
79 print templates.basic.format(name='hola', desc='desc', path='path', startDate='0', endDate='0')
77 80 click.echo('testing')
81
82
83 def runFromXML(filename):
84 controller = controller_api.ControllerThread()
85 if not controller.readXml(filename):
86 return
87
88 plotterObj = controller.useExternalPlotter()
89
90 controller.start()
91 plotterObj.start()
92
93 print "Finishing all processes ..."
94
95 controller.join(5)
96
97 print "End of script"
98 return
1 NO CONTENT: file renamed from schain-cli/schaincli/templates.py to schaincli/schaincli/templates.py
1 NO CONTENT: file renamed from schain-cli/setup.cfg to schaincli/setup.cfg
1 NO CONTENT: file renamed from schain-cli/setup.py to schaincli/setup.py
1 NO CONTENT: file renamed from schain-cli/tests/__init__.py to schaincli/tests/__init__.py
1 NO CONTENT: file renamed from schain-cli/tests/test_cli.py to schaincli/tests/test_cli.py
1 NO CONTENT: file renamed from schain-cli/tox.ini to schaincli/tox.ini
@@ -1,1321 +1,1321
1 1 '''
2 2 Created on September , 2012
3 3 @author:
4 4 '''
5 5
6 6 import sys
7 7 import ast
8 8 import datetime
9 9 import traceback
10 10 import math
11 11 import time
12 12 from multiprocessing import Process, Queue, cpu_count
13 13
14 14 import schainpy
15 15 import schainpy.admin
16 16
17 17 from xml.etree.ElementTree import ElementTree, Element, SubElement, tostring
18 18 from xml.dom import minidom
19 19
20 20 from schainpy.model import *
21 21 from time import sleep
22 22
23 23 def prettify(elem):
24 24 """Return a pretty-printed XML string for the Element.
25 25 """
26 26 rough_string = tostring(elem, 'utf-8')
27 27 reparsed = minidom.parseString(rough_string)
28 28 return reparsed.toprettyxml(indent=" ")
29 29
30 30 def multiSchain(child, nProcess=cpu_count(), startDate=None, endDate=None, by_day=False):
31 31 skip = 0
32 32 cursor = 0
33 33 nFiles = None
34 34 processes = []
35 35 dt1 = datetime.datetime.strptime(startDate, '%Y/%m/%d')
36 36 dt2 = datetime.datetime.strptime(endDate, '%Y/%m/%d')
37 37 days = (dt2 - dt1).days
38 38
39 39 for day in range(days+1):
40 40 skip = 0
41 41 cursor = 0
42 42 q = Queue()
43 43 processes = []
44 44 dt = (dt1 + datetime.timedelta(day)).strftime('%Y/%m/%d')
45 45 firstProcess = Process(target=child, args=(cursor, skip, q, dt))
46 46 firstProcess.start()
47 47 if by_day:
48 48 continue
49 49 nFiles = q.get()
50 50 firstProcess.terminate()
51 51 skip = int(math.ceil(nFiles/nProcess))
52 52 while True:
53 53 processes.append(Process(target=child, args=(cursor, skip, q, dt)))
54 54 processes[cursor].start()
55 55 if nFiles < cursor*skip:
56 56 break
57 57 cursor += 1
58 58
59 59 def beforeExit(exctype, value, trace):
60 60 for process in processes:
61 61 process.terminate()
62 62 process.join()
63 63 print traceback.print_tb(trace)
64 64
65 65 sys.excepthook = beforeExit
66 66
67 67 for process in processes:
68 68 process.join()
69 69 process.terminate()
70 70 time.sleep(3)
71 71
72 72 class ParameterConf():
73 73
74 74 id = None
75 75 name = None
76 76 value = None
77 77 format = None
78 78
79 79 __formated_value = None
80 80
81 81 ELEMENTNAME = 'Parameter'
82 82
83 83 def __init__(self):
84 84
85 85 self.format = 'str'
86 86
87 87 def getElementName(self):
88 88
89 89 return self.ELEMENTNAME
90 90
91 91 def getValue(self):
92 92
93 93 value = self.value
94 94 format = self.format
95 95
96 96 if self.__formated_value != None:
97 97
98 98 return self.__formated_value
99 99
100 100 if format == 'obj':
101 101 return value
102 102
103 103 if format == 'str':
104 104 self.__formated_value = str(value)
105 105 return self.__formated_value
106 106
107 107 if value == '':
108 108 raise ValueError, "%s: This parameter value is empty" %self.name
109 109
110 110 if format == 'list':
111 111 strList = value.split(',')
112 112
113 113 self.__formated_value = strList
114 114
115 115 return self.__formated_value
116 116
117 117 if format == 'intlist':
118 118 """
119 119 Example:
120 120 value = (0,1,2)
121 121 """
122 122
123 123 new_value = ast.literal_eval(value)
124 124
125 125 if type(new_value) not in (tuple, list):
126 126 new_value = [int(new_value)]
127 127
128 128 self.__formated_value = new_value
129 129
130 130 return self.__formated_value
131 131
132 132 if format == 'floatlist':
133 133 """
134 134 Example:
135 135 value = (0.5, 1.4, 2.7)
136 136 """
137 137
138 138 new_value = ast.literal_eval(value)
139 139
140 140 if type(new_value) not in (tuple, list):
141 141 new_value = [float(new_value)]
142 142
143 143 self.__formated_value = new_value
144 144
145 145 return self.__formated_value
146 146
147 147 if format == 'date':
148 148 strList = value.split('/')
149 149 intList = [int(x) for x in strList]
150 150 date = datetime.date(intList[0], intList[1], intList[2])
151 151
152 152 self.__formated_value = date
153 153
154 154 return self.__formated_value
155 155
156 156 if format == 'time':
157 157 strList = value.split(':')
158 158 intList = [int(x) for x in strList]
159 159 time = datetime.time(intList[0], intList[1], intList[2])
160 160
161 161 self.__formated_value = time
162 162
163 163 return self.__formated_value
164 164
165 165 if format == 'pairslist':
166 166 """
167 167 Example:
168 168 value = (0,1),(1,2)
169 169 """
170 170
171 171 new_value = ast.literal_eval(value)
172 172
173 173 if type(new_value) not in (tuple, list):
174 174 raise ValueError, "%s has to be a tuple or list of pairs" %value
175 175
176 176 if type(new_value[0]) not in (tuple, list):
177 177 if len(new_value) != 2:
178 178 raise ValueError, "%s has to be a tuple or list of pairs" %value
179 179 new_value = [new_value]
180 180
181 181 for thisPair in new_value:
182 182 if len(thisPair) != 2:
183 183 raise ValueError, "%s has to be a tuple or list of pairs" %value
184 184
185 185 self.__formated_value = new_value
186 186
187 187 return self.__formated_value
188 188
189 189 if format == 'multilist':
190 190 """
191 191 Example:
192 192 value = (0,1,2),(3,4,5)
193 193 """
194 194 multiList = ast.literal_eval(value)
195 195
196 196 if type(multiList[0]) == int:
197 197 multiList = ast.literal_eval("(" + value + ")")
198 198
199 199 self.__formated_value = multiList
200 200
201 201 return self.__formated_value
202 202
203 203 if format == 'bool':
204 204 value = int(value)
205 205
206 206 if format == 'int':
207 207 value = float(value)
208 208
209 209 format_func = eval(format)
210 210
211 211 self.__formated_value = format_func(value)
212 212
213 213 return self.__formated_value
214 214
215 215 def updateId(self, new_id):
216 216
217 217 self.id = str(new_id)
218 218
219 219 def setup(self, id, name, value, format='str'):
220 220
221 221 self.id = str(id)
222 222 self.name = name
223 223 if format == 'obj':
224 224 self.value = value
225 225 else:
226 226 self.value = str(value)
227 227 self.format = str.lower(format)
228 228
229 229 self.getValue()
230 230
231 231 return 1
232 232
233 233 def update(self, name, value, format='str'):
234 234
235 235 self.name = name
236 236 self.value = str(value)
237 237 self.format = format
238 238
239 239 def makeXml(self, opElement):
240 240 if self.name not in ('queue',):
241 241 parmElement = SubElement(opElement, self.ELEMENTNAME)
242 242 parmElement.set('id', str(self.id))
243 243 parmElement.set('name', self.name)
244 244 parmElement.set('value', self.value)
245 245 parmElement.set('format', self.format)
246 246
247 247 def readXml(self, parmElement):
248 248
249 249 self.id = parmElement.get('id')
250 250 self.name = parmElement.get('name')
251 251 self.value = parmElement.get('value')
252 252 self.format = str.lower(parmElement.get('format'))
253 253
254 254 #Compatible with old signal chain version
255 255 if self.format == 'int' and self.name == 'idfigure':
256 256 self.name = 'id'
257 257
258 258 def printattr(self):
259 259
260 260 print "Parameter[%s]: name = %s, value = %s, format = %s" %(self.id, self.name, self.value, self.format)
261 261
262 262 class OperationConf():
263 263
264 264 id = None
265 265 name = None
266 266 priority = None
267 267 type = None
268 268
269 269 parmConfObjList = []
270 270
271 271 ELEMENTNAME = 'Operation'
272 272
273 273 def __init__(self):
274 274
275 275 self.id = '0'
276 276 self.name = None
277 277 self.priority = None
278 278 self.type = 'self'
279 279
280 280
281 281 def __getNewId(self):
282 282
283 283 return int(self.id)*10 + len(self.parmConfObjList) + 1
284 284
285 285 def updateId(self, new_id):
286 286
287 287 self.id = str(new_id)
288 288
289 289 n = 1
290 290 for parmObj in self.parmConfObjList:
291 291
292 292 idParm = str(int(new_id)*10 + n)
293 293 parmObj.updateId(idParm)
294 294
295 295 n += 1
296 296
297 297 def getElementName(self):
298 298
299 299 return self.ELEMENTNAME
300 300
301 301 def getParameterObjList(self):
302 302
303 303 return self.parmConfObjList
304 304
305 305 def getParameterObj(self, parameterName):
306 306
307 307 for parmConfObj in self.parmConfObjList:
308 308
309 309 if parmConfObj.name != parameterName:
310 310 continue
311 311
312 312 return parmConfObj
313 313
314 314 return None
315 315
316 316 def getParameterObjfromValue(self, parameterValue):
317 317
318 318 for parmConfObj in self.parmConfObjList:
319 319
320 320 if parmConfObj.getValue() != parameterValue:
321 321 continue
322 322
323 323 return parmConfObj.getValue()
324 324
325 325 return None
326 326
327 327 def getParameterValue(self, parameterName):
328 328
329 329 parameterObj = self.getParameterObj(parameterName)
330 330
331 331 # if not parameterObj:
332 332 # return None
333 333
334 334 value = parameterObj.getValue()
335 335
336 336 return value
337 337
338 338
339 339 def getKwargs(self):
340 340
341 341 kwargs = {}
342 342
343 343 for parmConfObj in self.parmConfObjList:
344 344 if self.name == 'run' and parmConfObj.name == 'datatype':
345 345 continue
346 346
347 347 kwargs[parmConfObj.name] = parmConfObj.getValue()
348 348
349 349 return kwargs
350 350
351 351 def setup(self, id, name, priority, type):
352 352
353 353 self.id = str(id)
354 354 self.name = name
355 355 self.type = type
356 356 self.priority = priority
357 357
358 358 self.parmConfObjList = []
359 359
360 360 def removeParameters(self):
361 361
362 362 for obj in self.parmConfObjList:
363 363 del obj
364 364
365 365 self.parmConfObjList = []
366 366
367 367 def addParameter(self, name, value, format='str'):
368 368
369 369 id = self.__getNewId()
370 370
371 371 parmConfObj = ParameterConf()
372 372 if not parmConfObj.setup(id, name, value, format):
373 373 return None
374 374
375 375 self.parmConfObjList.append(parmConfObj)
376 376
377 377 return parmConfObj
378 378
379 379 def changeParameter(self, name, value, format='str'):
380 380
381 381 parmConfObj = self.getParameterObj(name)
382 382 parmConfObj.update(name, value, format)
383 383
384 384 return parmConfObj
385 385
386 386 def makeXml(self, procUnitElement):
387 387
388 388 opElement = SubElement(procUnitElement, self.ELEMENTNAME)
389 389 opElement.set('id', str(self.id))
390 390 opElement.set('name', self.name)
391 391 opElement.set('type', self.type)
392 392 opElement.set('priority', str(self.priority))
393 393
394 394 for parmConfObj in self.parmConfObjList:
395 395 parmConfObj.makeXml(opElement)
396 396
397 397 def readXml(self, opElement):
398 398
399 399 self.id = opElement.get('id')
400 400 self.name = opElement.get('name')
401 401 self.type = opElement.get('type')
402 402 self.priority = opElement.get('priority')
403 403
404 404 #Compatible with old signal chain version
405 405 #Use of 'run' method instead 'init'
406 406 if self.type == 'self' and self.name == 'init':
407 407 self.name = 'run'
408 408
409 409 self.parmConfObjList = []
410 410
411 411 parmElementList = opElement.iter(ParameterConf().getElementName())
412 412
413 413 for parmElement in parmElementList:
414 414 parmConfObj = ParameterConf()
415 415 parmConfObj.readXml(parmElement)
416 416
417 417 #Compatible with old signal chain version
418 418 #If an 'plot' OPERATION is found, changes name operation by the value of its type PARAMETER
419 419 if self.type != 'self' and self.name == 'Plot':
420 420 if parmConfObj.format == 'str' and parmConfObj.name == 'type':
421 421 self.name = parmConfObj.value
422 422 continue
423 423
424 424 self.parmConfObjList.append(parmConfObj)
425 425
426 426 def printattr(self):
427 427
428 428 print "%s[%s]: name = %s, type = %s, priority = %s" %(self.ELEMENTNAME,
429 429 self.id,
430 430 self.name,
431 431 self.type,
432 432 self.priority)
433 433
434 434 for parmConfObj in self.parmConfObjList:
435 435 parmConfObj.printattr()
436 436
437 437 def createObject(self, plotter_queue=None):
438 438
439 439
440 440 if self.type == 'self':
441 441 raise ValueError, "This operation type cannot be created"
442 442
443 443 if self.type == 'plotter':
444 444 #Plotter(plotter_name)
445 445 if not plotter_queue:
446 446 raise ValueError, "plotter_queue is not defined. Use:\nmyProject = Project()\nmyProject.setPlotterQueue(plotter_queue)"
447 447
448 448 opObj = Plotter(self.name, plotter_queue)
449 449
450 450 if self.type == 'external' or self.type == 'other':
451 451
452 452 className = eval(self.name)
453 453 kwargs = self.getKwargs()
454 454
455 455 opObj = className(**kwargs)
456 456
457 457 return opObj
458 458
459 459
460 460 class ProcUnitConf():
461 461
462 462 id = None
463 463 name = None
464 464 datatype = None
465 465 inputId = None
466 466 parentId = None
467 467
468 468 opConfObjList = []
469 469
470 470 procUnitObj = None
471 471 opObjList = []
472 472
473 473 ELEMENTNAME = 'ProcUnit'
474 474
475 475 def __init__(self):
476 476
477 477 self.id = None
478 478 self.datatype = None
479 479 self.name = None
480 480 self.inputId = None
481 481
482 482 self.opConfObjList = []
483 483
484 484 self.procUnitObj = None
485 485 self.opObjDict = {}
486 486
487 487 def __getPriority(self):
488 488
489 489 return len(self.opConfObjList)+1
490 490
491 491 def __getNewId(self):
492 492
493 493 return int(self.id)*10 + len(self.opConfObjList) + 1
494 494
495 495 def getElementName(self):
496 496
497 497 return self.ELEMENTNAME
498 498
499 499 def getId(self):
500 500
501 501 return self.id
502 502
503 503 def updateId(self, new_id, parentId=parentId):
504 504
505 505
506 506 new_id = int(parentId)*10 + (int(self.id) % 10)
507 507 new_inputId = int(parentId)*10 + (int(self.inputId) % 10)
508 508
509 509 #If this proc unit has not inputs
510 510 if self.inputId == '0':
511 511 new_inputId = 0
512 512
513 513 n = 1
514 514 for opConfObj in self.opConfObjList:
515 515
516 516 idOp = str(int(new_id)*10 + n)
517 517 opConfObj.updateId(idOp)
518 518
519 519 n += 1
520 520
521 521 self.parentId = str(parentId)
522 522 self.id = str(new_id)
523 523 self.inputId = str(new_inputId)
524 524
525 525
526 526 def getInputId(self):
527 527
528 528 return self.inputId
529 529
530 530 def getOperationObjList(self):
531 531
532 532 return self.opConfObjList
533 533
534 534 def getOperationObj(self, name=None):
535 535
536 536 for opConfObj in self.opConfObjList:
537 537
538 538 if opConfObj.name != name:
539 539 continue
540 540
541 541 return opConfObj
542 542
543 543 return None
544 544
545 545 def getOpObjfromParamValue(self, value=None):
546 546
547 547 for opConfObj in self.opConfObjList:
548 548 if opConfObj.getParameterObjfromValue(parameterValue=value) != value:
549 549 continue
550 550 return opConfObj
551 551 return None
552 552
553 553 def getProcUnitObj(self):
554 554
555 555 return self.procUnitObj
556 556
557 557 def setup(self, id, name, datatype, inputId, parentId=None):
558 558
559 559 #Compatible with old signal chain version
560 560 if datatype==None and name==None:
561 561 raise ValueError, "datatype or name should be defined"
562 562
563 563 if name==None:
564 564 if 'Proc' in datatype:
565 565 name = datatype
566 566 else:
567 567 name = '%sProc' %(datatype)
568 568
569 569 if datatype==None:
570 570 datatype = name.replace('Proc','')
571 571
572 572 self.id = str(id)
573 573 self.name = name
574 574 self.datatype = datatype
575 575 self.inputId = inputId
576 576 self.parentId = parentId
577 577
578 578 self.opConfObjList = []
579 579
580 580 self.addOperation(name='run', optype='self')
581 581
582 582 def removeOperations(self):
583 583
584 584 for obj in self.opConfObjList:
585 585 del obj
586 586
587 587 self.opConfObjList = []
588 588 self.addOperation(name='run')
589 589
590 590 def addParameter(self, **kwargs):
591 591 '''
592 592 Add parameters to "run" operation
593 593 '''
594 594 opObj = self.opConfObjList[0]
595 595
596 596 opObj.addParameter(**kwargs)
597 597
598 598 return opObj
599 599
600 600 def addOperation(self, name, optype='self'):
601 601
602 602 id = self.__getNewId()
603 603 priority = self.__getPriority()
604 604
605 605 opConfObj = OperationConf()
606 606 opConfObj.setup(id, name=name, priority=priority, type=optype)
607 607
608 608 self.opConfObjList.append(opConfObj)
609 609
610 610 return opConfObj
611 611
612 612 def makeXml(self, projectElement):
613 613
614 614 procUnitElement = SubElement(projectElement, self.ELEMENTNAME)
615 615 procUnitElement.set('id', str(self.id))
616 616 procUnitElement.set('name', self.name)
617 617 procUnitElement.set('datatype', self.datatype)
618 618 procUnitElement.set('inputId', str(self.inputId))
619 619
620 620 for opConfObj in self.opConfObjList:
621 621 opConfObj.makeXml(procUnitElement)
622 622
623 623 def readXml(self, upElement):
624 624
625 625 self.id = upElement.get('id')
626 626 self.name = upElement.get('name')
627 627 self.datatype = upElement.get('datatype')
628 628 self.inputId = upElement.get('inputId')
629 629
630 630 if self.ELEMENTNAME == "ReadUnit":
631 631 self.datatype = self.datatype.replace("Reader", "")
632 632
633 633 if self.ELEMENTNAME == "ProcUnit":
634 634 self.datatype = self.datatype.replace("Proc", "")
635 635
636 636 if self.inputId == 'None':
637 637 self.inputId = '0'
638 638
639 639 self.opConfObjList = []
640 640
641 641 opElementList = upElement.iter(OperationConf().getElementName())
642 642
643 643 for opElement in opElementList:
644 644 opConfObj = OperationConf()
645 645 opConfObj.readXml(opElement)
646 646 self.opConfObjList.append(opConfObj)
647 647
648 648 def printattr(self):
649 649
650 650 print "%s[%s]: name = %s, datatype = %s, inputId = %s" %(self.ELEMENTNAME,
651 651 self.id,
652 652 self.name,
653 653 self.datatype,
654 654 self.inputId)
655 655
656 656 for opConfObj in self.opConfObjList:
657 657 opConfObj.printattr()
658 658
659 659
660 660 def getKwargs(self):
661 661
662 662 opObj = self.opConfObjList[0]
663 663 kwargs = opObj.getKwargs()
664 664
665 665 return kwargs
666 666
667 667 def createObjects(self, plotter_queue=None):
668 668
669 669 className = eval(self.name)
670 670 kwargs = self.getKwargs()
671 671 procUnitObj = className(**kwargs)
672 672
673 673 for opConfObj in self.opConfObjList:
674 674
675 675 if opConfObj.type=='self' and self.name=='run':
676 676 continue
677 677 elif opConfObj.type=='self':
678 678 procUnitObj.addOperationKwargs(opConfObj.id, **opConfObj.getKwargs())
679 679 continue
680 680
681 681 opObj = opConfObj.createObject(plotter_queue)
682 682
683 683 self.opObjDict[opConfObj.id] = opObj
684 684
685 685 procUnitObj.addOperation(opObj, opConfObj.id)
686 686
687 687 self.procUnitObj = procUnitObj
688 688
689 689 return procUnitObj
690 690
691 691 def run(self):
692 692
693 693 is_ok = False
694 694
695 695 for opConfObj in self.opConfObjList:
696 696
697 697 kwargs = {}
698 698 for parmConfObj in opConfObj.getParameterObjList():
699 699 if opConfObj.name == 'run' and parmConfObj.name == 'datatype':
700 700 continue
701 701
702 702 kwargs[parmConfObj.name] = parmConfObj.getValue()
703 703
704 704 #ini = time.time()
705 705
706 706 #print "\tRunning the '%s' operation with %s" %(opConfObj.name, opConfObj.id)
707 707 sts = self.procUnitObj.call(opType = opConfObj.type,
708 708 opName = opConfObj.name,
709 709 opId = opConfObj.id,
710 710 )
711 711
712 712 # total_time = time.time() - ini
713 713 #
714 714 # if total_time > 0.002:
715 715 # print "%s::%s took %f seconds" %(self.name, opConfObj.name, total_time)
716 716
717 717 is_ok = is_ok or sts
718 718
719 719 return is_ok
720 720
721 721 def close(self):
722 722
723 723 for opConfObj in self.opConfObjList:
724 724 if opConfObj.type == 'self':
725 725 continue
726 726
727 727 opObj = self.procUnitObj.getOperationObj(opConfObj.id)
728 728 opObj.close()
729 729
730 730 self.procUnitObj.close()
731 731
732 732 return
733 733
734 734 class ReadUnitConf(ProcUnitConf):
735 735
736 736 path = None
737 737 startDate = None
738 738 endDate = None
739 739 startTime = None
740 740 endTime = None
741 741
742 742 ELEMENTNAME = 'ReadUnit'
743 743
744 744 def __init__(self):
745 745
746 746 self.id = None
747 747 self.datatype = None
748 748 self.name = None
749 749 self.inputId = None
750 750
751 751 self.parentId = None
752 752
753 753 self.opConfObjList = []
754 754 self.opObjList = []
755 755
756 756 def getElementName(self):
757 757
758 758 return self.ELEMENTNAME
759 759
760 760 def setup(self, id, name, datatype, path, startDate="", endDate="", startTime="", endTime="", parentId=None, queue=None, **kwargs):
761 761
762 762 #Compatible with old signal chain version
763 763 if datatype==None and name==None:
764 764 raise ValueError, "datatype or name should be defined"
765 765
766 766 if name==None:
767 767 if 'Reader' in datatype:
768 768 name = datatype
769 769 else:
770 770 name = '%sReader' %(datatype)
771 771
772 772 if datatype==None:
773 773 datatype = name.replace('Reader','')
774 774
775 775 self.id = id
776 776 self.name = name
777 777 self.datatype = datatype
778 778
779 779 self.path = os.path.abspath(path)
780 780 self.startDate = startDate
781 781 self.endDate = endDate
782 782 self.startTime = startTime
783 783 self.endTime = endTime
784 784
785 785 self.inputId = '0'
786 786 self.parentId = parentId
787 787 self.queue = queue
788 788 self.addRunOperation(**kwargs)
789 789
790 790 def update(self, datatype, path, startDate, endDate, startTime, endTime, parentId=None, name=None, **kwargs):
791 791
792 792 #Compatible with old signal chain version
793 793 if datatype==None and name==None:
794 794 raise ValueError, "datatype or name should be defined"
795 795
796 796 if name==None:
797 797 if 'Reader' in datatype:
798 798 name = datatype
799 799 else:
800 800 name = '%sReader' %(datatype)
801 801
802 802 if datatype==None:
803 803 datatype = name.replace('Reader','')
804 804
805 805 self.datatype = datatype
806 806 self.name = name
807 807 self.path = path
808 808 self.startDate = startDate
809 809 self.endDate = endDate
810 810 self.startTime = startTime
811 811 self.endTime = endTime
812 812
813 813 self.inputId = '0'
814 814 self.parentId = parentId
815 815
816 816 self.updateRunOperation(**kwargs)
817 817
818 818 def removeOperations(self):
819 819
820 820 for obj in self.opConfObjList:
821 821 del obj
822 822
823 823 self.opConfObjList = []
824 824
825 825 def addRunOperation(self, **kwargs):
826 826
827 827 opObj = self.addOperation(name = 'run', optype = 'self')
828 828
829 829 opObj.addParameter(name='datatype' , value=self.datatype, format='str')
830 830 opObj.addParameter(name='path' , value=self.path, format='str')
831 831 opObj.addParameter(name='startDate' , value=self.startDate, format='date')
832 832 opObj.addParameter(name='endDate' , value=self.endDate, format='date')
833 833 opObj.addParameter(name='startTime' , value=self.startTime, format='time')
834 834 opObj.addParameter(name='endTime' , value=self.endTime, format='time')
835 835 opObj.addParameter(name='queue' , value=self.queue, format='obj')
836 836
837 837 for key, value in kwargs.items():
838 838 opObj.addParameter(name=key, value=value, format=type(value).__name__)
839 839
840 840 return opObj
841 841
842 842 def updateRunOperation(self, **kwargs):
843 843
844 844 opObj = self.getOperationObj(name = 'run')
845 845 opObj.removeParameters()
846 846
847 847 opObj.addParameter(name='datatype' , value=self.datatype, format='str')
848 848 opObj.addParameter(name='path' , value=self.path, format='str')
849 849 opObj.addParameter(name='startDate' , value=self.startDate, format='date')
850 850 opObj.addParameter(name='endDate' , value=self.endDate, format='date')
851 851 opObj.addParameter(name='startTime' , value=self.startTime, format='time')
852 852 opObj.addParameter(name='endTime' , value=self.endTime, format='time')
853 853
854 854 for key, value in kwargs.items():
855 855 opObj.addParameter(name=key, value=value, format=type(value).__name__)
856 856
857 857 return opObj
858 858
859 859 # def makeXml(self, projectElement):
860 860 #
861 861 # procUnitElement = SubElement(projectElement, self.ELEMENTNAME)
862 862 # procUnitElement.set('id', str(self.id))
863 863 # procUnitElement.set('name', self.name)
864 864 # procUnitElement.set('datatype', self.datatype)
865 865 # procUnitElement.set('inputId', str(self.inputId))
866 866 #
867 867 # for opConfObj in self.opConfObjList:
868 868 # opConfObj.makeXml(procUnitElement)
869 869
870 870 def readXml(self, upElement):
871 871
872 872 self.id = upElement.get('id')
873 873 self.name = upElement.get('name')
874 874 self.datatype = upElement.get('datatype')
875 875 self.inputId = upElement.get('inputId')
876 876
877 877 if self.ELEMENTNAME == "ReadUnit":
878 878 self.datatype = self.datatype.replace("Reader", "")
879 879
880 880 if self.inputId == 'None':
881 881 self.inputId = '0'
882 882
883 883 self.opConfObjList = []
884 884
885 885 opElementList = upElement.iter(OperationConf().getElementName())
886 886
887 887 for opElement in opElementList:
888 888 opConfObj = OperationConf()
889 889 opConfObj.readXml(opElement)
890 890 self.opConfObjList.append(opConfObj)
891 891
892 892 if opConfObj.name == 'run':
893 893 self.path = opConfObj.getParameterValue('path')
894 894 self.startDate = opConfObj.getParameterValue('startDate')
895 895 self.endDate = opConfObj.getParameterValue('endDate')
896 896 self.startTime = opConfObj.getParameterValue('startTime')
897 897 self.endTime = opConfObj.getParameterValue('endTime')
898 898
899 899 class Project():
900 900
901 901 id = None
902 902 name = None
903 903 description = None
904 904 filename = None
905 905
906 906 procUnitConfObjDict = None
907 907
908 908 ELEMENTNAME = 'Project'
909 909
910 910 plotterQueue = None
911 911
912 912 def __init__(self, plotter_queue=None):
913 913
914 914 self.id = None
915 915 self.name = None
916 916 self.description = None
917 917
918 918 self.plotterQueue = plotter_queue
919 919
920 920 self.procUnitConfObjDict = {}
921 921
922 922 def __getNewId(self):
923 923
924 924 idList = self.procUnitConfObjDict.keys()
925 925
926 926 id = int(self.id)*10
927 927
928 928 while True:
929 929 id += 1
930 930
931 931 if str(id) in idList:
932 932 continue
933 933
934 934 break
935 935
936 936 return str(id)
937 937
938 938 def getElementName(self):
939 939
940 940 return self.ELEMENTNAME
941 941
942 942 def getId(self):
943 943
944 944 return self.id
945 945
946 946 def updateId(self, new_id):
947 947
948 948 self.id = str(new_id)
949 949
950 950 keyList = self.procUnitConfObjDict.keys()
951 951 keyList.sort()
952 952
953 953 n = 1
954 954 newProcUnitConfObjDict = {}
955 955
956 956 for procKey in keyList:
957 957
958 958 procUnitConfObj = self.procUnitConfObjDict[procKey]
959 959 idProcUnit = str(int(self.id)*10 + n)
960 960 procUnitConfObj.updateId(idProcUnit, parentId = self.id)
961 961
962 962 newProcUnitConfObjDict[idProcUnit] = procUnitConfObj
963 963 n += 1
964 964
965 965 self.procUnitConfObjDict = newProcUnitConfObjDict
966 966
967 967 def setup(self, id, name, description):
968 968
969 969 self.id = str(id)
970 970 self.name = name
971 971 self.description = description
972 972
973 973 def update(self, name, description):
974 974
975 975 self.name = name
976 976 self.description = description
977 977
978 978 def addReadUnit(self, id=None, datatype=None, name=None, **kwargs):
979 979
980 980 if id is None:
981 981 idReadUnit = self.__getNewId()
982 982 else:
983 983 idReadUnit = str(id)
984 984
985 985 readUnitConfObj = ReadUnitConf()
986 986 readUnitConfObj.setup(idReadUnit, name, datatype, parentId=self.id, **kwargs)
987 987
988 988 self.procUnitConfObjDict[readUnitConfObj.getId()] = readUnitConfObj
989 989
990 990 return readUnitConfObj
991 991
992 992 def addProcUnit(self, inputId='0', datatype=None, name=None):
993 993
994 994 idProcUnit = self.__getNewId()
995 995
996 996 procUnitConfObj = ProcUnitConf()
997 997 procUnitConfObj.setup(idProcUnit, name, datatype, inputId, parentId=self.id)
998 998
999 999 self.procUnitConfObjDict[procUnitConfObj.getId()] = procUnitConfObj
1000 1000
1001 1001 return procUnitConfObj
1002 1002
1003 1003 def removeProcUnit(self, id):
1004 1004
1005 1005 if id in self.procUnitConfObjDict.keys():
1006 1006 self.procUnitConfObjDict.pop(id)
1007 1007
1008 1008 def getReadUnitId(self):
1009 1009
1010 1010 readUnitConfObj = self.getReadUnitObj()
1011 1011
1012 1012 return readUnitConfObj.id
1013 1013
1014 1014 def getReadUnitObj(self):
1015 1015
1016 1016 for obj in self.procUnitConfObjDict.values():
1017 1017 if obj.getElementName() == "ReadUnit":
1018 1018 return obj
1019 1019
1020 1020 return None
1021 1021
1022 1022 def getProcUnitObj(self, id=None, name=None):
1023 1023
1024 1024 if id != None:
1025 1025 return self.procUnitConfObjDict[id]
1026 1026
1027 1027 if name != None:
1028 1028 return self.getProcUnitObjByName(name)
1029 1029
1030 1030 return None
1031 1031
1032 1032 def getProcUnitObjByName(self, name):
1033 1033
1034 1034 for obj in self.procUnitConfObjDict.values():
1035 1035 if obj.name == name:
1036 1036 return obj
1037 1037
1038 1038 return None
1039 1039
1040 1040 def procUnitItems(self):
1041 1041
1042 1042 return self.procUnitConfObjDict.items()
1043 1043
1044 1044 def makeXml(self):
1045 1045
1046 1046 projectElement = Element('Project')
1047 1047 projectElement.set('id', str(self.id))
1048 1048 projectElement.set('name', self.name)
1049 1049 projectElement.set('description', self.description)
1050 1050
1051 1051 for procUnitConfObj in self.procUnitConfObjDict.values():
1052 1052 procUnitConfObj.makeXml(projectElement)
1053 1053
1054 1054 self.projectElement = projectElement
1055 1055
1056 1056 def writeXml(self, filename=None):
1057 1057
1058 1058 if filename == None:
1059 1059 if self.filename:
1060 1060 filename = self.filename
1061 1061 else:
1062 1062 filename = "schain.xml"
1063 1063
1064 1064 if not filename:
1065 1065 print "filename has not been defined. Use setFilename(filename) for do it."
1066 1066 return 0
1067 1067
1068 1068 abs_file = os.path.abspath(filename)
1069 1069
1070 1070 if not os.access(os.path.dirname(abs_file), os.W_OK):
1071 1071 print "No write permission on %s" %os.path.dirname(abs_file)
1072 1072 return 0
1073 1073
1074 1074 if os.path.isfile(abs_file) and not(os.access(abs_file, os.W_OK)):
1075 1075 print "File %s already exists and it could not be overwriten" %abs_file
1076 1076 return 0
1077 1077
1078 1078 self.makeXml()
1079 1079
1080 1080 ElementTree(self.projectElement).write(abs_file, method='xml')
1081 1081
1082 1082 self.filename = abs_file
1083 1083
1084 1084 return 1
1085 1085
1086 1086 def readXml(self, filename = None):
1087 1087
1088 1088 if not filename:
1089 1089 print "filename is not defined"
1090 1090 return 0
1091 1091
1092 1092 abs_file = os.path.abspath(filename)
1093 1093
1094 1094 if not os.path.isfile(abs_file):
1095 1095 print "%s file does not exist" %abs_file
1096 1096 return 0
1097 1097
1098 1098 self.projectElement = None
1099 1099 self.procUnitConfObjDict = {}
1100 1100
1101 1101 try:
1102 1102 self.projectElement = ElementTree().parse(abs_file)
1103 1103 except:
1104 1104 print "Error reading %s, verify file format" %filename
1105 1105 return 0
1106 1106
1107 1107 self.project = self.projectElement.tag
1108 1108
1109 1109 self.id = self.projectElement.get('id')
1110 1110 self.name = self.projectElement.get('name')
1111 1111 self.description = self.projectElement.get('description')
1112 1112
1113 1113 readUnitElementList = self.projectElement.iter(ReadUnitConf().getElementName())
1114 1114
1115 1115 for readUnitElement in readUnitElementList:
1116 1116 readUnitConfObj = ReadUnitConf()
1117 1117 readUnitConfObj.readXml(readUnitElement)
1118 1118
1119 1119 if readUnitConfObj.parentId == None:
1120 1120 readUnitConfObj.parentId = self.id
1121 1121
1122 1122 self.procUnitConfObjDict[readUnitConfObj.getId()] = readUnitConfObj
1123 1123
1124 1124 procUnitElementList = self.projectElement.iter(ProcUnitConf().getElementName())
1125 1125
1126 1126 for procUnitElement in procUnitElementList:
1127 1127 procUnitConfObj = ProcUnitConf()
1128 1128 procUnitConfObj.readXml(procUnitElement)
1129 1129
1130 1130 if procUnitConfObj.parentId == None:
1131 1131 procUnitConfObj.parentId = self.id
1132 1132
1133 1133 self.procUnitConfObjDict[procUnitConfObj.getId()] = procUnitConfObj
1134 1134
1135 1135 self.filename = abs_file
1136 1136
1137 1137 return 1
1138 1138
1139 1139 def printattr(self):
1140 1140
1141 1141 print "Project[%s]: name = %s, description = %s" %(self.id,
1142 1142 self.name,
1143 1143 self.description)
1144 1144
1145 1145 for procUnitConfObj in self.procUnitConfObjDict.values():
1146 1146 procUnitConfObj.printattr()
1147 1147
1148 1148 def createObjects(self):
1149 1149
1150 1150 for procUnitConfObj in self.procUnitConfObjDict.values():
1151 1151 procUnitConfObj.createObjects(self.plotterQueue)
1152 1152
1153 1153 def __connect(self, objIN, thisObj):
1154 1154
1155 1155 thisObj.setInput(objIN.getOutputObj())
1156 1156
1157 1157 def connectObjects(self):
1158 1158
1159 1159 for thisPUConfObj in self.procUnitConfObjDict.values():
1160 1160
1161 1161 inputId = thisPUConfObj.getInputId()
1162 1162
1163 1163 if int(inputId) == 0:
1164 1164 continue
1165 1165
1166 1166 #Get input object
1167 1167 puConfINObj = self.procUnitConfObjDict[inputId]
1168 1168 puObjIN = puConfINObj.getProcUnitObj()
1169 1169
1170 1170 #Get current object
1171 1171 thisPUObj = thisPUConfObj.getProcUnitObj()
1172 1172
1173 1173 self.__connect(puObjIN, thisPUObj)
1174 1174
1175 1175 def __handleError(self, procUnitConfObj, send_email=True):
1176 1176
1177 1177 import socket
1178 1178
1179 1179 err = traceback.format_exception(sys.exc_info()[0],
1180 1180 sys.exc_info()[1],
1181 1181 sys.exc_info()[2])
1182 1182
1183 1183 print "***** Error occurred in %s *****" %(procUnitConfObj.name)
1184 1184 print "***** %s" %err[-1]
1185 1185
1186 1186 message = "".join(err)
1187 1187
1188 1188 sys.stderr.write(message)
1189 1189
1190 1190 if not send_email:
1191 1191 return
1192 1192
1193 1193 subject = "SChain v%s: Error running %s\n" %(schainpy.__version__, procUnitConfObj.name)
1194 1194
1195 1195 subtitle = "%s: %s\n" %(procUnitConfObj.getElementName() ,procUnitConfObj.name)
1196 1196 subtitle += "Hostname: %s\n" %socket.gethostbyname(socket.gethostname())
1197 1197 subtitle += "Working directory: %s\n" %os.path.abspath("./")
1198 1198 subtitle += "Configuration file: %s\n" %self.filename
1199 1199 subtitle += "Time: %s\n" %str(datetime.datetime.now())
1200 1200
1201 1201 readUnitConfObj = self.getReadUnitObj()
1202 1202 if readUnitConfObj:
1203 1203 subtitle += "\nInput parameters:\n"
1204 1204 subtitle += "[Data path = %s]\n" %readUnitConfObj.path
1205 1205 subtitle += "[Data type = %s]\n" %readUnitConfObj.datatype
1206 1206 subtitle += "[Start date = %s]\n" %readUnitConfObj.startDate
1207 1207 subtitle += "[End date = %s]\n" %readUnitConfObj.endDate
1208 1208 subtitle += "[Start time = %s]\n" %readUnitConfObj.startTime
1209 1209 subtitle += "[End time = %s]\n" %readUnitConfObj.endTime
1210 1210
1211 1211 adminObj = schainpy.admin.SchainNotify()
1212 1212 adminObj.sendAlert(message=message,
1213 1213 subject=subject,
1214 1214 subtitle=subtitle,
1215 1215 filename=self.filename)
1216 1216
1217 1217 def isPaused(self):
1218 1218 return 0
1219 1219
1220 1220 def isStopped(self):
1221 1221 return 0
1222 1222
1223 1223 def runController(self):
1224 1224 """
1225 1225 returns 0 when this process has been stopped, 1 otherwise
1226 1226 """
1227 1227
1228 1228 if self.isPaused():
1229 1229 print "Process suspended"
1230 1230
1231 1231 while True:
1232 1232 sleep(0.1)
1233 1233
1234 1234 if not self.isPaused():
1235 1235 break
1236 1236
1237 1237 if self.isStopped():
1238 1238 break
1239 1239
1240 1240 print "Process reinitialized"
1241 1241
1242 1242 if self.isStopped():
1243 1243 print "Process stopped"
1244 1244 return 0
1245 1245
1246 1246 return 1
1247 1247
1248 1248 def setFilename(self, filename):
1249 1249
1250 1250 self.filename = filename
1251 1251
1252 1252 def setPlotterQueue(self, plotter_queue):
1253 1253
1254 1254 raise NotImplementedError, "Use schainpy.controller_api.ControllerThread instead Project class"
1255 1255
1256 1256 def getPlotterQueue(self):
1257 1257
1258 1258 raise NotImplementedError, "Use schainpy.controller_api.ControllerThread instead Project class"
1259 1259
1260 1260 def useExternalPlotter(self):
1261 1261
1262 1262 raise NotImplementedError, "Use schainpy.controller_api.ControllerThread instead Project class"
1263 1263
1264 1264 def run(self):
1265 1265
1266 1266 print
1267 1267 print "*"*60
1268 1268 print " Starting SIGNAL CHAIN PROCESSING v%s " %schainpy.__version__
1269 1269 print "*"*60
1270 1270 print
1271 1271
1272 1272 keyList = self.procUnitConfObjDict.keys()
1273 1273 keyList.sort()
1274 1274
1275 1275 while(True):
1276 1276
1277 1277 is_ok = False
1278 1278
1279 1279 for procKey in keyList:
1280 1280 # print "Running the '%s' process with %s" %(procUnitConfObj.name, procUnitConfObj.id)
1281 1281
1282 1282 procUnitConfObj = self.procUnitConfObjDict[procKey]
1283 1283
1284 1284 try:
1285 1285 sts = procUnitConfObj.run()
1286 1286 is_ok = is_ok or sts
1287 1287 except KeyboardInterrupt:
1288 1288 is_ok = False
1289 1289 break
1290 1290 except ValueError, e:
1291 1291 sleep(0.5)
1292 1292 self.__handleError(procUnitConfObj, send_email=True)
1293 1293 is_ok = False
1294 1294 break
1295 1295 except:
1296 1296 sleep(0.5)
1297 1297 self.__handleError(procUnitConfObj)
1298 1298 is_ok = False
1299 1299 break
1300 1300
1301 1301 #If every process unit finished so end process
1302 1302 if not(is_ok):
1303 1303 # print "Every process unit have finished"
1304 1304 break
1305 1305
1306 1306 if not self.runController():
1307 1307 break
1308 1308
1309 1309 #Closing every process
1310 1310 for procKey in keyList:
1311 1311 procUnitConfObj = self.procUnitConfObjDict[procKey]
1312 1312 procUnitConfObj.close()
1313 1313
1314 1314 print "Process finished"
1315 1315
1316 def start(self):
1316 def start(self, filename=None):
1317 1317
1318 self.writeXml()
1318 self.writeXml(filename)
1319 1319 self.createObjects()
1320 1320 self.connectObjects()
1321 1321 self.run()
@@ -1,49 +1,53
1 1 '''
2 2 Created on Jul 16, 2014
3 3
4 4 @author: Miguel Urco
5 5 '''
6 6
7 7 from schainpy import __version__
8 8 from setuptools import setup, Extension
9 9
10 10 setup(name="schainpy",
11 11 version=__version__,
12 12 description="Python tools to read, write and process Jicamarca data",
13 13 author="Miguel Urco",
14 14 author_email="miguel.urco@jro.igp.gob.pe",
15 15 url="http://jro.igp.gob.pe",
16 16 packages = {'schainpy',
17 17 'schainpy.model',
18 18 'schainpy.model.data',
19 19 'schainpy.model.graphics',
20 20 'schainpy.model.io',
21 21 'schainpy.model.proc',
22 22 'schainpy.model.serializer',
23 23 'schainpy.model.utils',
24 24 'schainpy.gui',
25 25 'schainpy.gui.figures',
26 26 'schainpy.gui.viewcontroller',
27 27 'schainpy.gui.viewer',
28 28 'schainpy.gui.viewer.windows'},
29 29 ext_package='schainpy',
30 30 py_modules=[''],
31 31 package_data={'': ['schain.conf.template'],
32 32 'schainpy.gui.figures': ['*.png','*.jpg'],
33 33 },
34 34 include_package_data=False,
35 scripts =['schainpy/gui/schainGUI',
36 'schainpy/scripts/schain'],
35 entry_points={
36 'console_scripts': [
37 'schain = schaincli.schaincli.cli:main',
38 ],
39 },
40 scripts =['schainpy/gui/schainGUI'],
37 41 ext_modules=[Extension("cSchain", ["schainpy/model/proc/extensions.c"])],
38 42 install_requires=[
39 43 "scipy >= 0.14.0",
40 44 "h5py >= 2.2.1",
41 45 "matplotlib >= 1.4.2",
42 46 "pyfits >= 3.4",
43 47 "numpy >= 1.11.2",
44 48 "paramiko >= 2.1.2",
45 49 "paho-mqtt >= 1.2",
46 50 "zmq",
47 51 "fuzzywuzzy"
48 52 ],
49 53 )
General Comments 0
You need to be logged in to leave comments. Login now