octoprint.settings

class octoprint.settings.HierarchicalChainMap(*maps)
exception octoprint.settings.InvalidSettings(message, line=None, column=None, details=None)
exception octoprint.settings.NoSuchSettingsPath
class octoprint.settings.Settings(configfile=None, basedir=None)

The Settings class 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:

Path

Value

["serial", "port"]

"/dev/ttyACM0"

["serial", "timeout"]

communication: 20.0
temperature: 5.0
sdStatus: 1.0
connection: 10.0

["serial", "timeout", "temperature"]

5.0

["server", "port"]

5000

However, these would be invalid paths: ["key"], ["serial", "port", "value"], ["server", "host", 3].

property last_modified

Returns: (int) The last modification time of the configuration file.

octoprint.settings.default_settings = {'accessControl': {'addRemoteUsers': False, 'autologinAs': None, 'autologinLocal': False, 'checkBasicAuthenticationPassword': True, 'enabled': True, 'groupManager': 'octoprint.access.groups.FilebasedGroupManager', 'groupfile': None, 'localNetworks': ['127.0.0.0/8', '::1/128'], 'permissionManager': 'octoprint.access.permissions.PermissionManager', 'remoteUserHeader': 'REMOTE_USER', 'salt': None, 'trustBasicAuthentication': False, 'trustRemoteUser': False, 'userManager': 'octoprint.access.users.FilebasedUserManager', 'userfile': None}, 'api': {'allowCrossOrigin': False, 'apps': {}, 'key': None}, 'appearance': {'closeModalsWithClick': True, 'color': 'default', 'colorIcon': True, 'colorTransparent': False, 'components': {'disabled': {'generic': [], 'navbar': [], 'settings': [], 'sidebar': [], 'tab': [], 'usersettings': []}, 'order': {'about': ['about', 'plugin_pi_support', 'supporters', 'authors', 'changelog', 'license', 'thirdparty', 'plugin_pluginmanager'], 'generic': [], 'navbar': ['settings', 'systemmenu', 'plugin_announcements', 'plugin_logging', 'plugin_pi_support', 'login'], 'settings': ['section_printer', 'serial', 'printerprofiles', 'temperatures', 'terminalfilters', 'gcodescripts', 'section_features', 'features', 'webcam', 'accesscontrol', 'plugin_gcodeviewer', 'api', 'plugin_appkeys', 'section_octoprint', 'server', 'folders', 'appearance', 'plugin_logging', 'plugin_pluginmanager', 'plugin_softwareupdate', 'plugin_announcements', 'plugin_backup', 'plugin_tracking', 'plugin_errortracking', 'plugin_pi_support'], 'sidebar': ['plugin_firmware_check', 'connection', 'state', 'files'], 'tab': ['temperature', 'control', 'plugin_gcodeviewer', 'terminal', 'timelapse'], 'usersettings': ['access', 'interface'], 'wizard': ['plugin_backup', 'plugin_corewizard_acl']}}, 'defaultLanguage': '_default', 'fuzzyTimes': True, 'name': '', 'showFahrenheitAlso': False}, 'controls': [], 'devel': {'cache': {'enabled': True, 'preemptive': True}, 'showLoadingAnimation': True, 'sockJsConnectTimeout': 10, 'stylesheet': 'css', 'useFrozenDictForPrinterState': True, 'webassets': {'bundle': True, 'clean_on_startup': True, 'minify': True, 'minify_plugins': False}}, 'estimation': {'printTime': {'forceDumbAfterMin': 30, 'forceDumbFromPercent': 0.3, 'stableThreshold': 60, 'statsWeighingUntil': 0.5, 'validityRange': 0.15}}, 'events': {'enabled': True, 'subscriptions': []}, 'feature': {'autoUppercaseBlacklist': ['M117', 'M118'], 'g90InfluencesExtruder': False, 'keyboardControl': True, 'modelSizeDetection': True, 'pollWatched': False, 'printCancelConfirmation': True, 'printStartConfirmation': False, 'sdSupport': True, 'temperatureGraph': True}, 'folder': {'data': None, 'generated': None, 'logs': None, 'plugins': None, 'printerProfiles': None, 'scripts': None, 'slicingProfiles': None, 'timelapse': None, 'timelapse_tmp': None, 'translations': None, 'uploads': None, 'virtualSd': None, 'watched': None}, 'gcodeAnalysis': {'maxExtruders': 10, 'runAt': 'idle', 'throttle_highprio': 0.0, 'throttle_lines': 100, 'throttle_normalprio': 0.01}, 'plugins': {'_disabled': [], '_forcedCompatible': []}, 'printerParameters': {'defaultExtrusionLength': 5, 'pauseTriggers': []}, 'printerProfiles': {'default': None}, 'scripts': {'gcode': {'afterPrintCancelled': "; disable motors\nM84\n\n;disable all heaters\n{% snippet 'disable_hotends' %}\n{% snippet 'disable_bed' %}\n;disable fan\nM106 S0", 'snippets': {'disable_bed': '{% if printer_profile.heatedBed %}M140 S0\n{% endif %}', 'disable_hotends': '{% if printer_profile.extruder.sharedNozzle %}M104 T0 S0\n{% else %}{% for tool in range(printer_profile.extruder.count) %}M104 T{{ tool }} S0\n{% endfor %}{% endif %}'}}}, 'serial': {'abortHeatupOnCancel': True, 'ackMax': 1, 'additionalBaudrates': [], 'additionalPorts': [], 'alwaysSendChecksum': False, 'autoconnect': False, 'baudrate': None, 'blacklistedBaudrates': [], 'blacklistedPorts': [], 'blockWhileDwelling': False, 'blockedCommands': ['M0', 'M1'], 'capabilities': {'autoreport_sdstatus': True, 'autoreport_temp': True, 'busy_protocol': True, 'emergency_parser': True}, 'checksumRequiringCommands': ['M110'], 'disableSdPrintingDetection': False, 'disconnectOnErrors': True, 'emergencyCommands': ['M112', 'M108', 'M410'], 'exclusive': True, 'externalHeatupDetection': True, 'firmwareDetection': True, 'helloCommand': 'M110 N0', 'identicalResendsCountdown': 7, 'ignoreErrorsFromFirmware': False, 'ignoreIdenticalResends': False, 'log': False, 'logPositionOnCancel': False, 'logPositionOnPause': True, 'logResends': True, 'longRunningCommands': ['G4', 'G28', 'G29', 'G30', 'G32', 'M400', 'M226', 'M600'], 'maxCommunicationTimeouts': {'idle': 2, 'long': 5, 'printing': 5}, 'maxConsecutiveResends': 10, 'maxNotSdPrinting': 2, 'maxWritePasses': 5, 'neverSendChecksum': False, 'pausingCommands': ['M0', 'M1', 'M25'], 'port': None, 'repetierTargetTemp': False, 'sanityCheckTools': True, 'sdAlwaysAvailable': False, 'sdRelativePath': False, 'sendChecksumWithUnknownCommands': False, 'sendM112OnError': True, 'supportFAsCommand': False, 'supportResendsWithoutOk': 'detect', 'supportWait': True, 'swallowOkAfterResend': True, 'terminalLogSize': 20, 'timeout': {'baudrateDetectionPause': 1.0, 'communication': 30, 'communicationBusy': 3, 'connection': 10, 'detectionConsecutive': 2, 'detectionFirst': 10, 'positionLogWait': 10.0, 'resendOk': 0.5, 'sdStatus': 1, 'sdStatusAutoreport': 1, 'temperature': 5, 'temperatureAutoreport': 2, 'temperatureTargetSet': 2}, 'triggerOkForM29': True, 'unknownCommandsNeedAck': False, 'useParityWorkaround': 'detect', 'waitForStartOnConnect': False}, 'server': {'allowFraming': False, 'commands': {'serverRestartCommand': None, 'systemRestartCommand': None, 'systemShutdownCommand': None}, 'cookies': {'samesite': None, 'secure': False}, 'diskspace': {'critical': 209715200, 'warning': 524288000}, 'firstRun': True, 'heartbeat': 900, 'host': None, 'ignoreIncompleteStartup': False, 'incompleteStartup': False, 'ipCheck': {'enabled': True, 'trustedSubnets': []}, 'maxSize': 102400, 'onlineCheck': {'enabled': None, 'host': '8.8.8.8', 'interval': 900, 'name': 'octoprint.org', 'port': 53}, 'pluginBlacklist': {'enabled': None, 'ttl': 900, 'url': 'https://plugins.octoprint.org/blacklist.json'}, 'port': 5000, 'preemptiveCache': {'exceptions': [], 'until': 7}, 'reverseProxy': {'hostFallback': None, 'hostHeader': None, 'portFallback': None, 'portHeader': None, 'prefixFallback': None, 'prefixHeader': None, 'schemeFallback': None, 'schemeHeader': None, 'serverFallback': None, 'serverHeader': None, 'trustedDownstream': []}, 'secretKey': None, 'seenWizards': {}, 'startOnceInSafeMode': False, 'uploads': {'maxSize': 1073741824, 'nameSuffix': 'name', 'pathSuffix': 'path'}}, 'slicing': {'defaultProfiles': None, 'defaultSlicer': None, 'enabled': True}, 'system': {'actions': []}, 'temperature': {'cutoff': 30, 'profiles': [{'name': 'ABS', 'extruder': 210, 'bed': 100}, {'name': 'PLA', 'extruder': 180, 'bed': 60}], 'sendAutomatically': False, 'sendAutomaticallyAfter': 1}, 'terminalFilters': [{'name': 'Suppress temperature messages', 'regex': '(Send: (N\\d+\\s+)?M105)|(Recv:\\s+(ok\\s+((P|B|N)\\d+\\s+)*)?(B|T\\d*):\\d+)'}, {'name': 'Suppress SD status messages', 'regex': '(Send: (N\\d+\\s+)?M27)|(Recv: SD printing byte)|(Recv: Not SD printing)'}, {'name': 'Suppress wait responses', 'regex': 'Recv: wait'}], 'webcam': {'bitrate': '10000k', 'cleanTmpAfterDays': 7, 'ffmpeg': None, 'ffmpegThreads': 1, 'ffmpegVideoCodec': 'libx264', 'flipH': False, 'flipV': False, 'rotate90': False, 'snapshot': None, 'snapshotSslValidation': True, 'snapshotTimeout': 5, 'stream': None, 'streamRatio': '16:9', 'streamTimeout': 5, 'timelapse': {'fps': 25, 'options': {}, 'postRoll': 0, 'type': 'off'}, 'timelapseEnabled': True, 'watermark': True, 'webcamEnabled': True}}

The default settings of the core application.

octoprint.settings.settings(init=False, basedir=None, configfile=None)

Factory method for initially constructing and consecutively retrieving the Settings singleton.

Parameters
  • 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 ValueError will 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: ~/.octoprint on Linux, %APPDATA%/OctoPrint on Windows and ~/Library/Application Support/OctoPrint on MacOS.

  • configfile (str) – Path of the configuration file (config.yaml) to work on. If not set the default will be used: <basedir>/config.yaml for basedir as defined above.

Returns

The fully initialized Settings instance.

Return type

Settings

Raises

ValueErrorinit is True but settings are already initialized or vice versa.

octoprint.settings.valid_boolean_trues = <octoprint.util.CaseInsensitiveSet object>

Values that are considered to be equivalent to the boolean True value, used for type conversion in various places.