data_manager

class mpf.core.data_manager.DataManager(machine, name)

Bases: mpf.core.mpf_controller.MpfController

Handles key value data loading and saving for the machine.

Methods & Attributes

The data_manager has the following methods & attributes available. Note that methods & attributes inherited from the base class are not included here.

configure_logging(logger, console_level='basic', file_level='basic')

Configure the logging for the module this class is mixed into.

Parameters:
  • logger -- The string name of the logger to use
  • console_level -- The level of logging for the console. Valid options are "none", "basic", or "full".
  • file_level -- The level of logging for the console. Valid options are "none", "basic", or "full".
debug_log(msg, *args, **kwargs)

Log a message at the debug level.

Note that whether this message shows up in the console or log file is controlled by the settings used with configure_logging().

error_log(msg, *args, **kwargs)

Log a message at the error level.

These messages will always be shown in the console and the log file.

get_data(section=None)

Return the value of this DataManager's data.

Parameters:section -- Optional string name of a section (dictionary key) for the data you want returned. Default is None which returns the entire dictionary.
info_log(msg, *args, **kwargs)

Log a message at the info level.

Whether this message shows up in the console or log file is controlled by the settings used with configure_logging().

remove_key(key)

Remove key by name.

save_all(data=None, delay_secs=0)

Write this DataManager's data to the disk.

Parameters:
  • data -- An optional dict() of the data you want to write. If None then it will write the data as it exists in its own data attribute.
  • delay_secs -- Optional integer value of the amount of time you want to wait before the disk write occurs. Useful for writes that occur when MPF is busy, so you can delay them by a few seconds so they don't slow down MPF. Default is 0.
save_key(key, value, delay_secs=0)

Update an individual key and then write the entire dictionary to disk.

Parameters:
  • key -- String name of the key to add/update.
  • value -- Value of the key
  • delay_secs -- Optional number of seconds to wait before writing the data to disk. Default is 0.
warning_log(msg, *args, **kwargs)

Log a message at the warning level.

These messages will always be shown in the console and the log file.