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].

last_modified

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

Type:Returns
octoprint.settings.default_settings = {u'accessControl': {u'addRemoteUsers': False, u'autologinAs': None, u'autologinLocal': False, u'checkBasicAuthenticationPassword': True, u'enabled': True, u'groupManager': u'octoprint.access.groups.FilebasedGroupManager', u'groupfile': None, u'localNetworks': [u'127.0.0.0/8', u'::1/128'], u'permissionManager': u'octoprint.access.permissions.PermissionManager', u'remoteUserHeader': u'REMOTE_USER', u'salt': None, u'trustBasicAuthentication': False, u'trustRemoteUser': False, u'userManager': u'octoprint.access.users.FilebasedUserManager', u'userfile': None}, u'api': {u'allowCrossOrigin': False, u'apps': {}, u'key': None}, u'appearance': {u'closeModalsWithClick': True, u'color': u'default', u'colorIcon': True, u'colorTransparent': False, u'components': {u'disabled': {u'generic': [], u'navbar': [], u'settings': [], u'sidebar': [], u'tab': [], u'usersettings': []}, u'order': {u'about': [u'about', u'plugin_pi_support', u'supporters', u'authors', u'changelog', u'license', u'thirdparty', u'plugin_pluginmanager'], u'generic': [], u'navbar': [u'settings', u'systemmenu', u'plugin_announcements', u'plugin_pi_support', u'login'], u'settings': [u'section_printer', u'serial', u'printerprofiles', u'temperatures', u'terminalfilters', u'gcodescripts', u'section_features', u'features', u'webcam', u'accesscontrol', u'gcodevisualizer', u'api', u'plugin_appkeys', u'section_octoprint', u'server', u'folders', u'appearance', u'plugin_logging', u'plugin_pluginmanager', u'plugin_softwareupdate', u'plugin_announcements', u'plugin_backup', u'plugin_tracking', u'plugin_errortracking', u'plugin_pi_support'], u'sidebar': [u'plugin_printer_safety_check', u'connection', u'state', u'files'], u'tab': [u'temperature', u'control', u'gcodeviewer', u'terminal', u'timelapse'], u'usersettings': [u'access', u'interface'], u'wizard': [u'access']}}, u'defaultLanguage': u'_default', u'fuzzyTimes': True, u'name': u'', u'showFahrenheitAlso': False}, u'controls': [], u'devel': {u'cache': {u'enabled': True, u'preemptive': True}, u'showLoadingAnimation': True, u'stylesheet': u'css', u'useFrozenDictForPrinterState': True, u'virtualPrinter': {u'ambientTemperature': 21.3, u'brokenM29': True, u'brokenResend': False, u'busyInterval': 2.0, u'capabilities': {u'AUTOREPORT_SD_STATUS': True, u'AUTOREPORT_TEMP': True, u'EMERGENCY_PARSER': True}, u'commandBuffer': 4, u'echoOnM117': True, u'enabled': False, u'errors': {u'checksum_mismatch': u'Checksum mismatch', u'checksum_missing': u'Missing checksum', u'command_unknown': u'Unknown command {}', u'lineno_mismatch': u'expected line {} got {}', u'lineno_missing': u'No Line Number with checksum, Last Line: {}', u'maxtemp': u'MAXTEMP triggered!', u'mintemp': u'MINTEMP triggered!'}, u'extendedSdFileList': False, u'firmwareName': u'Virtual Marlin 1.0', u'forceChecksum': False, u'hasBed': True, u'hasChamber': False, u'includeCurrentToolInTemps': True, u'includeFilenameInOpened': True, u'm114FormatString': u'X:{x} Y:{y} Z:{z} E:{e[current]} Count: A:{a} B:{b} C:{c}', u'm115FormatString': u'FIRMWARE_NAME:{firmware_name} PROTOCOL_VERSION:1.0', u'm115ReportCapabilities': True, u'numExtruders': 1, u'okAfterResend': False, u'okBeforeCommandOutput': False, u'okFormatString': u'ok', u'pinnedExtruders': None, u'preparedOks': [], u'repetierStyleTargetTemperature': False, u'reprapfwM114': False, u'resetLines': [u'start', u'Marlin: Virtual Marlin!', u'\x80', u'SD card ok'], u'rxBuffer': 64, u'sendBusy': False, u'sendWait': True, u'sharedNozzle': False, u'simulateReset': True, u'smoothieTemperatureReporting': False, u'supportF': False, u'supportM112': True, u'throttle': 0.01, u'waitInterval': 1.0}, u'webassets': {u'bundle': True, u'clean_on_startup': True}}, u'estimation': {u'printTime': {u'forceDumbAfterMin': 30, u'forceDumbFromPercent': 0.3, u'stableThreshold': 60, u'statsWeighingUntil': 0.5, u'validityRange': 0.15}}, u'events': {u'enabled': True, u'subscriptions': []}, u'feature': {u'autoUppercaseBlacklist': [u'M117', u'M118'], u'g90InfluencesExtruder': False, u'keyboardControl': True, u'modelSizeDetection': True, u'pollWatched': False, u'printCancelConfirmation': True, u'printStartConfirmation': False, u'sdSupport': True, u'temperatureGraph': True}, u'folder': {u'data': None, u'generated': None, u'logs': None, u'plugins': None, u'printerProfiles': None, u'scripts': None, u'slicingProfiles': None, u'timelapse': None, u'timelapse_tmp': None, u'translations': None, u'uploads': None, u'virtualSd': None, u'watched': None}, u'gcodeAnalysis': {u'maxExtruders': 10, u'runAt': u'idle', u'throttle_highprio': 0.0, u'throttle_lines': 100, u'throttle_normalprio': 0.01}, u'gcodeViewer': {u'enabled': True, u'mobileSizeThreshold': 2097152, u'sizeThreshold': 20971520}, u'plugins': {u'_disabled': [], u'_forcedCompatible': []}, u'printerParameters': {u'defaultExtrusionLength': 5, u'pauseTriggers': []}, u'printerProfiles': {u'default': None}, u'scripts': {u'gcode': {u'afterPrintCancelled': u"; disable motors\nM84\n\n;disable all heaters\n{% snippet 'disable_hotends' %}\n{% snippet 'disable_bed' %}\n;disable fan\nM106 S0", u'snippets': {u'disable_bed': u'{% if printer_profile.heatedBed %}M140 S0\n{% endif %}', u'disable_hotends': u'{% 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 %}'}}}, u'serial': {u'abortHeatupOnCancel': True, u'ackMax': 1, u'additionalBaudrates': [], u'additionalPorts': [], u'alwaysSendChecksum': False, u'autoconnect': False, u'baudrate': None, u'blockWhileDwelling': False, u'blockedCommands': [u'M0', u'M1'], u'capabilities': {u'autoreport_sdstatus': True, u'autoreport_temp': True, u'busy_protocol': True, u'emergency_parser': True}, u'checksumRequiringCommands': [u'M110'], u'disconnectOnErrors': True, u'emergencyCommands': [u'M112', u'M108', u'M410'], u'exclusive': True, u'externalHeatupDetection': True, u'firmwareDetection': True, u'helloCommand': u'M110 N0', u'identicalResendsCountdown': 7, u'ignoreErrorsFromFirmware': False, u'ignoreIdenticalResends': False, u'log': False, u'logPositionOnCancel': False, u'logPositionOnPause': True, u'logResends': True, u'longRunningCommands': [u'G4', u'G28', u'G29', u'G30', u'G32', u'M400', u'M226', u'M600'], u'maxCommunicationTimeouts': {u'idle': 2, u'long': 5, u'printing': 5}, u'maxConsecutiveResends': 10, u'maxNotSdPrinting': 2, u'maxWritePasses': 5, u'neverSendChecksum': False, u'pausingCommands': [u'M0', u'M1', u'M25'], u'port': None, u'repetierTargetTemp': False, u'sdAlwaysAvailable': False, u'sdRelativePath': False, u'sendChecksumWithUnknownCommands': False, u'sendM112OnError': True, u'supportFAsCommand': False, u'supportResendsWithoutOk': u'detect', u'supportWait': True, u'swallowOkAfterResend': True, u'terminalLogSize': 20, u'timeout': {u'baudrateDetectionPause': 1.0, u'communication': 30, u'communicationBusy': 3, u'connection': 10, u'detection': 1, u'positionLogWait': 10.0, u'resendOk': 0.5, u'sdStatus': 1, u'sdStatusAutoreport': 1, u'temperature': 5, u'temperatureAutoreport': 2, u'temperatureTargetSet': 2}, u'triggerOkForM29': True, u'unknownCommandsNeedAck': False, u'useParityWorkaround': u'detect', u'waitForStartOnConnect': False}, u'server': {u'allowFraming': False, u'commands': {u'serverRestartCommand': None, u'systemRestartCommand': None, u'systemShutdownCommand': None}, u'diskspace': {u'critical': 209715200, u'warning': 524288000}, u'firstRun': True, u'heartbeat': 900, u'host': None, u'ignoreIncompleteStartup': False, u'incompleteStartup': False, u'ipCheck': {u'enabled': True, u'trustedSubnets': []}, u'maxSize': 102400, u'onlineCheck': {u'enabled': None, u'host': u'8.8.8.8', u'interval': 900, u'port': 53}, u'pluginBlacklist': {u'enabled': None, u'ttl': 900, u'url': u'https://plugins.octoprint.org/blacklist.json'}, u'port': 5000, u'preemptiveCache': {u'exceptions': [], u'until': 7}, u'reverseProxy': {u'hostFallback': None, u'hostHeader': None, u'portFallback': None, u'portHeader': None, u'prefixFallback': None, u'prefixHeader': None, u'schemeFallback': None, u'schemeHeader': None, u'serverFallback': None, u'serverHeader': None, u'trustedDownstream': []}, u'secretKey': None, u'seenWizards': {}, u'startOnceInSafeMode': False, u'uploads': {u'maxSize': 1073741824, u'nameSuffix': u'name', u'pathSuffix': u'path'}}, u'slicing': {u'defaultProfiles': None, u'defaultSlicer': None, u'enabled': True}, u'system': {u'actions': []}, u'temperature': {u'cutoff': 30, u'profiles': [{u'name': u'ABS', u'bed': 100, u'extruder': 210}, {u'name': u'PLA', u'bed': 60, u'extruder': 180}], u'sendAutomatically': False, u'sendAutomaticallyAfter': 1}, u'terminalFilters': [{u'regex': u'(Send: (N\\d+\\s+)?M105)|(Recv:\\s+(ok\\s+((P|B|N)\\d+\\s+)*)?(B|T\\d*):\\d+)', u'name': u'Suppress temperature messages'}, {u'regex': u'(Send: (N\\d+\\s+)?M27)|(Recv: SD printing byte)|(Recv: Not SD printing)', u'name': u'Suppress SD status messages'}, {u'regex': u'Recv: wait', u'name': u'Suppress wait responses'}], u'webcam': {u'bitrate': u'10000k', u'cleanTmpAfterDays': 7, u'ffmpeg': None, u'ffmpegThreads': 1, u'ffmpegVideoCodec': u'mpeg2video', u'flipH': False, u'flipV': False, u'rotate90': False, u'snapshot': None, u'snapshotSslValidation': True, u'snapshotTimeout': 5, u'stream': None, u'streamRatio': u'16:9', u'streamTimeout': 5, u'timelapse': {u'fps': 25, u'options': {}, u'postRoll': 0, u'type': u'off'}, u'timelapseEnabled': True, u'watermark': True, u'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.