patatmo.cli package

exception patatmo.cli.CredentialsError[source]

Bases: ValueError

patatmo.cli.cli_argumentparser(*args, **kwargs)[source]

Set up and return an argparse.ArgumentParser with default arguments every patatmo cli script needs.

Parameters
  • args (list, optional) – further positional arguments handed to the constructor

  • kwargs (dict, optional) – further keyword arguments handed to the constructor

Returns

the parser with default arguments

Return type

argparse.ArgumentParser

patatmo.cli.get_client(arguments=Namespace())[source]

Set up a client for direct usage.

Parameters

arguments (argparse.Namespace, optional) – the parsed command-line arguments.

Returns

a ready-to-use netatmo api client

Return type

NetatmoClient

Raises

CredentialsError – if any of the credentials could not be determined

patatmo.cli.get_configuration()[source]

Return the user’s patatmo configuration

Returns

the user’s patatmo configuration

Return type

configparser.ConfigParser

patatmo.cli.get_configuration_dir()[source]

Return the user’s configuration directory

Returns

path to the user’s configueration directory

Return type

str

patatmo.cli.get_configuration_file()[source]

Return the user’s configuration file

Returns

path to the user’s configueration file

Return type

str

patatmo.cli.get_credentials(arguments=Namespace())[source]

Try to determine the netatmo credentials in this order:

  1. command-line arguments

  2. environment variables

  3. user configuration folder

Raise an error if it was not possible to determine all credentials.

Parameters

arguments (argparse.Namespace, optional) – the parsed command-line arguments.

Returns

the credentials ready to use by Authentication.

Return type

dict

Raises

CredentialsError – if any of the credentials could not be determined

patatmo.cli.get_output_file(arguments=Namespace())[source]

Return a file handler according to the ‘output’ option in the given arguments.

Parameters

arguments (argparse.Namespace, optional) – the parsed command-line arguments.

Returns

the filehandle to output to

Return type

filehandle

patatmo.cli.make_sure_dir_exists(directory)[source]

Make sure the given directory exists

Parameters

directory (str) – the path of interest