This module represents OctoPrint’s settings management. Within this module the default settings for the core
application are defined and the instance of the
Settings is held, which offers getter and setter
methods for the raw configuration values as well as various convenience methods to access the paths to base folders
of various types and the configuration file itself.
The default settings of the core application.
valid_boolean_trues= [True, 'true', 'yes', 'y', '1']¶
Values that are considered to be equivalent to the boolean
Truevalue, used for type conversion in various places.
settings(init=False, basedir=None, configfile=None)¶
Factory method for initially constructing and consecutively retrieving the
- init (boolean) – A flag indicating whether this is the initial call to construct the singleton (True) or not
(False, default). If this is set to True and the plugin manager has already been initialized, a
ValueErrorwill be raised. The same will happen if the plugin manager has not yet been initialized and this is set to False.
- basedir (str) – Path of the base directory for all of OctoPrint’s settings, log files, uploads etc. If not set
the default will be used:
%APPDATA%/OctoPrinton Windows and
~/Library/Application Support/OctoPrinton MacOS.
- configfile (str) – Path of the configuration file (
config.yaml) to work on. If not set the default will be used:
basediras defined above.
The fully initialized
Return type: Raises:
initis True but settings are already initialized or vice versa.
- init (boolean) – A flag indicating whether this is the initial call to construct the singleton (True) or not (False, default). If this is set to True and the plugin manager has already been initialized, a
Settingsclass allows managing all of OctoPrint’s settings. It takes care of initializing the settings directory, loading the configuration from
config.yaml, persisting changes to disk etc and provides access methods for getting and setting specific values from the overall settings structure via paths.
A general word on the concept of paths, since they play an important role in OctoPrint’s settings management. A path is basically a list or tuple consisting of keys to follow down into the settings (which are basically like a
dict) in order to set or retrieve a specific value (or more than one). For example, for a settings structure like the following:
serial: port: "/dev/ttyACM0" baudrate: 250000 timeouts: communication: 20.0 temperature: 5.0 sdStatus: 1.0 connection: 10.0 server: host: "0.0.0.0" port: 5000
the following paths could be used:
communication: 20.0 temperature: 5.0 sdStatus: 1.0 connection: 10.0
["serial", "timeout", "temperature"]
However, these would be invalid paths:
["serial", "port", "value"],
["server", "host", 3].
Returns: The last modification time of the configuration file. Return type: int
loadScript(script_type, name, context=None, source=False)¶
saveScript(script_type, name, script)¶
set(path, value, force=False, defaults=None, config=None, preprocessors=None)¶
setBaseFolder(type, path, force=False)¶
setBoolean(path, value, **kwargs)¶
setFloat(path, value, **kwargs)¶
setInt(path, value, **kwargs)¶