@@ -0,0 +1,46 | |||||
|
1 | """. | |||
|
2 | ||||
|
3 | SCHAINPY - LOG | |||
|
4 | Simple helper for log standarization | |||
|
5 | Usage: | |||
|
6 | from schainpy.utils import log | |||
|
7 | log.error('A kitten died beacuse of you') | |||
|
8 | log.warning('You are doing it wrong but what the heck, I'll allow it) | |||
|
9 | log.succes('YOU ROCK!') | |||
|
10 | To create your own logger inside your class do it like this: | |||
|
11 | from schainpy.utils import log | |||
|
12 | awesomeLogger = log.makelogger("never gonna", bg="red", fg="white") | |||
|
13 | awesomeLogger('give you up') | |||
|
14 | which will look like this: | |||
|
15 | [NEVER GONNA] - give you up | |||
|
16 | with color red as background and white as foreground. | |||
|
17 | """ | |||
|
18 | ||||
|
19 | import click | |||
|
20 | ||||
|
21 | ||||
|
22 | def warning(message): | |||
|
23 | click.echo(click.style('[WARNING] - ' + message, fg='yellow')) | |||
|
24 | pass | |||
|
25 | ||||
|
26 | ||||
|
27 | def error(message): | |||
|
28 | click.echo(click.style('[ERROR] - ' + message, bg='red', fg='white')) | |||
|
29 | pass | |||
|
30 | ||||
|
31 | ||||
|
32 | def success(message): | |||
|
33 | click.echo(click.style('[SUCESS] - ' + message, bg='green', fg='white')) | |||
|
34 | pass | |||
|
35 | ||||
|
36 | ||||
|
37 | def log(message): | |||
|
38 | click.echo('[LOG] - ' + message) | |||
|
39 | pass | |||
|
40 | ||||
|
41 | ||||
|
42 | def makelogger(topic, bg='reset', fg='reset'): | |||
|
43 | def func(message): | |||
|
44 | click.echo(click.style('[{}] - '.format(topic.upper()) + message, | |||
|
45 | bg=bg, fg=fg)) | |||
|
46 | return func |
@@ -1,12 +1,13 | |||||
1 | import click |
|
1 | import click | |
2 | import schainpy |
|
2 | import schainpy | |
3 | import subprocess |
|
3 | import subprocess | |
4 | from multiprocessing import cpu_count |
|
|||
5 | from schaincli import templates |
|
|||
6 | from schainpy import controller_api |
|
|||
7 | import os |
|
4 | import os | |
8 | import sys |
|
5 | import sys | |
9 | import glob |
|
6 | import glob | |
|
7 | from multiprocessing import cpu_count | |||
|
8 | from schaincli import templates | |||
|
9 | from schainpy import controller_api | |||
|
10 | from schainpy.utils import log | |||
10 |
|
11 | |||
11 | def print_version(ctx, param, value): |
|
12 | def print_version(ctx, param, value): | |
12 | if not value or ctx.resilient_parsing: |
|
13 | if not value or ctx.resilient_parsing: | |
@@ -14,6 +15,7 def print_version(ctx, param, value): | |||||
14 | click.echo(schainpy.__version__) |
|
15 | click.echo(schainpy.__version__) | |
15 | ctx.exit() |
|
16 | ctx.exit() | |
16 |
|
17 | |||
|
18 | cliLogger = log.makelogger('schain cli') | |||
17 |
|
19 | |||
18 | @click.command() |
|
20 | @click.command() | |
19 | @click.option('--version', '-v', is_flag=True, callback=print_version, help='SChain version', type=str) |
|
21 | @click.option('--version', '-v', is_flag=True, callback=print_version, help='SChain version', type=str) | |
@@ -34,15 +36,15 def main(command, nextcommand, version, xml): | |||||
34 | numberfiles = len(currentfiles) |
|
36 | numberfiles = len(currentfiles) | |
35 | print currentfiles |
|
37 | print currentfiles | |
36 | if numberfiles > 1: |
|
38 | if numberfiles > 1: | |
37 |
|
|
39 | log.error('There is more than one file to run') | |
38 | elif numberfiles == 1: |
|
40 | elif numberfiles == 1: | |
39 | subprocess.call(['python ' + currentfiles[0]], shell=True) |
|
41 | subprocess.call(['python ' + currentfiles[0]], shell=True) | |
40 | else: |
|
42 | else: | |
41 |
|
|
43 | log.error('There is no file to run.') | |
42 | else: |
|
44 | else: | |
43 | subprocess.call(['python ' + nextcommand], shell=True) |
|
45 | subprocess.call(['python ' + nextcommand], shell=True) | |
44 | else: |
|
46 | else: | |
45 |
|
|
47 | log.error('Command is not defined.') | |
46 |
|
48 | |||
47 |
|
49 | |||
48 | def basicInputs(): |
|
50 | def basicInputs(): | |
@@ -70,14 +72,13 def generate(): | |||||
70 | script = open(scriptname, 'w') |
|
72 | script = open(scriptname, 'w') | |
71 | try: |
|
73 | try: | |
72 | script.write(current) |
|
74 | script.write(current) | |
73 |
|
|
75 | log.success('Script {file} generated'.format(file=scriptname)) | |
74 | except Exception as e: |
|
76 | except Exception as e: | |
75 |
|
|
77 | log.error('I cannot create the file. Do you have writing permissions?') | |
76 |
|
78 | |||
77 |
|
79 | |||
78 | def test(): |
|
80 | def test(): | |
79 | print templates.basic.format(name='hola', desc='desc', path='path', startDate='0', endDate='0') |
|
81 | log.warning('testing') | |
80 | click.echo('testing') |
|
|||
81 |
|
82 | |||
82 |
|
83 | |||
83 | def runFromXML(filename): |
|
84 | def runFromXML(filename): | |
@@ -90,9 +91,9 def runFromXML(filename): | |||||
90 | controller.start() |
|
91 | controller.start() | |
91 | plotterObj.start() |
|
92 | plotterObj.start() | |
92 |
|
93 | |||
93 |
|
|
94 | cliLogger("Finishing all processes ...") | |
94 |
|
95 | |||
95 | controller.join(5) |
|
96 | controller.join(5) | |
96 |
|
97 | |||
97 |
|
|
98 | cliLogger("End of script") | |
98 | return |
|
99 | return |
@@ -1,54 +1,56 | |||||
1 | ''' |
|
1 | """. | |
|
2 | ||||
2 | Created on Jul 16, 2014 |
|
3 | Created on Jul 16, 2014 | |
3 |
|
4 | |||
4 | @author: Miguel Urco |
|
5 | @author: Miguel Urco | |
5 | ''' |
|
6 | """ | |
6 |
|
7 | |||
7 | from schainpy import __version__ |
|
8 | from schainpy import __version__ | |
8 | from setuptools import setup, Extension |
|
9 | from setuptools import setup, Extension | |
9 |
|
10 | |||
10 | setup(name="schainpy", |
|
11 | setup(name="schainpy", | |
11 |
|
|
12 | version=__version__, | |
12 |
|
|
13 | description="Python tools to read, write and process Jicamarca data", | |
13 |
|
|
14 | author="Miguel Urco", | |
14 |
|
|
15 | author_email="miguel.urco@jro.igp.gob.pe", | |
15 |
|
|
16 | url="http://jro.igp.gob.pe", | |
16 |
|
|
17 | packages={'schainpy', | |
17 |
|
|
18 | 'schainpy.model', | |
18 |
|
|
19 | 'schainpy.model.data', | |
19 |
|
|
20 | 'schainpy.model.graphics', | |
20 |
|
|
21 | 'schainpy.model.io', | |
21 |
|
|
22 | 'schainpy.model.proc', | |
22 |
|
|
23 | 'schainpy.model.serializer', | |
23 |
|
|
24 | 'schainpy.model.utils', | |
24 |
|
|
25 | 'schainpy.gui', | |
25 |
|
|
26 | 'schainpy.gui.figures', | |
26 |
|
|
27 | 'schainpy.gui.viewcontroller', | |
27 |
|
|
28 | 'schainpy.gui.viewer', | |
28 |
|
|
29 | 'schainpy.gui.viewer.windows'}, | |
29 |
|
|
30 | ext_package='schainpy', | |
30 |
|
|
31 | py_modules=[''], | |
31 |
|
|
32 | package_data={'': ['schain.conf.template'], | |
32 |
|
|
33 | 'schainpy.gui.figures': ['*.png', '*.jpg'], | |
33 |
|
|
34 | }, | |
34 |
|
|
35 | include_package_data=False, | |
35 |
|
|
36 | entry_points={ | |
36 |
|
|
37 | 'console_scripts': [ | |
37 |
|
|
38 | 'schain = schaincli.cli:main', | |
38 |
|
|
39 | ], | |
39 |
|
|
40 | }, | |
40 |
|
|
41 | scripts=['schainpy/gui/schainGUI'], | |
41 |
|
|
42 | ext_modules=[Extension("cSchain", ["schainpy/model/proc/extensions.c"])], | |
42 |
|
|
43 | install_requires=[ | |
43 |
|
|
44 | "scipy >= 0.14.0", | |
44 |
|
|
45 | "h5py >= 2.2.1", | |
45 |
|
|
46 | "matplotlib >= 1.4.2", | |
46 |
|
|
47 | "pyfits >= 3.4", | |
47 |
|
|
48 | "numpy >= 1.11.2", | |
48 |
|
|
49 | "paramiko >= 2.1.2", | |
49 |
|
|
50 | "paho-mqtt >= 1.2", | |
50 |
|
|
51 | "zmq", | |
51 |
|
|
52 | "fuzzywuzzy", | |
52 |
|
|
53 | "click", | |
53 |
|
|
54 | "colorama" | |
|
55 | ], | |||
54 | ) |
|
56 | ) |
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