@@ -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", | |
|
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/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,1 | |||
|
1 | <Project description="A schain project" id="191" name="project"><ReadUnit datatype="Voltage" 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" /><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="walk" value="1" /><Parameter format="int" id="191119" name="verbose" value="1" /><Parameter format="int" id="191120" name="online" value="0" /></Operation></ReadUnit><ProcUnit datatype="Voltage" id="1912" inputId="1911" name="VoltageProc"><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="plotter"><Parameter format="str" id="191231" name="wintitle" value="Jicamarca Radio Observatory" /><Parameter format="int" id="191232" name="showprofile" value="0" /><Parameter format="int" id="191233" name="xmin" value="0" /><Parameter format="int" id="191234" name="xmax" value="24" /><Parameter format="str" id="191235" name="figpath" value="/home/nanosat/schain/figs" /><Parameter format="int" id="191236" name="wr_period" value="5" /><Parameter format="int" id="191237" name="exp_code" value="22" /></Operation></ProcUnit></Project> No newline at end of file |
@@ -0,0 +1,9 | |||
|
1 | # schaing | |
|
2 | ||
|
3 | Command Line Interface for SIGNAL CHAIN - jro | |
|
4 | ||
|
5 | # Usage | |
|
6 | ||
|
7 | To use it: | |
|
8 | ||
|
9 | $ schain-cli --help |
|
1 | NO CONTENT: new file 100644 |
@@ -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,188 | |||
|
1 | import click | |
|
2 | import schainpy | |
|
3 | import subprocess | |
|
4 | import os | |
|
5 | import sys | |
|
6 | import glob | |
|
7 | save_stdout = sys.stdout | |
|
8 | sys.stdout = open('trash', 'w') | |
|
9 | from multiprocessing import cpu_count | |
|
10 | from schaincli import templates | |
|
11 | from schainpy import controller_api | |
|
12 | from schainpy.model import Operation, ProcessingUnit | |
|
13 | from schainpy.utils import log | |
|
14 | from importlib import import_module | |
|
15 | from pydoc import locate | |
|
16 | from fuzzywuzzy import process | |
|
17 | sys.stdout = save_stdout | |
|
18 | ||
|
19 | ||
|
20 | def print_version(ctx, param, value): | |
|
21 | if not value or ctx.resilient_parsing: | |
|
22 | return | |
|
23 | click.echo(schainpy.__version__) | |
|
24 | ctx.exit() | |
|
25 | ||
|
26 | ||
|
27 | cliLogger = log.makelogger('schain cli') | |
|
28 | PREFIX = 'experiment' | |
|
29 | ||
|
30 | ||
|
31 | @click.command() | |
|
32 | @click.option('--version', '-v', is_flag=True, callback=print_version, help='SChain version', type=str) | |
|
33 | @click.option('--xml', '-x', default=None, help='run an XML file', type=click.Path(exists=True, resolve_path=True)) | |
|
34 | @click.argument('command', default='run', required=True) | |
|
35 | @click.argument('nextcommand', default=None, required=False, type=str) | |
|
36 | def main(command, nextcommand, version, xml): | |
|
37 | """COMMAND LINE INTERFACE FOR SIGNAL CHAIN - JICAMARCA RADIO OBSERVATORY \n | |
|
38 | Available commands.\n | |
|
39 | --xml: runs a schain XML generated file\n | |
|
40 | run: runs any python script starting 'experiment_'\n | |
|
41 | generate: generates a template schain script\n | |
|
42 | search: return avilable operations, procs or arguments of the give operation/proc\n""" | |
|
43 | if xml is not None: | |
|
44 | runFromXML(xml) | |
|
45 | elif command == 'generate': | |
|
46 | generate() | |
|
47 | elif command == 'test': | |
|
48 | test() | |
|
49 | elif command == 'run': | |
|
50 | runschain(nextcommand) | |
|
51 | elif command == 'search': | |
|
52 | search(nextcommand) | |
|
53 | else: | |
|
54 | log.error('Command {} is not defined'.format(command)) | |
|
55 | ||
|
56 | def check_module(possible, instance): | |
|
57 | def check(x): | |
|
58 | try: | |
|
59 | instancia = locate('schainpy.model.{}'.format(x)) | |
|
60 | return isinstance(instancia(), instance) | |
|
61 | except Exception as e: | |
|
62 | return False | |
|
63 | clean = clean_modules(possible) | |
|
64 | return [x for x in clean if check(x)] | |
|
65 | ||
|
66 | ||
|
67 | def clean_modules(module): | |
|
68 | noEndsUnder = [x for x in module if not x.endswith('__')] | |
|
69 | noStartUnder = [x for x in noEndsUnder if not x.startswith('__')] | |
|
70 | noFullUpper = [x for x in noStartUnder if not x.isupper()] | |
|
71 | return noFullUpper | |
|
72 | ||
|
73 | ||
|
74 | def search(nextcommand): | |
|
75 | if nextcommand is None: | |
|
76 | log.error('There is no Operation/ProcessingUnit to search') | |
|
77 | elif nextcommand == 'procs': | |
|
78 | module = dir(import_module('schainpy.model')) | |
|
79 | procs = check_module(module, ProcessingUnit) | |
|
80 | try: | |
|
81 | procs.remove('ProcessingUnit') | |
|
82 | except Exception as e: | |
|
83 | pass | |
|
84 | log.success('Current ProcessingUnits are:\n\033[1m{}\033[0m'.format('\n'.join(procs))) | |
|
85 | ||
|
86 | elif nextcommand == 'operations': | |
|
87 | module = dir(import_module('schainpy.model')) | |
|
88 | noProcs = [x for x in module if not x.endswith('Proc')] | |
|
89 | operations = check_module(noProcs, Operation) | |
|
90 | try: | |
|
91 | operations.remove('Operation') | |
|
92 | except Exception as e: | |
|
93 | pass | |
|
94 | log.success('Current Operations are:\n\033[1m{}\033[0m'.format('\n'.join(operations))) | |
|
95 | else: | |
|
96 | try: | |
|
97 | module = locate('schainpy.model.{}'.format(nextcommand)) | |
|
98 | args = module().getAllowedArgs() | |
|
99 | log.warning('Use this feature with caution. It may not return all the allowed arguments') | |
|
100 | try: | |
|
101 | args.remove('self') | |
|
102 | except Exception as e: | |
|
103 | pass | |
|
104 | try: | |
|
105 | args.remove('dataOut') | |
|
106 | except Exception as e: | |
|
107 | pass | |
|
108 | if len(args) == 0: | |
|
109 | log.success('{} has no arguments'.format(nextcommand)) | |
|
110 | else: | |
|
111 | log.success('Showing arguments of {} are:\n\033[1m{}\033[0m'.format(nextcommand, '\n'.join(args))) | |
|
112 | except Exception as e: | |
|
113 | log.error('Module {} does not exists'.format(nextcommand)) | |
|
114 | allModules = dir(import_module('schainpy.model')) | |
|
115 | module = check_module(allModules, Operation) | |
|
116 | module.extend(check_module(allModules, ProcessingUnit)) | |
|
117 | similar = process.extractOne(nextcommand, module)[0] | |
|
118 | log.success('Searching {} instead'.format(similar)) | |
|
119 | search(similar) | |
|
120 | ||
|
121 | ||
|
122 | def runschain(nextcommand): | |
|
123 | if nextcommand is None: | |
|
124 | currentfiles = glob.glob('./{}_*.py'.format(PREFIX)) | |
|
125 | numberfiles = len(currentfiles) | |
|
126 | if numberfiles > 1: | |
|
127 | log.error('There is more than one file to run') | |
|
128 | elif numberfiles == 1: | |
|
129 | subprocess.call(['python ' + currentfiles[0]], shell=True) | |
|
130 | else: | |
|
131 | log.error('There is no file to run') | |
|
132 | else: | |
|
133 | try: | |
|
134 | subprocess.call(['python ' + nextcommand], shell=True) | |
|
135 | except Exception as e: | |
|
136 | log.error("I cannot run the file. Does it exists?") | |
|
137 | ||
|
138 | ||
|
139 | def basicInputs(): | |
|
140 | inputs = {} | |
|
141 | inputs['desc'] = click.prompt('Enter a description', default="A schain project", type=str) | |
|
142 | inputs['name'] = click.prompt('Name of the project', default="project", type=str) | |
|
143 | inputs['path'] = click.prompt('Data path', default=os.getcwd(), type=click.Path(exists=True, resolve_path=True)) | |
|
144 | inputs['startDate'] = click.prompt('Start date', default='1970/01/01', type=str) | |
|
145 | inputs['endDate'] = click.prompt('End date', default='2017/12/31', type=str) | |
|
146 | inputs['startHour'] = click.prompt('Start hour', default='00:00:00', type=str) | |
|
147 | inputs['endHour'] = click.prompt('End hour', default='23:59:59', type=str) | |
|
148 | inputs['figpath'] = inputs['path'] + '/figs' | |
|
149 | return inputs | |
|
150 | ||
|
151 | ||
|
152 | def generate(): | |
|
153 | inputs = basicInputs() | |
|
154 | inputs['multiprocess'] = click.confirm('Is this a multiprocess script?') | |
|
155 | if inputs['multiprocess']: | |
|
156 | inputs['nProcess'] = click.prompt('How many process?', default=cpu_count(), type=int) | |
|
157 | current = templates.multiprocess.format(**inputs) | |
|
158 | else: | |
|
159 | current = templates.basic.format(**inputs) | |
|
160 | scriptname = '{}_{}.py'.format(PREFIX, inputs['name']) | |
|
161 | script = open(scriptname, 'w') | |
|
162 | try: | |
|
163 | script.write(current) | |
|
164 | log.success('Script {} generated'.format(scriptname)) | |
|
165 | except Exception as e: | |
|
166 | log.error('I cannot create the file. Do you have writing permissions?') | |
|
167 | ||
|
168 | ||
|
169 | def test(): | |
|
170 | log.warning('testing') | |
|
171 | ||
|
172 | ||
|
173 | def runFromXML(filename): | |
|
174 | controller = controller_api.ControllerThread() | |
|
175 | if not controller.readXml(filename): | |
|
176 | return | |
|
177 | ||
|
178 | plotterObj = controller.useExternalPlotter() | |
|
179 | ||
|
180 | controller.start() | |
|
181 | plotterObj.start() | |
|
182 | ||
|
183 | cliLogger("Finishing all processes") | |
|
184 | ||
|
185 | controller.join(5) | |
|
186 | ||
|
187 | cliLogger("End of script") | |
|
188 | return |
@@ -0,0 +1,75 | |||
|
1 | basic = '''from schainpy.controller import Project | |
|
2 | ||
|
3 | desc = "{desc}" | |
|
4 | ||
|
5 | controller = Project() | |
|
6 | controller.setup(id='191', name="{name}", description=desc) | |
|
7 | ||
|
8 | readUnitConf = controller.addReadUnit(datatype='VoltageReader', | |
|
9 | path="{path}", | |
|
10 | startDate="{startDate}", | |
|
11 | endDate="{endDate}", | |
|
12 | startTime="{startHour}", | |
|
13 | endTime="{endHour}", | |
|
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="{figpath}", 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() | |
|
35 | ''' | |
|
36 | ||
|
37 | multiprocess = '''from schainpy.controller import Project, multiSchain | |
|
38 | ||
|
39 | desc = "{desc}" | |
|
40 | ||
|
41 | def fiber(cursor, skip, q, day): | |
|
42 | controller = Project() | |
|
43 | controller.setup(id='191', name="{name}", description=desc) | |
|
44 | ||
|
45 | readUnitConf = controller.addReadUnit(datatype='SpectraReader', | |
|
46 | path="{path}", | |
|
47 | startDate=day, | |
|
48 | endDate=day, | |
|
49 | startTime="{startHour}", | |
|
50 | endTime="{endHour}", | |
|
51 | online=0, | |
|
52 | queue=q, | |
|
53 | cursor=cursor, | |
|
54 | skip=skip, | |
|
55 | verbose=1, | |
|
56 | walk=1, | |
|
57 | ) | |
|
58 | ||
|
59 | procUnitConf1 = controller.addProcUnit(datatype='Spectra', inputId=readUnitConf.getId()) | |
|
60 | ||
|
61 | procUnitConf2 = controller.addProcUnit(datatype='ParametersProc', inputId=readUnitConf.getId()) | |
|
62 | opObj11 = procUnitConf2.addOperation(name='SpectralMoments', optype='other') | |
|
63 | ||
|
64 | opObj12 = procUnitConf2.addOperation(name='PublishData', optype='other') | |
|
65 | opObj12.addParameter(name='zeromq', value=1, format='int') | |
|
66 | opObj12.addParameter(name='verbose', value=0, format='bool') | |
|
67 | ||
|
68 | controller.start() | |
|
69 | ||
|
70 | ||
|
71 | if __name__ == '__main__': | |
|
72 | multiSchain(fiber, nProcess={nProcess}, startDate="{startDate}", endDate="{endDate}") | |
|
73 | ||
|
74 | ||
|
75 | ''' |
@@ -0,0 +1,1 | |||
|
1 |
@@ -0,0 +1,29 | |||
|
1 | import pytest | |
|
2 | from click.testing import CliRunner | |
|
3 | from schaincli import cli | |
|
4 | ||
|
5 | ||
|
6 | @pytest.fixture | |
|
7 | def runner(): | |
|
8 | return CliRunner() | |
|
9 | ||
|
10 | ||
|
11 | def test_cli(runner): | |
|
12 | result = runner.invoke(cli.main) | |
|
13 | assert result.exit_code == 0 | |
|
14 | assert not result.exception | |
|
15 | assert result.output.strip() == 'Hello, world.' | |
|
16 | ||
|
17 | ||
|
18 | def test_cli_with_option(runner): | |
|
19 | result = runner.invoke(cli.main, ['--as-cowboy']) | |
|
20 | assert not result.exception | |
|
21 | assert result.exit_code == 0 | |
|
22 | assert result.output.strip() == 'Howdy, world.' | |
|
23 | ||
|
24 | ||
|
25 | def test_cli_with_arg(runner): | |
|
26 | result = runner.invoke(cli.main, ['Jicamarca']) | |
|
27 | assert result.exit_code == 0 | |
|
28 | assert not result.exception | |
|
29 | assert result.output.strip() == 'Hello, Jicamarca.' |
@@ -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() |
@@ -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 | NO CONTENT: new file 100644 |
@@ -0,0 +1,45 | |||
|
1 | """. | |
|
2 | SCHAINPY - LOG | |
|
3 | Simple helper for log standarization | |
|
4 | Usage: | |
|
5 | from schainpy.utils import log | |
|
6 | log.error('A kitten died beacuse of you') | |
|
7 | log.warning('You are doing it wrong but what the heck, I'll allow it) | |
|
8 | log.succes('YOU ROCK!') | |
|
9 | To create your own logger inside your class do it like this: | |
|
10 | from schainpy.utils import log | |
|
11 | awesomeLogger = log.makelogger("never gonna", bg="red", fg="white") | |
|
12 | awesomeLogger('give you up') | |
|
13 | which will look like this: | |
|
14 | [NEVER GONNA] - give you up | |
|
15 | with color red as background and white as foreground. | |
|
16 | """ | |
|
17 | ||
|
18 | import click | |
|
19 | ||
|
20 | ||
|
21 | def warning(message): | |
|
22 | click.echo(click.style('[WARNING] - ' + message, fg='yellow')) | |
|
23 | pass | |
|
24 | ||
|
25 | ||
|
26 | def error(message): | |
|
27 | click.echo(click.style('[ERROR] - ' + message, fg='red')) | |
|
28 | pass | |
|
29 | ||
|
30 | ||
|
31 | def success(message): | |
|
32 | click.echo(click.style(message, fg='green')) | |
|
33 | pass | |
|
34 | ||
|
35 | ||
|
36 | def log(message): | |
|
37 | click.echo('[LOG] - ' + message) | |
|
38 | pass | |
|
39 | ||
|
40 | ||
|
41 | def makelogger(topic, bg='reset', fg='reset'): | |
|
42 | def func(message): | |
|
43 | click.echo(click.style('[{}] - '.format(topic.upper()) + message, | |
|
44 | bg=bg, fg=fg)) | |
|
45 | return func |
@@ -0,0 +1,1 | |||
|
1 | You should install "digital_rf_hdf5" module if you want to read USRP data |
@@ -1313,9 +1313,9 class Project(): | |||
|
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() |
@@ -5,175 +5,175 from schainpy.controller import Project | |||
|
5 | 5 | from schainpy.model.graphics.jroplotter import PlotManager |
|
6 | 6 | |
|
7 | 7 | class ControllerThread(threading.Thread, Project): |
|
8 | ||
|
8 | ||
|
9 | 9 | def __init__(self, plotter_queue=None): |
|
10 | ||
|
10 | ||
|
11 | 11 | threading.Thread.__init__(self) |
|
12 | 12 | Project.__init__(self, plotter_queue) |
|
13 | ||
|
13 | ||
|
14 | 14 | self.setDaemon(True) |
|
15 | ||
|
15 | ||
|
16 | 16 | self.lock = threading.Lock() |
|
17 | 17 | self.control = {'stop':False, 'pause':False} |
|
18 | ||
|
18 | ||
|
19 | 19 | def __del__(self): |
|
20 | ||
|
20 | ||
|
21 | 21 | self.control['stop'] = True |
|
22 | ||
|
22 | ||
|
23 | 23 | def stop(self): |
|
24 | ||
|
24 | ||
|
25 | 25 | self.lock.acquire() |
|
26 | ||
|
26 | ||
|
27 | 27 | self.control['stop'] = True |
|
28 | ||
|
28 | ||
|
29 | 29 | self.lock.release() |
|
30 | ||
|
30 | ||
|
31 | 31 | def pause(self): |
|
32 | ||
|
32 | ||
|
33 | 33 | self.lock.acquire() |
|
34 | ||
|
34 | ||
|
35 | 35 | self.control['pause'] = not(self.control['pause']) |
|
36 | 36 | paused = self.control['pause'] |
|
37 | ||
|
37 | ||
|
38 | 38 | self.lock.release() |
|
39 | ||
|
39 | ||
|
40 | 40 | return paused |
|
41 | ||
|
41 | ||
|
42 | 42 | def isPaused(self): |
|
43 | ||
|
43 | ||
|
44 | 44 | self.lock.acquire() |
|
45 | 45 | paused = self.control['pause'] |
|
46 | 46 | self.lock.release() |
|
47 | ||
|
47 | ||
|
48 | 48 | return paused |
|
49 | ||
|
49 | ||
|
50 | 50 | def isStopped(self): |
|
51 | ||
|
51 | ||
|
52 | 52 | self.lock.acquire() |
|
53 | 53 | stopped = self.control['stop'] |
|
54 | 54 | self.lock.release() |
|
55 | ||
|
55 | ||
|
56 | 56 | return stopped |
|
57 | ||
|
57 | ||
|
58 | 58 | def run(self): |
|
59 | 59 | self.control['stop'] = False |
|
60 | 60 | self.control['pause'] = False |
|
61 | ||
|
61 | ||
|
62 | 62 | self.writeXml() |
|
63 | ||
|
63 | ||
|
64 | 64 | self.createObjects() |
|
65 | 65 | self.connectObjects() |
|
66 | 66 | Project.run(self) |
|
67 | ||
|
67 | ||
|
68 | 68 | def isRunning(self): |
|
69 | ||
|
69 | ||
|
70 | 70 | return self.is_alive() |
|
71 | ||
|
71 | ||
|
72 | 72 | def isFinished(self): |
|
73 | ||
|
73 | ||
|
74 | 74 | return not self.is_alive() |
|
75 | 75 | |
|
76 | 76 | def setPlotters(self): |
|
77 | ||
|
77 | ||
|
78 | 78 | plotterList = PlotManager.plotterList |
|
79 | ||
|
79 | ||
|
80 | 80 | for thisPUConfObj in self.procUnitConfObjDict.values(): |
|
81 | ||
|
81 | ||
|
82 | 82 | inputId = thisPUConfObj.getInputId() |
|
83 | ||
|
83 | ||
|
84 | 84 | if int(inputId) == 0: |
|
85 | 85 | continue |
|
86 | ||
|
86 | ||
|
87 | 87 | for thisOpObj in thisPUConfObj.getOperationObjList(): |
|
88 | ||
|
88 | ||
|
89 | 89 | if thisOpObj.type == "self": |
|
90 | 90 | continue |
|
91 | ||
|
91 | ||
|
92 | 92 | if thisOpObj.name in plotterList: |
|
93 | 93 | thisOpObj.type = "plotter" |
|
94 | 94 | |
|
95 | 95 | def setPlotterQueue(self, plotter_queue): |
|
96 | ||
|
96 | ||
|
97 | 97 | self.plotterQueue = plotter_queue |
|
98 | ||
|
98 | ||
|
99 | 99 | def getPlotterQueue(self): |
|
100 | ||
|
100 | ||
|
101 | 101 | return self.plotterQueue |
|
102 | 102 | |
|
103 | 103 | def useExternalPlotter(self): |
|
104 | ||
|
104 | ||
|
105 | 105 | self.plotterQueue = Queue(10) |
|
106 | 106 | self.setPlotters() |
|
107 | ||
|
107 | ||
|
108 | 108 | plotManagerObj = PlotManager(self.plotterQueue) |
|
109 | 109 | plotManagerObj.setController(self) |
|
110 | ||
|
110 | ||
|
111 | 111 | return plotManagerObj |
|
112 | ||
|
112 | ||
|
113 | 113 | # from PyQt4 import QtCore |
|
114 | 114 | # from PyQt4.QtCore import SIGNAL |
|
115 |
# |
|
|
115 | # | |
|
116 | 116 | # class ControllerQThread(QtCore.QThread, Project): |
|
117 | # | |
|
117 | # | |
|
118 | 118 | # def __init__(self, filename): |
|
119 | # | |
|
119 | # | |
|
120 | 120 | # QtCore.QThread.__init__(self) |
|
121 | 121 | # Project.__init__(self) |
|
122 | # | |
|
122 | # | |
|
123 | 123 | # self.filename = filename |
|
124 | # | |
|
124 | # | |
|
125 | 125 | # self.lock = threading.Lock() |
|
126 | 126 | # self.control = {'stop':False, 'pause':False} |
|
127 | # | |
|
127 | # | |
|
128 | 128 | # def __del__(self): |
|
129 | # | |
|
129 | # | |
|
130 | 130 | # self.control['stop'] = True |
|
131 | 131 | # self.wait() |
|
132 | # | |
|
132 | # | |
|
133 | 133 | # def stop(self): |
|
134 | # | |
|
134 | # | |
|
135 | 135 | # self.lock.acquire() |
|
136 | # | |
|
136 | # | |
|
137 | 137 | # self.control['stop'] = True |
|
138 | # | |
|
138 | # | |
|
139 | 139 | # self.lock.release() |
|
140 | # | |
|
140 | # | |
|
141 | 141 | # def pause(self): |
|
142 | # | |
|
142 | # | |
|
143 | 143 | # self.lock.acquire() |
|
144 | # | |
|
144 | # | |
|
145 | 145 | # self.control['pause'] = not(self.control['pause']) |
|
146 | 146 | # paused = self.control['pause'] |
|
147 | # | |
|
147 | # | |
|
148 | 148 | # self.lock.release() |
|
149 | # | |
|
149 | # | |
|
150 | 150 | # return paused |
|
151 | # | |
|
151 | # | |
|
152 | 152 | # def isPaused(self): |
|
153 | # | |
|
153 | # | |
|
154 | 154 | # self.lock.acquire() |
|
155 | 155 | # paused = self.control['pause'] |
|
156 | 156 | # self.lock.release() |
|
157 | # | |
|
157 | # | |
|
158 | 158 | # return paused |
|
159 | # | |
|
159 | # | |
|
160 | 160 | # def isStopped(self): |
|
161 | # | |
|
161 | # | |
|
162 | 162 | # self.lock.acquire() |
|
163 | 163 | # stopped = self.control['stop'] |
|
164 | 164 | # self.lock.release() |
|
165 | # | |
|
165 | # | |
|
166 | 166 | # return stopped |
|
167 | # | |
|
167 | # | |
|
168 | 168 | # def run(self): |
|
169 | # | |
|
169 | # | |
|
170 | 170 | # self.control['stop'] = False |
|
171 | 171 | # self.control['pause'] = False |
|
172 | # | |
|
172 | # | |
|
173 | 173 | # self.readXml(self.filename) |
|
174 | 174 | # self.createObjects() |
|
175 | 175 | # self.connectObjects() |
|
176 | 176 | # self.emit( SIGNAL( "jobStarted( PyQt_PyObject )" ), 1) |
|
177 | 177 | # Project.run(self) |
|
178 | 178 | # self.emit( SIGNAL( "jobFinished( PyQt_PyObject )" ), 1) |
|
179 | # No newline at end of file | |
|
179 | # |
@@ -9,6 +9,7 import glob | |||
|
9 | 9 | import time |
|
10 | 10 | import numpy |
|
11 | 11 | import fnmatch |
|
12 | import inspect | |
|
12 | 13 | import time, datetime |
|
13 | 14 | #import h5py |
|
14 | 15 | import traceback |
@@ -536,6 +537,9 class JRODataIO: | |||
|
536 | 537 | |
|
537 | 538 | return dtype_width |
|
538 | 539 | |
|
540 | def getAllowedArgs(self): | |
|
541 | return inspect.getargspec(self.run).args | |
|
542 | ||
|
539 | 543 | class JRODataReader(JRODataIO): |
|
540 | 544 | |
|
541 | 545 | |
@@ -1432,12 +1436,52 class JRODataReader(JRODataIO): | |||
|
1432 | 1436 | self.__printInfo = False |
|
1433 | 1437 | |
|
1434 | 1438 | |
|
1435 |
def run(self, |
|
|
1439 | def run(self, | |
|
1440 | path=None, | |
|
1441 | startDate=None, | |
|
1442 | endDate=None, | |
|
1443 | startTime=datetime.time(0,0,0), | |
|
1444 | endTime=datetime.time(23,59,59), | |
|
1445 | set=None, | |
|
1446 | expLabel = "", | |
|
1447 | ext = None, | |
|
1448 | online = False, | |
|
1449 | delay = 60, | |
|
1450 | walk = True, | |
|
1451 | getblock = False, | |
|
1452 | nTxs = 1, | |
|
1453 | realtime=False, | |
|
1454 | blocksize=None, | |
|
1455 | blocktime=None, | |
|
1456 | queue=None, | |
|
1457 | skip=None, | |
|
1458 | cursor=None, | |
|
1459 | warnings=True, | |
|
1460 | verbose=True, **kwargs): | |
|
1436 | 1461 | |
|
1437 | 1462 | if not(self.isConfig): |
|
1438 | ||
|
1439 | 1463 | # self.dataOut = dataOut |
|
1440 |
self.setup( |
|
|
1464 | self.setup( path=path, | |
|
1465 | startDate=startDate, | |
|
1466 | endDate=endDate, | |
|
1467 | startTime=startTime, | |
|
1468 | endTime=endTime, | |
|
1469 | set=set, | |
|
1470 | expLabel=expLabel, | |
|
1471 | ext=ext, | |
|
1472 | online=online, | |
|
1473 | delay=delay, | |
|
1474 | walk=walk, | |
|
1475 | getblock=getblock, | |
|
1476 | nTxs=nTxs, | |
|
1477 | realtime=realtime, | |
|
1478 | blocksize=blocksize, | |
|
1479 | blocktime=blocktime, | |
|
1480 | queue=queue, | |
|
1481 | skip=skip, | |
|
1482 | cursor=cursor, | |
|
1483 | warnings=warnings, | |
|
1484 | verbose=verbose) | |
|
1441 | 1485 | self.isConfig = True |
|
1442 | 1486 | |
|
1443 | 1487 | self.getData() |
@@ -1740,11 +1784,11 class JRODataWriter(JRODataIO): | |||
|
1740 | 1784 | |
|
1741 | 1785 | return 1 |
|
1742 | 1786 | |
|
1743 | def run(self, dataOut, **kwargs): | |
|
1787 | def run(self, dataOut, path, blocksPerFile, profilesPerBlock=64, set=None, ext=None, datatype=4, **kwargs): | |
|
1744 | 1788 | |
|
1745 | 1789 | if not(self.isConfig): |
|
1746 | 1790 | |
|
1747 | self.setup(dataOut, **kwargs) | |
|
1791 | self.setup(dataOut, path, blocksPerFile, profilesPerBlock=profilesPerBlock, set=set, ext=ext, datatype=datatype, **kwargs) | |
|
1748 | 1792 | self.isConfig = True |
|
1749 | 1793 | |
|
1750 | 1794 | self.putData() |
@@ -1,1 +1,1 | |||
|
1 |
<Project description="HF_EXAMPLE" id="191" name="test01"><ReadUnit datatype="Spectra |
|
|
1 | <Project description="HF_EXAMPLE" id="191" name="test01"><ReadUnit datatype="Spectra" 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/data/sp1_f0" /><Parameter format="date" id="191113" name="startDate" value="2017/01/28" /><Parameter format="date" id="191114" name="endDate" value="2017/01/28" /><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="5" /><Parameter format="int" id="191119" name="skip" value="177" /><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="Parameters" 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" /><Parameter format="int" id="191333" name="delay" 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,49 +1,57 | |||
|
1 | ''' | |
|
1 | """. | |
|
2 | ||
|
2 | 3 | Created on Jul 16, 2014 |
|
3 | 4 | |
|
4 | 5 | @author: Miguel Urco |
|
5 | ''' | |
|
6 | """ | |
|
6 | 7 | |
|
7 | 8 | from schainpy import __version__ |
|
8 | 9 | from setuptools import setup, Extension |
|
9 | 10 | |
|
10 | 11 | setup(name="schainpy", |
|
11 |
|
|
|
12 |
|
|
|
13 |
|
|
|
14 |
|
|
|
15 |
|
|
|
16 |
|
|
|
17 |
|
|
|
18 |
|
|
|
19 |
|
|
|
20 |
|
|
|
21 |
|
|
|
22 |
|
|
|
23 |
|
|
|
24 |
|
|
|
25 |
|
|
|
26 |
|
|
|
27 |
|
|
|
28 |
|
|
|
29 |
|
|
|
30 |
|
|
|
31 |
|
|
|
32 |
|
|
|
33 |
|
|
|
34 |
|
|
|
35 | scripts =['schainpy/gui/schainGUI', | |
|
36 | 'schainpy/scripts/schain'], | |
|
37 | ext_modules=[Extension("cSchain", ["schainpy/model/proc/extensions.c"])], | |
|
38 | install_requires=[ | |
|
39 | "scipy >= 0.14.0", | |
|
40 | "h5py >= 2.2.1", | |
|
41 | "matplotlib >= 1.4.2", | |
|
42 | "pyfits >= 3.4", | |
|
43 |
|
|
|
44 |
|
|
|
45 |
|
|
|
46 |
|
|
|
47 |
|
|
|
48 |
|
|
|
12 | version=__version__, | |
|
13 | description="Python tools to read, write and process Jicamarca data", | |
|
14 | author="Miguel Urco", | |
|
15 | author_email="miguel.urco@jro.igp.gob.pe", | |
|
16 | url="http://jro.igp.gob.pe", | |
|
17 | packages={'schainpy', | |
|
18 | 'schainpy.model', | |
|
19 | 'schainpy.model.data', | |
|
20 | 'schainpy.model.graphics', | |
|
21 | 'schainpy.model.io', | |
|
22 | 'schainpy.model.proc', | |
|
23 | 'schainpy.model.serializer', | |
|
24 | 'schainpy.model.utils', | |
|
25 | 'schainpy.gui', | |
|
26 | 'schainpy.gui.figures', | |
|
27 | 'schainpy.gui.viewcontroller', | |
|
28 | 'schainpy.gui.viewer', | |
|
29 | 'schainpy.gui.viewer.windows'}, | |
|
30 | ext_package='schainpy', | |
|
31 | py_modules=[''], | |
|
32 | package_data={'': ['schain.conf.template'], | |
|
33 | 'schainpy.gui.figures': ['*.png', '*.jpg'], | |
|
34 | }, | |
|
35 | include_package_data=False, | |
|
36 | entry_points={ | |
|
37 | 'console_scripts': [ | |
|
38 | 'schain = schaincli.cli:main', | |
|
39 | ], | |
|
40 | }, | |
|
41 | scripts=['schainpy/gui/schainGUI'], | |
|
42 | ext_modules=[Extension("cSchain", ["schainpy/model/proc/extensions.c"])], | |
|
43 | install_requires=[ | |
|
44 | "scipy >= 0.14.0", | |
|
45 | "h5py >= 2.2.1", | |
|
46 | "matplotlib >= 1.4.2", | |
|
47 | "pyfits >= 3.4", | |
|
48 | "numpy >= 1.11.2", | |
|
49 | "paramiko >= 2.1.2", | |
|
50 | "paho-mqtt >= 1.2", | |
|
51 | "zmq", | |
|
52 | "fuzzywuzzy", | |
|
53 | "click", | |
|
54 | "colorama", | |
|
55 | "python-Levenshtein" | |
|
56 | ], | |
|
49 | 57 | ) |
General Comments 0
You need to be logged in to leave comments.
Login now