Skip to content
Snippets Groups Projects
Select Git revision
  • ab15a548e2faa2115082116308539918d4553ec7
  • develop default
  • master protected
  • feature/frontend-tests
  • 0.108
  • 0.107
  • 0.106
  • 0.105
  • 0.104
  • 0.103
  • 0.102
  • 0.101
  • 0.100
  • 0.99
  • 0.98
  • 0.97
  • 0.96
  • 0.95
  • 0.94
  • 0.93
  • 0.92
  • 0.91
  • 0.90
  • 0.89
24 results

Banner.tsx

Blame
  • cli.py 1.46 KiB
    """
    
    script name [TODO]
    ====================
    
    .. code-block:: bash
    
        Usage: script name [OPTIONS]
    
          notes: - first call init_db(dns=mysql_dsn(params from config)) - then create
          a session (as in unit test) - ... and perform the db queries
    
        Options:
          --config FILENAME  config filename  [required]
          --fqdn TEXT        config filename  [required]
          --help             Show this message and exit.
    
    The configuration filename must be formatted according
    to this schema:
    
        .. asjson::
           resource_management.config.CONFIG_SCHEMA
    
    
    .. todo::
    
        add a console script alias and change the name (cli.py) below
    
    
    """
    import json
    
    import click
    from jsonschema.exceptions import ValidationError
    
    
    def _validate_config(_unused_ctx, _unused_param, file):
        try:
            params = json.loads(file.read())
            return params
        except (json.JSONDecodeError, ValidationError):
            raise click.BadParameter('config file is not valid json')
    
    
    @click.command()
    @click.option(
        '--config',
        required=True,
        type=click.File('r'),
        help='config filename',
        callback=_validate_config)
    @click.option(
        '--fqdn',
        required=True,
        type=click.STRING,
        help='config filename')
    def cli(config, fqdn):
        """
        notes:
        - first call init_db(dns=mysql_dsn(params from config))
        - then create a session (as in unit test)
        - ... and perform the db queries
        """
        print(config)
        print(fqdn)
    
    
    if __name__ == '__main__':
        cli()