weboob.tools.application.base

class weboob.tools.application.base.Application(option_parser=None)

Bases: object

Base application.

This class can be herited to have some common code within weboob applications.

APPNAME = ''
CONFDIR = None
CONFIG = {}
COPYRIGHT = None
DEBUG_FILTER = 2
DESCRIPTION = None
STORAGE = {}
SYNOPSIS = 'Usage: %prog [-h] [-dqv] [-b backends] ...\n %prog [--help] [--version]'
VERSION = None
add_application_options(group)

Overload this method if your application needs extra options.

These options will be displayed in an option group.

bcall_error_handler(backend, error, backtrace)

Handler for an exception inside the CallErrors exception.

This method can be overridden to support more exceptions types.

bcall_errors_handler(errors, debugmsg='Use --debug option to print backtraces', ignore=())

Handler for the CallErrors exception.

It calls bcall_error_handler for each error.

Parameters:
  • errors (weboob.core.bcall.CallErrors) – Object containing errors from backends
  • debugmsg (basestring) – Default message asking to enable the debug mode
  • ignore (tuple[Exception]) – Exceptions to ignore
classmethod create_default_logger()
create_logging_file_handler(filename)
create_storage(path=None, klass=None, localonly=False)

Create a storage object.

Parameters:
  • path (str) – An optional specific path
  • klass (weboob.tools.storage.IStorage) – What class to instance
  • localonly (bool) – If True, do not set it on the Weboob object.
Return type:

weboob.tools.storage.IStorage

create_weboob()
deinit()
guess_encoding(stdio=None)
handle_application_options()

Overload this method in your application if you want to handle options defined in add_application_options.

load_backends(caps=None, names=None, exclude=None, *args, **kwargs)
load_config(path=None, klass=None)

Load a configuration file and get his object.

Parameters:
Return type:

weboob.tools.config.iconfig.IConfig

main(argv)

Main method

Called by run

parse_args(args)
classmethod run(args=None)

This static method can be called to run the application.

It creates the application object, handles options, setups logging, calls the main() method, and catches common exceptions.

You can’t do anything after this call, as it always finishes with a call to sys.exit().

For example:

>>> from weboob.application.myapplication import MyApplication
>>> MyApplication.run()
classmethod setup_logging(level, handlers)
setup_nss()
stderr = <open file '<stderr>', mode 'w'>
stdin = <open file '<stdin>', mode 'r'>
stdout = <open file '<stdout>', mode 'w'>