##// END OF EJS Templates
nextcommand y command
José Chávez -
r936:e1464a5292b7
parent child
Show More
@@ -0,0 +1,34
1 from schainpy.controller import Project
2
3 desc = "asdasddsad"
4
5 controller = Project()
6 controller.setup(id='191', name="asdasd", description=desc)
7
8 readUnitConf = controller.addReadUnit(datatype='VoltageReader',
9 path="/home/nanosat/schain/schain-cli",
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/schain-cli/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()
@@ -0,0 +1,33
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/scripts",
10 startDate="1970/01/01",
11 endDate="2017/12/31",
12 startTime="00:00:00",
13 endTime="23:59:59",
14 online=0,
15 walk=1,
16 )
17
18 procUnitConf1 = controller.addProcUnit(datatype='VoltageProc', inputId=readUnitConf.getId())
19
20 opObj11 = procUnitConf1.addOperation(name='ProfileSelector', optype='other')
21 opObj11.addParameter(name='profileRangeList', value='120,183', format='intlist')
22
23 opObj11 = procUnitConf1.addOperation(name='RTIPlot', optype='other')
24 opObj11.addParameter(name='wintitle', value='Jicamarca Radio Observatory', format='str')
25 opObj11.addParameter(name='showprofile', value='0', format='int')
26 opObj11.addParameter(name='xmin', value='0', format='int')
27 opObj11.addParameter(name='xmax', value='24', format='int')
28 opObj11.addParameter(name='figpath', value="/home/nanosat/schain/schainpy/scripts/figs", format='str')
29 opObj11.addParameter(name='wr_period', value='5', format='int')
30 opObj11.addParameter(name='exp_code', value='22', format='int')
31
32
33 controller.start()
@@ -1,1 +1,1
1 <Project description="A schain project" id="191" name="project"><ReadUnit datatype="VoltageReader" id="1911" inputId="0" name="VoltageReader"><Operation id="19111" name="run" priority="1" type="self"><Parameter format="str" id="191111" name="datatype" value="VoltageReader" /><Parameter format="str" id="191112" name="path" value="/home/nanosat/schain/schain-cli" /><Parameter format="date" id="191113" name="startDate" value="1970/01/01" /><Parameter format="date" id="191114" name="endDate" value="2017/12/31" /><Parameter format="time" id="191115" name="startTime" value="00:00:00" /><Parameter format="time" id="191116" name="endTime" value="23:59:59" /><Parameter format="int" id="191118" name="online" value="0" /><Parameter format="int" id="191119" name="walk" value="1" /></Operation></ReadUnit><ProcUnit datatype="SpectraProc" id="1912" inputId="1911" name="SpectraProc"><Operation id="19121" name="run" priority="1" type="self" /><Operation id="19122" name="ProfileSelector" priority="2" type="other"><Parameter format="intlist" id="191221" name="profileRangeList" value="120,183" /></Operation><Operation id="19123" name="RTIPlot" priority="3" type="other"><Parameter format="int" id="191231" name="id" value="101" /><Parameter format="str" id="191232" name="wintitle" value="Jicamarca Radio Observatory" /><Parameter format="int" id="191233" name="showprofile" value="0" /><Parameter format="int" id="191234" name="xmin" value="0" /><Parameter format="int" id="191235" name="xmax" value="24" /><Parameter format="str" id="191236" name="figpath" value="/home/nanosat/schain/schain-cli/figs" /><Parameter format="int" id="191237" name="wr_period" value="5" /><Parameter format="int" id="191238" name="exp_code" value="22" /></Operation></ProcUnit></Project> No newline at end of file
1 <Project description="A schain project" id="191" name="project"><ReadUnit datatype="SpectraReader" id="1911" inputId="0" name="SpectraReader"><Operation id="19111" name="run" priority="1" type="self"><Parameter format="str" id="191111" name="datatype" value="SpectraReader" /><Parameter format="str" id="191112" name="path" value="/home/nanosat/schain/schain-cli" /><Parameter format="date" id="191113" name="startDate" value="1970/01/01" /><Parameter format="date" id="191114" name="endDate" value="1970/01/01" /><Parameter format="time" id="191115" name="startTime" value="00:00:00" /><Parameter format="time" id="191116" name="endTime" value="23:59:59" /><Parameter format="int" id="191118" name="cursor" value="0" /><Parameter format="int" id="191119" name="skip" value="0" /><Parameter format="int" id="191120" name="walk" value="1" /><Parameter format="int" id="191121" name="verbose" value="1" /><Parameter format="int" id="191122" name="online" value="0" /></Operation></ReadUnit><ProcUnit datatype="ParametersProc" id="1913" inputId="1911" name="ParametersProc"><Operation id="19131" name="run" priority="1" type="self" /><Operation id="19132" name="SpectralMoments" priority="2" type="other" /><Operation id="19133" name="PublishData" priority="3" type="other"><Parameter format="int" id="191331" name="zeromq" value="1" /><Parameter format="bool" id="191332" name="verbose" value="0" /></Operation></ProcUnit><ProcUnit datatype="Spectra" id="1912" inputId="1911" name="SpectraProc"><Operation id="19121" name="run" priority="1" type="self" /></ProcUnit></Project> No newline at end of file
@@ -1,61 +1,77
1 1 import click
2 2 import schainpy
3 3 import subprocess
4 4 from multiprocessing import cpu_count
5 5 from schaincli import templates
6 import os, sys
6 import os
7 import sys
8 import glob
7 9
8 10 def print_version(ctx, param, value):
9 11 if not value or ctx.resilient_parsing:
10 12 return
11 13 click.echo(schainpy.__version__)
12 14 ctx.exit()
13 15
14 16
15 17 @click.command()
16 18 @click.option('--version', '-v', is_flag=True, callback=print_version, help='SChain version', type=str)
17 @click.option('--xml', '-x', default=None, help='xml file', type=click.Path(exists=True, resolve_path=True))
19 @click.option('--xml', '-x', default=None, help='run an XML file', type=click.Path(exists=True, resolve_path=True))
18 20 @click.argument('command', default='run', required=True)
19 def main(command, version, xml):
21 @click.argument('nextcommand', default=None, required=False, type=click.Path(exists=True, resolve_path=True))
22 def main(command, nextcommand, version, xml):
20 23 """COMMAND LINE INTERFACE FOR SIGNAL CHAIN - JICAMARCA RADIO OBSERVATORY"""
21 24 if xml is not None:
22 25 subprocess.call(['schain --file=' + xml], shell=True)
23 26 elif command == 'generate':
24 27 generate()
25 28 elif command == 'test':
26 29 test()
30 elif command == 'run':
31 if nextcommand is None:
32 currentfiles = glob.glob('./*.py')
33 numberfiles = len(currentfiles)
34 print currentfiles
35 if numberfiles > 1:
36 click.echo('\x1b[6;37;41m[ERROR] - There is more than one file to run\x1b[0m')
37 elif numberfiles == 1:
38 subprocess.call(['python ' + currentfiles[0]], shell=True)
39 else:
40 click.echo('\x1b[6;37;41m[ERROR] - There is no file to run.\x1b[0m')
41 else:
42 subprocess.call(['python ' + nextcommand], shell=True)
27 43 else:
28 click.echo('\x1b[0;37;41m[ERROR] - Command is not defined.\x1b[0m')
44 click.echo('\x1b[6;37;41m[ERROR] - Command is not defined.\x1b[0m')
29 45
30 46 def basicInputs():
31 47 inputs = {}
32 48 inputs['desc'] = click.prompt('Enter a description', default="A schain project", type=str)
33 49 inputs['name'] = click.prompt('Name of the project', default="project", type=str)
34 50 inputs['path'] = click.prompt('Data path', default=os.getcwd(), type=click.Path(exists=True, resolve_path=True))
35 51 inputs['startDate'] = click.prompt('Start date', default='1970/01/01', type=str)
36 52 inputs['endDate'] = click.prompt('End date', default='2017/12/31', type=str)
37 53 inputs['startHour'] = click.prompt('Start hour', default='00:00:00', type=str)
38 54 inputs['endHour'] = click.prompt('End hour', default='23:59:59', type=str)
39 55 inputs['figpath'] = inputs['path'] + '/figs'
40 56 return inputs
41 57
42 58 def generate():
43 59 inputs = basicInputs()
44 60 inputs['multiprocess'] = click.confirm('Is this a multiprocess script?')
45 61 if inputs['multiprocess']:
46 62 inputs['nProcess'] = click.prompt('How many process?', default=cpu_count(), type=int)
47 63 current = templates.multiprocess.format(**inputs)
48 64 else:
49 65 current = templates.basic.format(**inputs)
50 66 scriptname = inputs['name'] + ".py"
51 67 script = open(scriptname, 'w')
52 68 try:
53 69 script.write(current)
54 click.echo('\x1b[0;37;42m[SUCCESS] Script {file} generated\x1b[0m'.format(file=scriptname))
70 click.echo('\x1b[6;37;42m[SUCCESS] Script {file} generated\x1b[0m'.format(file=scriptname))
55 71 except Exception as e:
56 click.echo('\x1b[0;37;41m[ERROR] I cannot create the file. Do you have writing permissions?\x1b[0m')
72 click.echo('\x1b[6;37;41m[ERROR] I cannot create the file. Do you have writing permissions?\x1b[0m')
57 73
58 74
59 75 def test():
60 76 print templates.basic.format(name='hola', desc= 'desc', path='path', startDate='0', endDate='0')
61 77 click.echo('testing')
@@ -1,75 +1,75
1 1 basic = '''from schainpy.controller import Project
2 2
3 3 desc = "{desc}"
4 4
5 5 controller = Project()
6 6 controller.setup(id='191', name="{name}", description=desc)
7 7
8 8 readUnitConf = controller.addReadUnit(datatype='VoltageReader',
9 9 path="{path}",
10 10 startDate="{startDate}",
11 11 endDate="{endDate}",
12 12 startTime="{startHour}",
13 13 endTime="{endHour}",
14 14 online=0,
15 15 verbose=1,
16 16 walk=1,
17 17 )
18 18
19 19 procUnitConf1 = controller.addProcUnit(datatype='VoltageProc', inputId=readUnitConf.getId())
20 20
21 21 opObj11 = procUnitConf1.addOperation(name='ProfileSelector', optype='other')
22 22 opObj11.addParameter(name='profileRangeList', value='120,183', format='intlist')
23 23
24 24 opObj11 = procUnitConf1.addOperation(name='RTIPlot', optype='other')
25 25 opObj11.addParameter(name='wintitle', value='Jicamarca Radio Observatory', format='str')
26 26 opObj11.addParameter(name='showprofile', value='0', format='int')
27 27 opObj11.addParameter(name='xmin', value='0', format='int')
28 28 opObj11.addParameter(name='xmax', value='24', format='int')
29 29 opObj11.addParameter(name='figpath', value="{figpath}", format='str')
30 30 opObj11.addParameter(name='wr_period', value='5', format='int')
31 31 opObj11.addParameter(name='exp_code', value='22', format='int')
32 32
33 33
34 34 controller.start()
35 35 '''
36 36
37 37 multiprocess = '''from schainpy.controller import Project, multiSchain
38 38
39 39 desc = "{desc}"
40 40
41 41 def fiber(cursor, skip, q, day):
42 42 controller = Project()
43 43 controller.setup(id='191', name="{name}", description=desc)
44 44
45 45 readUnitConf = controller.addReadUnit(datatype='SpectraReader',
46 46 path="{path}",
47 startDate="day",
48 endDate="day",
47 startDate=day,
48 endDate=day,
49 49 startTime="{startHour}",
50 50 endTime="{endHour}",
51 51 online=0,
52 52 queue=q,
53 53 cursor=cursor,
54 54 skip=skip,
55 55 verbose=1,
56 56 walk=1,
57 57 )
58 58
59 59 procUnitConf1 = controller.addProcUnit(datatype='Spectra', inputId=readUnitConf.getId())
60 60
61 61 procUnitConf2 = controller.addProcUnit(datatype='ParametersProc', inputId=readUnitConf.getId())
62 62 opObj11 = procUnitConf2.addOperation(name='SpectralMoments', optype='other')
63 63
64 64 opObj12 = procUnitConf2.addOperation(name='PublishData', optype='other')
65 65 opObj12.addParameter(name='zeromq', value=1, format='int')
66 66 opObj12.addParameter(name='verbose', value=0, format='bool')
67 67
68 68 controller.start()
69 69
70 70
71 71 if __name__ == '__main__':
72 72 multiSchain(fiber, nProcess={nProcess}, startDate="{startDate}", endDate="{endDate}")
73 73
74 74
75 75 '''
General Comments 0
You need to be logged in to leave comments. Login now