@@ -1,98 +1,98 | |||||
1 | import click |
|
1 | import click | |
2 | import schainpy |
|
2 | import schainpy | |
3 | import subprocess |
|
3 | import subprocess | |
4 | from multiprocessing import cpu_count |
|
4 | from multiprocessing import cpu_count | |
5 |
from schaincli |
|
5 | from schaincli import templates | |
6 | from schainpy import controller_api |
|
6 | from schainpy import controller_api | |
7 | import os |
|
7 | import os | |
8 | import sys |
|
8 | import sys | |
9 | import glob |
|
9 | import glob | |
10 |
|
10 | |||
11 | def print_version(ctx, param, value): |
|
11 | def print_version(ctx, param, value): | |
12 | if not value or ctx.resilient_parsing: |
|
12 | if not value or ctx.resilient_parsing: | |
13 | return |
|
13 | return | |
14 | click.echo(schainpy.__version__) |
|
14 | click.echo(schainpy.__version__) | |
15 | ctx.exit() |
|
15 | ctx.exit() | |
16 |
|
16 | |||
17 |
|
17 | |||
18 | @click.command() |
|
18 | @click.command() | |
19 | @click.option('--version', '-v', is_flag=True, callback=print_version, help='SChain version', type=str) |
|
19 | @click.option('--version', '-v', is_flag=True, callback=print_version, help='SChain version', type=str) | |
20 | @click.option('--xml', '-x', default=None, help='run an XML file', type=click.Path(exists=True, resolve_path=True)) |
|
20 | @click.option('--xml', '-x', default=None, help='run an XML file', type=click.Path(exists=True, resolve_path=True)) | |
21 | @click.argument('command', default='run', required=True) |
|
21 | @click.argument('command', default='run', required=True) | |
22 | @click.argument('nextcommand', default=None, required=False, type=click.Path(exists=True, resolve_path=True)) |
|
22 | @click.argument('nextcommand', default=None, required=False, type=click.Path(exists=True, resolve_path=True)) | |
23 | def main(command, nextcommand, version, xml): |
|
23 | def main(command, nextcommand, version, xml): | |
24 | """COMMAND LINE INTERFACE FOR SIGNAL CHAIN - JICAMARCA RADIO OBSERVATORY""" |
|
24 | """COMMAND LINE INTERFACE FOR SIGNAL CHAIN - JICAMARCA RADIO OBSERVATORY""" | |
25 | if xml is not None: |
|
25 | if xml is not None: | |
26 | runFromXML(xml) |
|
26 | runFromXML(xml) | |
27 | elif command == 'generate': |
|
27 | elif command == 'generate': | |
28 | generate() |
|
28 | generate() | |
29 | elif command == 'test': |
|
29 | elif command == 'test': | |
30 | test() |
|
30 | test() | |
31 | elif command == 'run': |
|
31 | elif command == 'run': | |
32 | if nextcommand is None: |
|
32 | if nextcommand is None: | |
33 | currentfiles = glob.glob('./*.py') |
|
33 | currentfiles = glob.glob('./*.py') | |
34 | numberfiles = len(currentfiles) |
|
34 | numberfiles = len(currentfiles) | |
35 | print currentfiles |
|
35 | print currentfiles | |
36 | if numberfiles > 1: |
|
36 | if numberfiles > 1: | |
37 | click.echo('\x1b[6;37;41m[ERROR] - There is more than one file to run\x1b[0m') |
|
37 | click.echo('\x1b[6;37;41m[ERROR] - There is more than one file to run\x1b[0m') | |
38 | elif numberfiles == 1: |
|
38 | elif numberfiles == 1: | |
39 | subprocess.call(['python ' + currentfiles[0]], shell=True) |
|
39 | subprocess.call(['python ' + currentfiles[0]], shell=True) | |
40 | else: |
|
40 | else: | |
41 | click.echo('\x1b[6;37;41m[ERROR] - There is no file to run.\x1b[0m') |
|
41 | click.echo('\x1b[6;37;41m[ERROR] - There is no file to run.\x1b[0m') | |
42 | else: |
|
42 | else: | |
43 | subprocess.call(['python ' + nextcommand], shell=True) |
|
43 | subprocess.call(['python ' + nextcommand], shell=True) | |
44 | else: |
|
44 | else: | |
45 | click.echo('\x1b[6;37;41m[ERROR] - Command is not defined.\x1b[0m') |
|
45 | click.echo('\x1b[6;37;41m[ERROR] - Command is not defined.\x1b[0m') | |
46 |
|
46 | |||
47 |
|
47 | |||
48 | def basicInputs(): |
|
48 | def basicInputs(): | |
49 | inputs = {} |
|
49 | inputs = {} | |
50 | inputs['desc'] = click.prompt('Enter a description', default="A schain project", type=str) |
|
50 | inputs['desc'] = click.prompt('Enter a description', default="A schain project", type=str) | |
51 | inputs['name'] = click.prompt('Name of the project', default="project", type=str) |
|
51 | inputs['name'] = click.prompt('Name of the project', default="project", type=str) | |
52 | inputs['path'] = click.prompt('Data path', default=os.getcwd(), type=click.Path(exists=True, resolve_path=True)) |
|
52 | inputs['path'] = click.prompt('Data path', default=os.getcwd(), type=click.Path(exists=True, resolve_path=True)) | |
53 | inputs['startDate'] = click.prompt('Start date', default='1970/01/01', type=str) |
|
53 | inputs['startDate'] = click.prompt('Start date', default='1970/01/01', type=str) | |
54 | inputs['endDate'] = click.prompt('End date', default='2017/12/31', type=str) |
|
54 | inputs['endDate'] = click.prompt('End date', default='2017/12/31', type=str) | |
55 | inputs['startHour'] = click.prompt('Start hour', default='00:00:00', type=str) |
|
55 | inputs['startHour'] = click.prompt('Start hour', default='00:00:00', type=str) | |
56 | inputs['endHour'] = click.prompt('End hour', default='23:59:59', type=str) |
|
56 | inputs['endHour'] = click.prompt('End hour', default='23:59:59', type=str) | |
57 | inputs['figpath'] = inputs['path'] + '/figs' |
|
57 | inputs['figpath'] = inputs['path'] + '/figs' | |
58 | return inputs |
|
58 | return inputs | |
59 |
|
59 | |||
60 |
|
60 | |||
61 | def generate(): |
|
61 | def generate(): | |
62 | inputs = basicInputs() |
|
62 | inputs = basicInputs() | |
63 | inputs['multiprocess'] = click.confirm('Is this a multiprocess script?') |
|
63 | inputs['multiprocess'] = click.confirm('Is this a multiprocess script?') | |
64 | if inputs['multiprocess']: |
|
64 | if inputs['multiprocess']: | |
65 | inputs['nProcess'] = click.prompt('How many process?', default=cpu_count(), type=int) |
|
65 | inputs['nProcess'] = click.prompt('How many process?', default=cpu_count(), type=int) | |
66 | current = templates.multiprocess.format(**inputs) |
|
66 | current = templates.multiprocess.format(**inputs) | |
67 | else: |
|
67 | else: | |
68 | current = templates.basic.format(**inputs) |
|
68 | current = templates.basic.format(**inputs) | |
69 | scriptname = inputs['name'] + ".py" |
|
69 | scriptname = inputs['name'] + ".py" | |
70 | script = open(scriptname, 'w') |
|
70 | script = open(scriptname, 'w') | |
71 | try: |
|
71 | try: | |
72 | script.write(current) |
|
72 | script.write(current) | |
73 | click.echo('\x1b[6;37;42m[SUCCESS] Script {file} generated\x1b[0m'.format(file=scriptname)) |
|
73 | click.echo('\x1b[6;37;42m[SUCCESS] Script {file} generated\x1b[0m'.format(file=scriptname)) | |
74 | except Exception as e: |
|
74 | except Exception as e: | |
75 | click.echo('\x1b[6;37;41m[ERROR] I cannot create the file. Do you have writing permissions?\x1b[0m') |
|
75 | click.echo('\x1b[6;37;41m[ERROR] I cannot create the file. Do you have writing permissions?\x1b[0m') | |
76 |
|
76 | |||
77 |
|
77 | |||
78 | def test(): |
|
78 | def test(): | |
79 | 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') | |
80 | click.echo('testing') |
|
80 | click.echo('testing') | |
81 |
|
81 | |||
82 |
|
82 | |||
83 | def runFromXML(filename): |
|
83 | def runFromXML(filename): | |
84 | controller = controller_api.ControllerThread() |
|
84 | controller = controller_api.ControllerThread() | |
85 | if not controller.readXml(filename): |
|
85 | if not controller.readXml(filename): | |
86 | return |
|
86 | return | |
87 |
|
87 | |||
88 | plotterObj = controller.useExternalPlotter() |
|
88 | plotterObj = controller.useExternalPlotter() | |
89 |
|
89 | |||
90 | controller.start() |
|
90 | controller.start() | |
91 | plotterObj.start() |
|
91 | plotterObj.start() | |
92 |
|
92 | |||
93 | print "Finishing all processes ..." |
|
93 | print "Finishing all processes ..." | |
94 |
|
94 | |||
95 | controller.join(5) |
|
95 | controller.join(5) | |
96 |
|
96 | |||
97 | print "End of script" |
|
97 | print "End of script" | |
98 | return |
|
98 | return |
1 | NO CONTENT: file renamed from schaincli/schaincli/templates.py to schaincli/templates.py |
|
NO CONTENT: file renamed from schaincli/schaincli/templates.py to schaincli/templates.py |
@@ -1,53 +1,54 | |||||
1 | ''' |
|
1 | ''' | |
2 | Created on Jul 16, 2014 |
|
2 | Created on Jul 16, 2014 | |
3 |
|
3 | |||
4 | @author: Miguel Urco |
|
4 | @author: Miguel Urco | |
5 | ''' |
|
5 | ''' | |
6 |
|
6 | |||
7 | from schainpy import __version__ |
|
7 | from schainpy import __version__ | |
8 | from setuptools import setup, Extension |
|
8 | from setuptools import setup, Extension | |
9 |
|
9 | |||
10 | setup(name="schainpy", |
|
10 | setup(name="schainpy", | |
11 | version=__version__, |
|
11 | version=__version__, | |
12 | description="Python tools to read, write and process Jicamarca data", |
|
12 | description="Python tools to read, write and process Jicamarca data", | |
13 | author="Miguel Urco", |
|
13 | author="Miguel Urco", | |
14 | author_email="miguel.urco@jro.igp.gob.pe", |
|
14 | author_email="miguel.urco@jro.igp.gob.pe", | |
15 | url="http://jro.igp.gob.pe", |
|
15 | url="http://jro.igp.gob.pe", | |
16 | packages = {'schainpy', |
|
16 | packages = {'schainpy', | |
17 | 'schainpy.model', |
|
17 | 'schainpy.model', | |
18 | 'schainpy.model.data', |
|
18 | 'schainpy.model.data', | |
19 | 'schainpy.model.graphics', |
|
19 | 'schainpy.model.graphics', | |
20 | 'schainpy.model.io', |
|
20 | 'schainpy.model.io', | |
21 | 'schainpy.model.proc', |
|
21 | 'schainpy.model.proc', | |
22 | 'schainpy.model.serializer', |
|
22 | 'schainpy.model.serializer', | |
23 | 'schainpy.model.utils', |
|
23 | 'schainpy.model.utils', | |
24 | 'schainpy.gui', |
|
24 | 'schainpy.gui', | |
25 | 'schainpy.gui.figures', |
|
25 | 'schainpy.gui.figures', | |
26 | 'schainpy.gui.viewcontroller', |
|
26 | 'schainpy.gui.viewcontroller', | |
27 | 'schainpy.gui.viewer', |
|
27 | 'schainpy.gui.viewer', | |
28 | 'schainpy.gui.viewer.windows'}, |
|
28 | 'schainpy.gui.viewer.windows'}, | |
29 | ext_package='schainpy', |
|
29 | ext_package='schainpy', | |
30 | py_modules=[''], |
|
30 | py_modules=[''], | |
31 | package_data={'': ['schain.conf.template'], |
|
31 | package_data={'': ['schain.conf.template'], | |
32 | 'schainpy.gui.figures': ['*.png','*.jpg'], |
|
32 | 'schainpy.gui.figures': ['*.png','*.jpg'], | |
33 | }, |
|
33 | }, | |
34 | include_package_data=False, |
|
34 | include_package_data=False, | |
35 | entry_points={ |
|
35 | entry_points={ | |
36 | 'console_scripts': [ |
|
36 | 'console_scripts': [ | |
37 |
'schain = schaincli. |
|
37 | 'schain = schaincli.cli:main', | |
38 | ], |
|
38 | ], | |
39 | }, |
|
39 | }, | |
40 | scripts =['schainpy/gui/schainGUI'], |
|
40 | scripts =['schainpy/gui/schainGUI'], | |
41 | ext_modules=[Extension("cSchain", ["schainpy/model/proc/extensions.c"])], |
|
41 | ext_modules=[Extension("cSchain", ["schainpy/model/proc/extensions.c"])], | |
42 | install_requires=[ |
|
42 | install_requires=[ | |
43 | "scipy >= 0.14.0", |
|
43 | "scipy >= 0.14.0", | |
44 | "h5py >= 2.2.1", |
|
44 | "h5py >= 2.2.1", | |
45 | "matplotlib >= 1.4.2", |
|
45 | "matplotlib >= 1.4.2", | |
46 | "pyfits >= 3.4", |
|
46 | "pyfits >= 3.4", | |
47 | "numpy >= 1.11.2", |
|
47 | "numpy >= 1.11.2", | |
48 | "paramiko >= 2.1.2", |
|
48 | "paramiko >= 2.1.2", | |
49 | "paho-mqtt >= 1.2", |
|
49 | "paho-mqtt >= 1.2", | |
50 | "zmq", |
|
50 | "zmq", | |
51 | "fuzzywuzzy" |
|
51 | "fuzzywuzzy", | |
|
52 | "click" | |||
52 | ], |
|
53 | ], | |
53 | ) |
|
54 | ) |
1 | NO CONTENT: file was removed |
|
NO CONTENT: file was removed |
1 | NO CONTENT: file was removed |
|
NO CONTENT: file was removed |
1 | NO CONTENT: file was removed |
|
NO CONTENT: file was removed |
1 | NO CONTENT: file was removed |
|
NO CONTENT: file was removed |
1 | NO CONTENT: file was removed |
|
NO CONTENT: file was removed |
1 | NO CONTENT: file was removed |
|
NO CONTENT: file was removed |
General Comments 0
You need to be logged in to leave comments.
Login now