46 lines
1.9 KiB
Python
46 lines
1.9 KiB
Python
import click
|
|
|
|
from sdi_checker.app_cli import display_report
|
|
|
|
|
|
@click.command(name='dashboard')
|
|
@click.argument('file', nargs=-1)
|
|
@click.option('--directory', '-d', default='', multiple=False, type=str, help='Path to directory of report files')
|
|
@click.option('--workspace', '-ws', default='', multiple=False, type=str, help='Generate dashbord of specific workspace (if report type is WMS or WFS)')
|
|
@click.option('--destination', '-dst', default='', multiple=False, type=str, help='Destination directory and eventually filename of dashboard (default = "dashboard")')
|
|
@click.option('--template', '-tpl', default='', multiple=False, type=str, help='Template HTML used to geerate dashboard')
|
|
@click.pass_obj
|
|
def run(app, file, directory, workspace, destination, template):
|
|
"""
|
|
> dashboard [FILE] [--workspace WORKSPACE] [--destination DESTINATION] [--template TEMPLATE]
|
|
Générer un tableau de bord pour le rapport selectionné
|
|
"""
|
|
on_dashboard(app, file, directory, workspace, destination, template)
|
|
|
|
|
|
def on_dashboard(app, file, directory, workspace, destination, template):
|
|
"""
|
|
|
|
Générer un tableau de bord pour le rapport selectionné
|
|
"""
|
|
|
|
if not file or file is None or len(file) == 0:
|
|
app.echo()
|
|
app.echo('ERROR: [FILE] argument is missing.')
|
|
display_report.print_reports_list(app, app.config['reports'], title="Thanks to indicate a [FILE] id.", echo=True)
|
|
sys.exit()
|
|
|
|
file = [int(i.strip()) for i in ','.join(file).split(',')][0]
|
|
report = app.config['reports'][file]
|
|
|
|
if workspace and workspace is not None and report['type'].lower() not in ['wms', 'wfs']:
|
|
app.echo()
|
|
app.echo('ERROR: "--workspace" option works only on WMS and WFS report type.')
|
|
app.echo()
|
|
sys.exit()
|
|
|
|
result = app.generate_dashboard(report=report, workspace=workspace, destination=destination, template=template)
|
|
|
|
result_text = '\n'.join(result)
|
|
app.echo(result_text)
|