def status(config, details): """Show vehicle status.""" api = api_from_config(config) try: info = api.status(retry=False) except Exception: click.echo("Auth expired. Authenticating and retrying...", file=sys.stderr) try: config.info = api.authenticate() info = api.status(retry=False) except Exception as e: raise click.ClickException(str(e)) if config.json: print(pretty_json(info)) else: print_vehicle_info(config.info) print_status_info(info, details)
def setup(config, account_id, pin): """Setup the initial config. Your account ID and PIN numbers are needed for authentication. They will be stored in the ini file for later reusage. """ click.echo('Verifying credentials...', file=sys.stderr) api = Api(account_id, pin) try: info = api.authenticate() except Exception as e: raise click.ClickException(str(e)) config.account_id = account_id config.pin = pin config.info = info config.transaction_id = api.transaction_id click.echo(click.style('Success!', fg='green'), file=sys.stderr) if config.json: print(pretty_json(status)) else: print_vehicle_info(info)
def info(config): if config.json: print(pretty_json(config.info)) else: print_vehicle_info(config.info)