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.
- octoprint.settings.default_settings = dict(...)
The default settings of the core application.
- octoprint.settings.valid_boolean_trues = <octoprint.util.CaseInsensitiveSet object>
Values that are considered to be equivalent to the boolean
Truevalue, used for type conversion in various places.
- octoprint.settings.settings(init=False, basedir=None, configfile=None, overlays=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.
overlays (list) – List of paths to config overlays to put between default settings and config.yaml
The fully initialized
- Return type
initis True but settings are already initialized or vice versa.
- class octoprint.settings.Settings(configfile=None, basedir=None, overlays=None)
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 timeout: 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].
- OVERLAY_KEY = '__overlay__'
- add_overlay(overlay, at_end=False, key=None)
- backup(suffix=None, path=None, ext=None, hidden=False)
- property config
A view of the local config as stored in config.yaml
Does not support modifications, they will be thrown away silently. If you need to modify anything in the settings, utilize the provided set and remove methods.
- property config_hash
- property config_yaml
- property effective
- property effective_hash
- property effective_yaml
- get(path, **kwargs)
- getBaseFolder(type, create=True, allow_fallback=True, check_writable=True, deep_check_writable=False)
- getBoolean(path, **kwargs)
- getFloat(path, **kwargs)
- getInt(path, **kwargs)
- has(path, **kwargs)
- property last_modified
Returns: (int) The last modification time of the configuration file.
- property last_modified_or_made_dirty
- loadScript(script_type, name, context=None, source=False)
- load_overlay(overlay, migrate=True)
- load_overlays(overlays, migrate=True)
- remove(path, config=None, error_on_path=False, defaults=None)
- save(force=False, trigger_event=False)
- saveScript(script_type, name, script)
- set(path, value, force=False, defaults=None, config=None, preprocessors=None, error_on_path=False, *args, **kwargs)
- setBaseFolder(type, path, force=False, validate=True)
- setBoolean(path, value, **kwargs)
- setFloat(path, value, **kwargs)
- setInt(path, value, **kwargs)