@@ -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 | 1 | import click |
|
2 | 2 | import schainpy |
|
3 | 3 | import subprocess |
|
4 | from multiprocessing import cpu_count | |
|
5 | from schaincli import templates | |
|
6 | from schainpy import controller_api | |
|
7 | 4 | import os |
|
8 | 5 | import sys |
|
9 | 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 | 12 | def print_version(ctx, param, value): |
|
12 | 13 | if not value or ctx.resilient_parsing: |
@@ -14,6 +15,7 def print_version(ctx, param, value): | |||
|
14 | 15 | click.echo(schainpy.__version__) |
|
15 | 16 | ctx.exit() |
|
16 | 17 | |
|
18 | cliLogger = log.makelogger('schain cli') | |
|
17 | 19 | |
|
18 | 20 | @click.command() |
|
19 | 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 | 36 | numberfiles = len(currentfiles) |
|
35 | 37 | print currentfiles |
|
36 | 38 | if numberfiles > 1: |
|
37 |
|
|
|
39 | log.error('There is more than one file to run') | |
|
38 | 40 | elif numberfiles == 1: |
|
39 | 41 | subprocess.call(['python ' + currentfiles[0]], shell=True) |
|
40 | 42 | else: |
|
41 |
|
|
|
43 | log.error('There is no file to run.') | |
|
42 | 44 | else: |
|
43 | 45 | subprocess.call(['python ' + nextcommand], shell=True) |
|
44 | 46 | else: |
|
45 |
|
|
|
47 | log.error('Command is not defined.') | |
|
46 | 48 | |
|
47 | 49 | |
|
48 | 50 | def basicInputs(): |
@@ -70,14 +72,13 def generate(): | |||
|
70 | 72 | script = open(scriptname, 'w') |
|
71 | 73 | try: |
|
72 | 74 | script.write(current) |
|
73 |
|
|
|
75 | log.success('Script {file} generated'.format(file=scriptname)) | |
|
74 | 76 | except Exception as e: |
|
75 |
|
|
|
77 | log.error('I cannot create the file. Do you have writing permissions?') | |
|
76 | 78 | |
|
77 | 79 | |
|
78 | 80 | def test(): |
|
79 | print templates.basic.format(name='hola', desc='desc', path='path', startDate='0', endDate='0') | |
|
80 | click.echo('testing') | |
|
81 | log.warning('testing') | |
|
81 | 82 | |
|
82 | 83 | |
|
83 | 84 | def runFromXML(filename): |
@@ -90,9 +91,9 def runFromXML(filename): | |||
|
90 | 91 | controller.start() |
|
91 | 92 | plotterObj.start() |
|
92 | 93 | |
|
93 |
|
|
|
94 | cliLogger("Finishing all processes ...") | |
|
94 | 95 | |
|
95 | 96 | controller.join(5) |
|
96 | 97 | |
|
97 |
|
|
|
98 | cliLogger("End of script") | |
|
98 | 99 | return |
@@ -1,54 +1,56 | |||
|
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 |
|
|
|
36 |
|
|
|
37 |
|
|
|
38 |
|
|
|
39 |
|
|
|
40 |
|
|
|
41 |
|
|
|
42 |
|
|
|
43 |
|
|
|
44 |
|
|
|
45 |
|
|
|
46 |
|
|
|
47 |
|
|
|
48 |
|
|
|
49 |
|
|
|
50 |
|
|
|
51 |
|
|
|
52 |
|
|
|
53 |
|
|
|
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 | ], | |
|
54 | 56 | ) |
|
1 | NO CONTENT: file was removed |
General Comments 0
You need to be logged in to leave comments.
Login now