@@ -0,0 +1,21 | |||||
|
1 | # schaing-cli | |||
|
2 | ||||
|
3 | Command Line Interface for SIGNAL CHAIN - jro | |||
|
4 | ||||
|
5 | ||||
|
6 | # Installation | |||
|
7 | ||||
|
8 | If you don't use `pipsi`, you're missing out. | |||
|
9 | Here are [installation instructions](https://github.com/mitsuhiko/pipsi#readme). | |||
|
10 | ||||
|
11 | Simply run: | |||
|
12 | ||||
|
13 | $ pipsi install . | |||
|
14 | ||||
|
15 | ||||
|
16 | # Usage | |||
|
17 | ||||
|
18 | To use it: | |||
|
19 | ||||
|
20 | $ schain-cli --help | |||
|
21 |
1 | NO CONTENT: new file 100644 |
|
NO CONTENT: new file 100644 |
@@ -0,0 +1,43 | |||||
|
1 | import click | |||
|
2 | import schainpy | |||
|
3 | from schaincli import templates | |||
|
4 | import os, sys | |||
|
5 | ||||
|
6 | def print_version(ctx, param, value): | |||
|
7 | if not value or ctx.resilient_parsing: | |||
|
8 | return | |||
|
9 | click.echo(schainpy.__version__) | |||
|
10 | ctx.exit() | |||
|
11 | ||||
|
12 | ||||
|
13 | @click.command() | |||
|
14 | @click.option('--version', '-v', is_flag=True, callback=print_version, help='SChain version', type=str) | |||
|
15 | @click.argument('command', default='run', required=True) | |||
|
16 | def main(command, version): | |||
|
17 | """COMMAND LINE INTERFACE FOR SIGNAL CHAIN - JICAMARCA RADIO OBSERVATORY""" | |||
|
18 | if command == 'generate': | |||
|
19 | generate() | |||
|
20 | pass | |||
|
21 | elif command == 'run': | |||
|
22 | pass | |||
|
23 | elif command == 'test': | |||
|
24 | test() | |||
|
25 | pass | |||
|
26 | else: | |||
|
27 | click.echo('[ERROR] - Command not defined.') | |||
|
28 | ||||
|
29 | def generate(): | |||
|
30 | inputs = {} | |||
|
31 | inputs['desc'] = click.prompt('Enter a description', default="A schain project", type=str) | |||
|
32 | inputs['name'] = click.prompt('Name of the project', default="project", type=str) | |||
|
33 | inputs['path'] = click.prompt('Data path', default=os.getcwd(), type=click.Path(exists=True, resolve_path=True)) | |||
|
34 | inputs['startDate'] = click.prompt('Start date', default='01/01/1970', type=str) | |||
|
35 | inputs['endDate'] = click.prompt('End date', default='31/12/2017', type=str) | |||
|
36 | inputs['startHour'] = click.prompt('Start hour', default='00:00:00', type=str) | |||
|
37 | inputs['endHour'] = click.prompt('End hour', default='23:59:59', type=str) | |||
|
38 | script = open(inputs['name'] + ".py", 'w') | |||
|
39 | script.write(templates.basic.format(**inputs)) | |||
|
40 | ||||
|
41 | def test(): | |||
|
42 | print templates.basic.format(name='hola', desc= 'desc', path='path', startDate='0', endDate='0') | |||
|
43 | click.echo('testing') |
@@ -0,0 +1,21 | |||||
|
1 | basic = | |||
|
2 | '''import argparse | |||
|
3 | from schainpy.controller import Project, multiSchain | |||
|
4 | ||||
|
5 | desc = "{desc}" | |||
|
6 | ||||
|
7 | controller = Project() | |||
|
8 | controller.setup(id='191', name="{name}", description=desc) | |||
|
9 | ||||
|
10 | readUnitConf = controller.addReadUnit(datatype='SpectraReader', | |||
|
11 | path="{path}", | |||
|
12 | startDate="{startDate}", | |||
|
13 | endDate="{endDate}", | |||
|
14 | startTime="{startHour}", | |||
|
15 | endTime="{endHour}", | |||
|
16 | online=0, | |||
|
17 | walk=1, | |||
|
18 | ) | |||
|
19 | ||||
|
20 | procUnitConf2 = controllerObj.addProcUnit(datatype='Spectra', inputId=readUnitConfObj.getId()) | |||
|
21 | ''' |
@@ -0,0 +1,48 | |||||
|
1 | """ | |||
|
2 | Command Line Interface for SIGNAL CHAIN - jro | |||
|
3 | """ | |||
|
4 | from setuptools import find_packages, setup | |||
|
5 | ||||
|
6 | dependencies = ['click'] | |||
|
7 | ||||
|
8 | setup( | |||
|
9 | name='schaincli', | |||
|
10 | version='0.1.0', | |||
|
11 | url='http://jro-dev.igp.gob.pe/rhodecode/schain', | |||
|
12 | license='BSD', | |||
|
13 | author='Jose Chavez', | |||
|
14 | author_email='jose.chavez@jro.igp.gob.pe', | |||
|
15 | description='Command Line Interface for SIGNAL CHAIN - jro', | |||
|
16 | long_description=__doc__, | |||
|
17 | packages=find_packages(exclude=['tests']), | |||
|
18 | include_package_data=True, | |||
|
19 | zip_safe=False, | |||
|
20 | platforms='any', | |||
|
21 | install_requires=dependencies, | |||
|
22 | entry_points={ | |||
|
23 | 'console_scripts': [ | |||
|
24 | 'schain-cli = schaincli.cli:main', | |||
|
25 | ], | |||
|
26 | }, | |||
|
27 | classifiers=[ | |||
|
28 | # As from http://pypi.python.org/pypi?%3Aaction=list_classifiers | |||
|
29 | # 'Development Status :: 1 - Planning', | |||
|
30 | # 'Development Status :: 2 - Pre-Alpha', | |||
|
31 | # 'Development Status :: 3 - Alpha', | |||
|
32 | 'Development Status :: 4 - Beta', | |||
|
33 | # 'Development Status :: 5 - Production/Stable', | |||
|
34 | # 'Development Status :: 6 - Mature', | |||
|
35 | # 'Development Status :: 7 - Inactive', | |||
|
36 | 'Environment :: Console', | |||
|
37 | 'Intended Audience :: Developers', | |||
|
38 | 'License :: OSI Approved :: BSD License', | |||
|
39 | 'Operating System :: POSIX', | |||
|
40 | 'Operating System :: MacOS', | |||
|
41 | 'Operating System :: Unix', | |||
|
42 | 'Operating System :: Microsoft :: Windows', | |||
|
43 | 'Programming Language :: Python', | |||
|
44 | 'Programming Language :: Python :: 2', | |||
|
45 | 'Programming Language :: Python :: 3', | |||
|
46 | 'Topic :: Software Development :: Libraries :: Python Modules', | |||
|
47 | ] | |||
|
48 | ) |
@@ -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.' |
General Comments 0
You need to be logged in to leave comments.
Login now