Merge branch 'maintenance' into devel

# Conflicts:
#	setup.py
#	src/octoprint/server/__init__.py
#	src/octoprint/server/util/tornado.py
This commit is contained in:
Gina Häußge committed 2018-03-29 17:01:18 +02:00
commit 92ea6ee9aa
31 files changed
+405 -154

No files matched your search

+3 -3
View File
@@ -23,10 +23,10 @@ maintenance 1.3.8 da2c9632ea54fd1b3c8ae34f8f26bab29dbaf3c6 pep440-dev
fix/.* 1.3.8 da2c9632ea54fd1b3c8ae34f8f26bab29dbaf3c6 pep440-dev
improve/.* 1.3.8 da2c9632ea54fd1b3c8ae34f8f26bab29dbaf3c6 pep440-dev
# staging/maintenance is currently the branch for preparation of 1.3.7rc3
# staging/maintenance is currently the branch for preparation of 1.3.7rc4
# so is regressionfix/...
staging/maintenance 1.3.7rc3 339d1df5a920cc7a2dbae2b5f3410180fea4ceb0 pep440-dev
regressionfix/.* 1.3.7rc3 339d1df5a920cc7a2dbae2b5f3410180fea4ceb0 pep440-dev
staging/maintenance 1.3.7rc4 9c5d996ea2b66a085392981a5e6e0ee341013674 pep440-dev
regressionfix/.* 1.3.7rc4 9c5d996ea2b66a085392981a5e6e0ee341013674 pep440-dev
# every other branch is a development branch and thus gets resolved to 1.4.0-dev for now
.* 1.4.0 7f5d03d0549bcbd26f40e7e4a3297ea5204fb1cc pep440-dev
+8
View File
@@ -1,5 +1,13 @@
# OctoPrint Changelog
## 1.3.7rc3 (2018-03-29)
### Bugfixes
* [#2524](https://github.com/foosel/OctoPrint/issues/2524) Ignore `wait` while job is on hold.
([Commits](https://github.com/foosel/OctoPrint/compare/1.3.7rc2...1.3.7rc3))
## 1.3.7rc2 (2018-03-23)
### Bugfixes
+3 -13
View File
@@ -275,22 +275,11 @@ all requested information or your ticket will be closed.
### Where can I find which version and branch I'm on?
You can find out all of them by taking a look into the lower left corner of the
OctoPrint UI:
![Current version and git branch info in OctoPrint's UI](http://i.imgur.com/HyHMlY2.png)
If you don't have access to the UI you can find out that information via the
command line as well. Either `octoprint --version` or `python setup.py version`
in OctoPrint's folder will tell you the version of OctoPrint you are running
(note: if it doesn't then you are running a version older than 1.1.0,
*upgrade now*). A `git branch` in your OctoPrint installation folder will mark
the branch you are on with a little *. `git rev-parse HEAD` will tell you the
current commit.
Please refer to [this FAQ entry](https://discourse.octoprint.org/t/how-can-i-find-out-the-version-of-octoprint-or-octopi-i-am-running/204/1).
### Where can I find those log files you keep talking about?
Please refer to [this FAQ entry](https://discourse.octoprint.org/t/where-can-i-find-octoprints-log-files/299).
Please refer to [this FAQ entry](https://discourse.octoprint.org/t/where-can-i-find-octoprints-and-octopis-log-files/299/1).
### Where can I find my browser's error console?
@@ -483,6 +472,7 @@ the local version identifier to allow for an exact determination of the active c
* 2017-11-22: Added note on how to run the unit tests
* 2018-03-15: Link to new community forum and some clarifications re bug
reporting
* 2018-03-29: "Where to find version numbers" is now located on the FAQ
## Footnotes
* [1] - If you are wondering why, the problem is that anything that you add
+2 -2
View File
@@ -10,7 +10,6 @@ thanks to everyone who contributed!
* Aleph Objects, Inc.
* Andrew Moorby
* Arnljot Arntsen
* BEEVERYCREATIVE
* Boris Hussein
* Brad Jackson
* Brian E. Tyler
@@ -34,6 +33,7 @@ thanks to everyone who contributed!
* Kazuhiro Ogura
* Kodama Inc.
* Makespace Madrid
* Mark Walker
* Martin Beattie
* Michael Aumock
* Miles Flavel
@@ -55,4 +55,4 @@ thanks to everyone who contributed!
* Thomas Hatley
* Trent Shumay
and 1199 more wonderful people pledging on the [Patreon campaign](https://patreon.com/foosel)!
and 1214 more wonderful people pledging on the [Patreon campaign](https://patreon.com/foosel)!
+3 -4
View File
@@ -280,13 +280,12 @@ Folders
* - ``children``
- 0..*
- Array of :ref:`File information items <sec-api-datamodel-files-file>`
- Contained children for entries of type ``folder``. Will only include children in subfolders in recursive
listings. Not present in non recursive listings, this might be revisited in the future.
- Contained children for entries of type ``folder``. On non recursive listings only present on first level
sub folders!
* - ``size``
- 0..1
- Number
- The size of all files contained in the folder and its subfolders. Not present in non recursive listings, this might
be revisited in the future.
- The size of all files contained in the folder and its subfolders. Not present in non recursive listings!
Files
'''''
+31 -2
View File
@@ -82,8 +82,37 @@ Retrieve all files
"path": "folderA",
"type": "folder",
"typePath": ["folder"],
"children": [],
"size": 1334
"children": [
{
"name": "whistle_v2_copy.gcode",
"path": "whistle_v2_copy.gcode",
"type": "machinecode",
"typePath": ["machinecode", "gcode"],
"hash": "...",
"size": 1468987,
"date": 1378847754,
"origin": "local",
"refs": {
"resource": "http://example.com/api/files/local/folderA/whistle_v2_copy.gcode",
"download": "http://example.com/downloads/files/local/folderA/whistle_v2_copy.gcode"
},
"gcodeAnalysis": {
"estimatedPrintTime": 1188,
"filament": {
"length": 810,
"volume": 5.36
}
},
"print": {
"failure": 4,
"success": 23,
"last": {
"date": 1387144346,
"success": true
}
}
}
]
}
],
"free": "3.2GB"
+9 -1
View File
@@ -934,7 +934,7 @@ Use the following settings to configure the server:
# Settings if OctoPrint is running behind a reverse proxy (haproxy, nginx, apache, ...).
# These are necessary in order to make OctoPrint generate correct external URLs so
# that AJAX requests and download URLs work.
# that AJAX requests and download URLs work, and so that client IPs are read correctly.
reverseProxy:
# The request header from which to determine the URL prefix under which OctoPrint
@@ -968,6 +968,14 @@ Use the following settings to configure the server:
# (X-Forwarded-Host by default, see above) with forwarded requests.
hostFallback:
# List of trusted downstream servers for which to ignore the IP address when trying to determine
# the connecting client's IP address. If you have OctoPrint behind more than one reverse proxy
# you should add their IPs here so that they won't be interpreted as the client's IP. One reverse
# proxy will be handled correctly by default.
trustedDownstream:
- 192.168.1.254
- 192.168.23.42
# Settings for file uploads to OctoPrint, such as maximum allowed file size and
# header suffixes to use for streaming uploads. OctoPrint does some nifty things internally in
# order to allow streaming of large file uploads to the application rather than just storing
+1 -1
View File
@@ -16,7 +16,7 @@ import octoprint_setuptools
INSTALL_REQUIRES = [
"flask>=0.12,<0.13",
"werkzeug>=0.11.1,<0.12",
"tornado>=4.4.2,<4.5",
"tornado>=5.0.1,<6",
"Jinja2>=2.8,<2.9", # Jinja 2.9 has breaking changes WRT template scope - we can't
# guarantee backwards compatibility for plugins and such with that
# version, hence we need to pin to a lower version for now. See #1697
+1 -1
View File
@@ -198,7 +198,7 @@ def init_logging(settings, use_logging_file=True, logging_file=None, default_con
},
"handlers": {
"console": {
"class": "logging.StreamHandler",
"class": "octoprint.logging.handlers.OctoPrintStreamHandler",
"level": "DEBUG",
"formatter": "simple",
"stream": "ext://sys.stdout"
+9 -3
View File
@@ -153,7 +153,8 @@ class StorageInterface(object):
from root of base folder
:param function filter: a filter that matches the files that are to be returned, may be left out in which case no
filtering will take place
:param bool recursive: will also step into sub folders for building the complete list if set to True
:param bool recursive: will also step into sub folders for building the complete list if set to True, otherwise will only
do one step down into sub folders to be able to populate the ``children``.
:return: a dictionary mapping entry names to entry data that represents the whole file list
"""
raise NotImplementedError()
@@ -1277,7 +1278,7 @@ class LocalFileStorage(StorageInterface):
if metadata_dirty:
self._save_metadata(path, metadata)
def _list_folder(self, path, base="", entry_filter=None, recursive=True, **kwargs):
def _list_folder(self, path, base="", entry_filter=None, recursive=True, include_children=True, **kwargs):
if entry_filter is None:
entry_filter = kwargs.get("filter", None)
@@ -1385,8 +1386,14 @@ class LocalFileStorage(StorageInterface):
sub_result = self._list_folder(entry_path, base=path_in_location + "/", entry_filter=entry_filter,
recursive=recursive)
entry_data["children"] = sub_result
elif include_children:
sub_result = self._list_folder(entry_path, base=path_in_location + "/", entry_filter=entry_filter,
recursive=False, include_children=False)
entry_data["children"] = sub_result
if not entry_filter or entry_filter(entry_name, entry_data):
# only add folders passing the optional filter
def get_size():
total_size = 0
for element in entry_data["children"].values():
@@ -1395,7 +1402,6 @@ class LocalFileStorage(StorageInterface):
return total_size
# only add folders passing the optional filter
extended_entry_data = dict()
extended_entry_data.update(entry_data)
if recursive:
+39 -17
View File
@@ -6,10 +6,30 @@ import os
import re
import time
# noinspection PyCompatibility
import concurrent.futures
class AsyncLogHandlerMixin(logging.Handler):
def __init__(self, *args, **kwargs):
self._executor = concurrent.futures.ThreadPoolExecutor(max_workers=1)
super(AsyncLogHandlerMixin, self).__init__(*args, **kwargs)
def emit(self, record):
try:
self._executor.submit(self._emit, record)
except:
self.handleError(record)
def _emit(self, record):
# noinspection PyUnresolvedReferences
super(AsyncLogHandlerMixin, self).emit(record)
class CleaningTimedRotatingFileHandler(logging.handlers.TimedRotatingFileHandler):
def __init__(self, *args, **kwargs):
logging.handlers.TimedRotatingFileHandler.__init__(self, *args, **kwargs)
super(CleaningTimedRotatingFileHandler, self).__init__(*args, **kwargs)
# clean up old files on handler start
if self.backupCount > 0:
@@ -17,7 +37,7 @@ class CleaningTimedRotatingFileHandler(logging.handlers.TimedRotatingFileHandler
os.remove(s)
class OctoPrintLogHandler(CleaningTimedRotatingFileHandler):
class OctoPrintLogHandler(AsyncLogHandlerMixin, CleaningTimedRotatingFileHandler):
rollover_callbacks = []
@classmethod
@@ -25,32 +45,33 @@ class OctoPrintLogHandler(CleaningTimedRotatingFileHandler):
cls.rollover_callbacks.append((callback, args, kwargs))
def doRollover(self):
CleaningTimedRotatingFileHandler.doRollover(self)
super(OctoPrintLogHandler, self).doRollover()
for rcb in self.rollover_callbacks:
callback, args, kwargs = rcb
callback(*args, **kwargs)
class SerialLogHandler(logging.handlers.RotatingFileHandler):
class OctoPrintStreamHandler(AsyncLogHandlerMixin, logging.StreamHandler):
pass
_do_rollover = False
_suffix_template = "%Y-%m-%d_%H-%M-%S"
_file_pattern = re.compile(r"^\d{4}-\d{2}-\d{2}_\d{2}-\d{2}-\d{2}$")
class SerialLogHandler(AsyncLogHandlerMixin, logging.handlers.RotatingFileHandler):
do_rollover = False
suffix_template = "%Y-%m-%d_%H-%M-%S"
file_pattern = re.compile(r"^\d{4}-\d{2}-\d{2}_\d{2}-\d{2}-\d{2}$")
@classmethod
def on_open_connection(cls):
cls._do_rollover = True
cls.do_rollover = True
def __init__(self, *args, **kwargs):
logging.handlers.RotatingFileHandler.__init__(self, *args, **kwargs)
super(SerialLogHandler, self).__init__(*args, **kwargs)
self.cleanupFiles()
def emit(self, record):
logging.handlers.RotatingFileHandler.emit(self, record)
def shouldRollover(self, record):
return self.__class__._do_rollover
return type(self).do_rollover
def getFilesToDelete(self):
"""
@@ -64,7 +85,7 @@ class SerialLogHandler(logging.handlers.RotatingFileHandler):
for fileName in fileNames:
if fileName[:plen] == prefix:
suffix = fileName[plen:]
if self.__class__._file_pattern.match(suffix):
if type(self).file_pattern.match(suffix):
result.append(os.path.join(dirName, fileName))
result.sort()
if len(result) < self.backupCount:
@@ -88,7 +109,7 @@ class SerialLogHandler(logging.handlers.RotatingFileHandler):
if os.path.exists(self.baseFilename):
# figure out creation date/time to use for file suffix
t = time.localtime(os.stat(self.baseFilename).st_mtime)
dfn = self.baseFilename + "." + time.strftime(self.__class__._suffix_template, t)
dfn = self.baseFilename + "." + time.strftime(type(self).suffix_template, t)
if os.path.exists(dfn):
os.remove(dfn)
os.rename(self.baseFilename, dfn)
@@ -98,8 +119,8 @@ class SerialLogHandler(logging.handlers.RotatingFileHandler):
self.stream = self._open()
class RecordingLogHandler(logging.Handler):
def __init__(self, target=None, level=logging.NOTSET):
logging.Handler.__init__(self, level=level)
def __init__(self, target=None, *args, **kwargs):
super(RecordingLogHandler, self).__init__(*args, **kwargs)
self._buffer = []
self._target = target
@@ -133,6 +154,7 @@ class RecordingLogHandler(logging.Handler):
return len(self._buffer)
# noinspection PyAbstractClass
class CombinedLogHandler(logging.Handler):
def __init__(self, *handlers):
logging.Handler.__init__(self)
@@ -1 +1 @@
table td.settings_plugin_plugin_manager_plugins_name,table th.settings_plugin_plugin_manager_plugins_name{text-overflow:ellipsis;text-align:left}table td.settings_plugin_plugin_manager_plugins_actions,table th.settings_plugin_plugin_manager_plugins_actions{text-align:center;width:80px}table td.settings_plugin_plugin_manager_plugins_actions a,table th.settings_plugin_plugin_manager_plugins_actions a{text-decoration:none;color:#000}table td.settings_plugin_plugin_manager_plugins_actions a.disabled,table th.settings_plugin_plugin_manager_plugins_actions a.disabled{color:#ccc;cursor:default}#settings_plugin_pluginmanager_repositorydialog .slimScrollDiv{margin-bottom:20px;padding-right:12px}#settings_plugin_pluginmanager_repositorydialog h4{position:relative}#settings_plugin_pluginmanager_repositorydialog h4 a.dropdown-toggle{color:inherit;text-decoration:none;font-size:14px}#settings_plugin_pluginmanager_repositorydialog h4 ul.dropdown-menu{font-size:14px}#settings_plugin_pluginmanager_repositorydialog .form-search{text-align:center;margin-bottom:5px!important}#settings_plugin_pluginmanager_repositorydialog .form-inline{padding:5px 10px 5px 5px;margin-bottom:0}#settings_plugin_pluginmanager_repositorydialog .form-inline .help-block{margin-bottom:0;font-size:85%}#settings_plugin_pluginmanager_repositorydialog #settings_plugin_pluginmanager_repositorydialog_unavailable{overflow:hidden;width:100%;height:300px;background-image:url(../img/repo_unavailable.png);text-align:center;display:table}#settings_plugin_pluginmanager_repositorydialog #settings_plugin_pluginmanager_repositorydialog_unavailable div{display:table-cell;vertical-align:middle}#settings_plugin_pluginmanager_repositorydialog #settings_plugin_pluginmanager_repositorydialog_list{overflow:hidden;width:auto;height:300px}#settings_plugin_pluginmanager_repositorydialog #settings_plugin_pluginmanager_repositorydialog_list .entry{border-bottom:1px solid #ddd;padding:5px 10px 5px 5px}#settings_plugin_pluginmanager_workingdialog_output .message{font-weight:700}#settings_plugin_pluginmanager_workingdialog_output .error{font-weight:700;color:#900}#settings_plugin_pluginmanager_workingdialog_output .stdout{color:#333}#settings_plugin_pluginmanager_workingdialog_output .stderr{color:#900}#settings_plugin_pluginmanager_workingdialog_output .call{color:#009}
table td.settings_plugin_plugin_manager_plugins_name,table th.settings_plugin_plugin_manager_plugins_name{text-overflow:ellipsis;text-align:left}table td.settings_plugin_plugin_manager_plugins_actions,table th.settings_plugin_plugin_manager_plugins_actions{text-align:center;width:80px}table td.settings_plugin_plugin_manager_plugins_actions a,table th.settings_plugin_plugin_manager_plugins_actions a{text-decoration:none;color:#000}table td.settings_plugin_plugin_manager_plugins_actions a.disabled,table th.settings_plugin_plugin_manager_plugins_actions a.disabled{color:#ccc;cursor:default}#settings_plugin_pluginmanager_repositorydialog h4{position:relative}#settings_plugin_pluginmanager_repositorydialog h4 a.dropdown-toggle{color:inherit;text-decoration:none;font-size:14px}#settings_plugin_pluginmanager_repositorydialog h4 ul.dropdown-menu{font-size:14px}#settings_plugin_pluginmanager_repositorydialog .form-search{text-align:center;margin-bottom:5px!important}#settings_plugin_pluginmanager_repositorydialog .form-inline{padding:5px 10px 5px 5px;margin-bottom:0}#settings_plugin_pluginmanager_repositorydialog .form-inline .help-block{margin-bottom:0;font-size:85%}#settings_plugin_pluginmanager_repositorydialog #settings_plugin_pluginmanager_repositorydialog_unavailable{overflow:hidden;width:100%;height:300px;background-image:url(../img/repo_unavailable.png);text-align:center;display:table}#settings_plugin_pluginmanager_repositorydialog #settings_plugin_pluginmanager_repositorydialog_unavailable div{display:table-cell;vertical-align:middle}#settings_plugin_pluginmanager_repositorydialog #settings_plugin_pluginmanager_repositorydialog_list{width:auto;height:300px;overflow-x:hidden;overflow-y:scroll;padding-right:2px}#settings_plugin_pluginmanager_repositorydialog #settings_plugin_pluginmanager_repositorydialog_list .entry{border-bottom:1px solid #ddd;padding:5px}#settings_plugin_pluginmanager_workingdialog_output .message{font-weight:700}#settings_plugin_pluginmanager_workingdialog_output .error{font-weight:700;color:#900}#settings_plugin_pluginmanager_workingdialog_output .stdout{color:#333}#settings_plugin_pluginmanager_workingdialog_output .stderr{color:#900}#settings_plugin_pluginmanager_workingdialog_output .call{color:#009}
@@ -23,13 +23,6 @@ table {
}
#settings_plugin_pluginmanager_repositorydialog {
.slimScrollDiv {
@scrollBar: 10px;
margin-bottom: 20px;
padding-right: @scrollBar + 2px;
}
h4 {
position: relative;
@@ -75,14 +68,15 @@ table {
}
#settings_plugin_pluginmanager_repositorydialog_list {
overflow: hidden;
width: auto;
height: 300px;
overflow-x: hidden;
overflow-y: scroll;
padding-right: 2px;
.entry {
border-bottom: 1px solid #ddd;
padding: 5px;
padding-right: 10px;
}
}
}
@@ -155,7 +155,7 @@
</form>
<div data-bind="visible: repositoryAvailable()">
<div id="settings_plugin_pluginmanager_repositorydialog_list" data-bind="slimScrolledForeach: {data: repositoryplugins.paginatedItems, slimscroll: {height: '306px', size: '10px', distance: 0, railVisible: true, alwaysVisible: true, scrollBy: '102px'} }">
<div id="settings_plugin_pluginmanager_repositorydialog_list" data-bind="foreach: repositoryplugins.paginatedItems">
<div class="entry">
<div class="row-fluid">
<div class="span9">
+20 -21
View File
@@ -222,6 +222,7 @@ class Server(object):
pluginManager = self._plugin_manager
# monkey patch some stuff
util.sockjs.fix_tornado5_compatibility()
util.flask.enable_additional_translations(additional_folders=[self._settings.getBaseFolder("translations")])
# setup app
@@ -616,7 +617,15 @@ class Server(object):
self._stop_intermediary_server()
# initialize and bind the server
self._server = util.tornado.CustomHTTPServer(self._tornado_app, max_body_sizes=max_body_sizes, default_max_body_size=self._settings.getInt(["server", "maxSize"]))
trusted_downstream = self._settings.get(["server", "reverseProxy", "trustedDownstream"])
if not isinstance(trusted_downstream, list):
self._logger.warn("server.reverseProxy.trustedDownstream is not a list, skipping")
trusted_downstreams = []
self._server = util.tornado.CustomHTTPServer(self._tornado_app,
max_body_sizes=max_body_sizes,
default_max_body_size=self._settings.getInt(["server", "maxSize"]),
xheaders=True,
trusted_downstream=trusted_downstream)
self._server.listen(self._port, address=self._host)
### From now on it's ok to launch subprocesses again
@@ -783,7 +792,8 @@ class Server(object):
timer.start()
def _setup_app(self, app):
from octoprint.server.util.flask import ReverseProxiedEnvironment, OctoPrintFlaskRequest, OctoPrintFlaskResponse, OctoPrintJsonEncoder
from octoprint.server.util.flask import ReverseProxiedEnvironment, OctoPrintFlaskRequest, \
OctoPrintFlaskResponse, OctoPrintJsonEncoder, OctoPrintSessionInterface
s = settings()
@@ -819,6 +829,7 @@ class Server(object):
OctoPrintFlaskRequest.environment_wrapper = reverse_proxied
app.request_class = OctoPrintFlaskRequest
app.response_class = OctoPrintFlaskResponse
app.session_interface = OctoPrintSessionInterface()
@app.before_request
def before_request():
@@ -1314,25 +1325,13 @@ class Server(object):
js_filters = ["sourcemap_remove", "js_delimiter_bundler"]
js_plugin_filters = ["sourcemap_remove", "js_delimiter_bundler"]
if self._settings.getBoolean(["feature", "legacyPluginAssets"]):
# TODO remove again in 1.3.8
def js_bundles_for_plugins(collection, filters=None):
"""Produces Bundle instances"""
result = OrderedDict()
for plugin, assets in collection.items():
if len(assets):
result[plugin] = Bundle(*assets, filters=filters)
return result
else:
def js_bundles_for_plugins(collection, filters=None):
"""Produces JsPluginBundle instances that output IIFE wrapped assets"""
result = OrderedDict()
for plugin, assets in collection.items():
if len(assets):
result[plugin] = JsPluginBundle(plugin, *assets, filters=filters)
return result
def js_bundles_for_plugins(collection, filters=None):
"""Produces JsPluginBundle instances that output IIFE wrapped assets"""
result = OrderedDict()
for plugin, assets in collection.items():
if len(assets):
result[plugin] = JsPluginBundle(plugin, *assets, filters=filters)
return result
js_core = dynamic_core_assets["js"] + \
all_assets_for_plugins(dynamic_plugin_assets["bundled"]["js"]) + \
+13 -4
View File
@@ -122,8 +122,7 @@ def getSettings():
"modelSizeDetection": s.getBoolean(["feature", "modelSizeDetection"]),
"printCancelConfirmation": s.getBoolean(["feature", "printCancelConfirmation"]),
"g90InfluencesExtruder": s.getBoolean(["feature", "g90InfluencesExtruder"]),
"autoUppercaseBlacklist": s.get(["feature", "autoUppercaseBlacklist"]),
"legacyPluginAssets": s.getBoolean(["feature", "legacyPluginAssets"])
"autoUppercaseBlacklist": s.get(["feature", "autoUppercaseBlacklist"])
},
"serial": {
"port": connectionOptions["portPreference"],
@@ -140,6 +139,7 @@ def getSettings():
"timeoutTemperatureAutoreport": s.getFloat(["serial", "timeout", "temperatureAutoreport"]),
"timeoutSdStatus": s.getFloat(["serial", "timeout", "sdStatus"]),
"timeoutSdStatusAutoreport": s.getFloat(["serial", "timeout", "sdStatusAutoreport"]),
"timeoutBaudrateDetectionPause": s.getFloat(["serial", "timeout", "baudrateDetectionPause"]),
"log": s.getBoolean(["serial", "log"]),
"additionalPorts": s.get(["serial", "additionalPorts"]),
"additionalBaudrates": s.get(["serial", "additionalBaudrates"]),
@@ -360,7 +360,6 @@ def _saveSettings(data):
if "modelSizeDetection" in data["feature"]: s.setBoolean(["feature", "modelSizeDetection"], data["feature"]["modelSizeDetection"])
if "printCancelConfirmation" in data["feature"]: s.setBoolean(["feature", "printCancelConfirmation"], data["feature"]["printCancelConfirmation"])
if "g90InfluencesExtruder" in data["feature"]: s.setBoolean(["feature", "g90InfluencesExtruder"], data["feature"]["g90InfluencesExtruder"])
if "legacyPluginAssets" in data["feature"]: s.setBoolean(["feature", "legacyPluginAssets"], data["feature"]["legacyPluginAssets"])
if "autoUppercaseBlacklist" in data["feature"] and isinstance(data["feature"]["autoUppercaseBlacklist"], (list, tuple)): s.set(["feature", "autoUppercaseBlacklist"], data["feature"]["autoUppercaseBlacklist"])
if "serial" in data.keys():
@@ -376,6 +375,7 @@ def _saveSettings(data):
if "timeoutTemperatureAutoreport" in data["serial"]: s.setFloat(["serial", "timeout", "temperatureAutoreport"], data["serial"]["timeoutTemperatureAutoreport"])
if "timeoutSdStatus" in data["serial"]: s.setFloat(["serial", "timeout", "sdStatus"], data["serial"]["timeoutSdStatus"])
if "timeoutSdStatusAutoreport" in data["serial"]: s.setFloat(["serial", "timeout", "sdStatusAutoreport"], data["serial"]["timeoutSdStatusAutoreport"])
if "timeoutBaudrateDetectionPause" in data["serial"]: s.setFloat(["serial", "timeout", "baudrateDetectionPause"], data["serial"]["timeoutBaudrateDetectionPause"])
if "additionalPorts" in data["serial"] and isinstance(data["serial"]["additionalPorts"], (list, tuple)): s.set(["serial", "additionalPorts"], data["serial"]["additionalPorts"])
if "additionalBaudrates" in data["serial"] and isinstance(data["serial"]["additionalBaudrates"], (list, tuple)): s.set(["serial", "additionalBaudrates"], data["serial"]["additionalBaudrates"])
if "longRunningCommands" in data["serial"] and isinstance(data["serial"]["longRunningCommands"], (list, tuple)): s.set(["serial", "longRunningCommands"], data["serial"]["longRunningCommands"])
@@ -427,7 +427,16 @@ def _saveSettings(data):
if "watched" in data["folder"]: s.setBaseFolder("watched", data["folder"]["watched"])
if "temperature" in data.keys():
if "profiles" in data["temperature"]: s.set(["temperature", "profiles"], data["temperature"]["profiles"])
if "profiles" in data["temperature"]:
result = []
for profile in data["temperature"]["profiles"]:
try:
profile["bed"] = int(profile["bed"])
profile["extruder"] = int(profile["extruder"])
except ValueError:
pass
result.append(profile)
s.set(["temperature", "profiles"], result)
if "cutoff" in data["temperature"]:
try:
cutoff = int(data["temperature"]["cutoff"])
+2
View File
@@ -75,6 +75,8 @@ def loginFromApiKeyRequestHandler():
if not loginUser(user):
return _flask.make_response("Invalid API key", 403)
_flask.g.login_via_apikey = True
def loginFromAuthorizationHeaderRequestHandler():
"""
+8
View File
@@ -498,6 +498,14 @@ class OctoPrintFlaskResponse(flask.Response):
flask.Response.set_cookie(self, key, expires=0, max_age=0, path=path, domain=domain)
class OctoPrintSessionInterface(flask.sessions.SecureCookieSessionInterface):
def save_session(self, app, session, response):
if flask.g.get("login_via_apikey", False):
return
return super(OctoPrintSessionInterface, self).save_session(app, session, response)
#~~ passive login helper
def passive_login():
+94
View File
@@ -28,6 +28,100 @@ import wrapt
import json
def fix_tornado5_compatibility():
"""
Monkey patches sockjs tornado dependency to fix tornado 5.x compatibility
See https://github.com/mrjoes/sockjs-tornado/issues/113 for reason.
We need to first patch StatsCollector since that also gets used by SockJSRouter.
"""
import sockjs.tornado.router
import sockjs.tornado.stats
from tornado import ioloop, version_info
def fixed_stats_init(self, io_loop):
### Copied from sockjs.tornado.stats.StatsCollector.__init__
# Sessions
self.sess_active = 0
# Avoid circular reference
self.sess_transports = dict()
# Connections
self.conn_active = 0
self.conn_ps = sockjs.tornado.stats.MovingAverage()
# Packets
self.pack_sent_ps = sockjs.tornado.stats.MovingAverage()
self.pack_recv_ps = sockjs.tornado.stats.MovingAverage()
self._callback = ioloop.PeriodicCallback(self._update,
1000)
self._callback.start()
sockjs.tornado.stats.StatsCollector.__init__ = fixed_stats_init
def fixed_router_init(self, connection, prefix="", user_settings=dict(), io_loop=None, session_kls=None):
### Copied from sockjs.tornado.router.SockJSRouter.__init__
# TODO: Version check
if version_info[0] < 2:
raise Exception('sockjs-tornado requires Tornado 2.0 or higher.')
# Store connection class
self._connection = connection
# Initialize io_loop
self.io_loop = io_loop or ioloop.IOLoop.instance()
# Settings
self.settings = sockjs.tornado.router.DEFAULT_SETTINGS.copy()
if user_settings:
self.settings.update(user_settings)
self.websockets_enabled = 'websocket' not in self.settings['disabled_transports']
self.cookie_needed = self.settings['jsessionid']
# Sessions
self._session_kls = session_kls if session_kls else sockjs.tornado.router.session.Session
self._sessions = sockjs.tornado.router.sessioncontainer.SessionContainer()
check_interval = self.settings['session_check_interval'] * 1000
self._sessions_cleanup = ioloop.PeriodicCallback(self._sessions.expire,
check_interval)
self._sessions_cleanup.start()
# Stats
self.stats = sockjs.tornado.stats.StatsCollector(self.io_loop)
# Initialize URLs
base = prefix + r'/[^/.]+/(?P<session_id>[^/.]+)'
# Generate global handler URLs
self._transport_urls = [('%s/%s$' % (base, p[0]), p[1], dict(server=self))
for p in sockjs.tornado.router.GLOBAL_HANDLERS]
for k, v in sockjs.tornado.router.TRANSPORTS.items():
if k in self.settings['disabled_transports']:
continue
# Only version 1 is supported
self._transport_urls.append(
(r'%s/%s$' % (base, k),
v,
dict(server=self))
)
# Generate static URLs
self._transport_urls.extend([('%s%s' % (prefix, k), v, dict(server=self))
for k, v in sockjs.tornado.router.STATIC_HANDLERS.items()])
sockjs.tornado.router.SockJSRouter.__init__ = fixed_router_init
class ThreadSafeSession(sockjs.tornado.session.Session):
def __init__(self, conn, server, session_id, expiry=None):
sockjs.tornado.session.Session.__init__(self, conn, server, session_id, expiry=expiry)
+5 -1
View File
@@ -695,7 +695,8 @@ class CustomHTTPServer(tornado.httpserver.HTTPServer):
def handle_stream(self, stream, address):
context = tornado.httpserver._HTTPRequestContext(stream, address,
self.protocol)
self.protocol,
self.trusted_downstream)
conn = CustomHTTP1ServerConnection(stream, self.conn_params, context)
self._connections.add(conn)
conn.start_serving(self)
@@ -742,6 +743,9 @@ class CustomHTTP1Connection(tornado.http1connection.HTTP1Connection):
"""
def __init__(self, stream, is_client, params=None, context=None):
if params is None:
params = CustomHTTP1ConnectionParameters()
tornado.http1connection.HTTP1Connection.__init__(self, stream, is_client, params=params, context=context)
import re
+44 -6
View File
@@ -91,7 +91,7 @@ default_settings = {
"autoconnect": False,
"log": False,
"timeout": {
"detection": 0.5,
"detection": 1,
"connection": 10,
"communication": 30,
"communicationBusy": 3,
@@ -100,7 +100,8 @@ default_settings = {
"temperatureAutoreport": 2,
"sdStatus": 1,
"sdStatusAutoreport": 1,
"resendOk": .5
"resendOk": .5,
"baudrateDetectionPause": 1.0
},
"maxCommunicationTimeouts": {
"idle": 2,
@@ -163,7 +164,8 @@ default_settings = {
"schemeFallback": None,
"hostFallback": None,
"serverFallback": None,
"portFallback": None
"portFallback": None,
"trustedDownstream": []
},
"uploads": {
"maxSize": 1 * 1024 * 1024 * 1024, # 1GB
@@ -237,8 +239,7 @@ default_settings = {
"modelSizeDetection": True,
"printCancelConfirmation": True,
"autoUppercaseBlacklist": ["M117"],
"g90InfluencesExtruder": False,
"legacyPluginAssets": False # TODO remove again in 1.3.8
"g90InfluencesExtruder": False
},
"folder": {
"uploads": None,
@@ -919,7 +920,8 @@ class Settings(object):
self._migrate_gcode_scripts,
self._migrate_core_system_commands,
self._migrate_serial_features,
self._migrate_resend_without_ok
self._migrate_resend_without_ok,
self._migrate_string_temperature_profile_values
)
for migrate in migrators:
@@ -931,6 +933,8 @@ class Settings(object):
def _migrate_gcode_scripts(self, config):
"""
Migrates an old development version of gcode scripts to the new template based format.
Added in 1.2.0
"""
dirty = False
@@ -955,6 +959,8 @@ class Settings(object):
def _migrate_printer_parameters(self, config):
"""
Migrates the old "printer > parameters" data structure to the new printer profile mechanism.
Added in 1.2.0
"""
default_profile = config["printerProfiles"]["defaultProfile"] if "printerProfiles" in config and "defaultProfile" in config["printerProfiles"] else dict()
dirty = False
@@ -1020,6 +1026,8 @@ class Settings(object):
"""
Migrates the old "server > baseUrl" and "server > scheme" configuration entries to
"server > reverseProxy > prefixFallback" and "server > reverseProxy > schemeFallback".
Added in 1.2.0
"""
if "server" in config.keys() and ("baseUrl" in config["server"] or "scheme" in config["server"]):
prefix = ""
@@ -1047,6 +1055,8 @@ class Settings(object):
"""
Migrates the old event configuration format of type "events > gcodeCommandTrigger" and
"event > systemCommandTrigger" to the new events format.
Added in 1.2.0
"""
if "events" in config.keys() and ("gcodeCommandTrigger" in config["events"] or "systemCommandTrigger" in config["events"]):
self._logger.info("Migrating config (event subscriptions)...")
@@ -1142,6 +1152,8 @@ class Settings(object):
If server commands for action is not yet set, migrates command. Otherwise only
deletes definition from custom system commands.
Added in 1.3.0
"""
changed = False
@@ -1188,6 +1200,8 @@ class Settings(object):
Migrates feature flags identified as serial specific from the feature to the serial config tree and vice versa.
If a flag already exists in the target tree, only deletes the copy in the source tree.
Added in 1.3.7
"""
changed = False
@@ -1231,6 +1245,8 @@ class Settings(object):
Migrates supportResendsWithoutOk flag from boolean to ("always", "detect", "never") value range.
True gets migrated to "always", False to "detect" (which is the new default).
Added in 1.3.7
"""
if "serial" in config and "supportResendsWithoutOk" in config["serial"] \
and config["serial"]["supportResendsWithoutOk"] not in ("always", "detect", "never"):
@@ -1242,6 +1258,28 @@ class Settings(object):
return True
return False
def _migrate_string_temperature_profile_values(self, config):
"""
Migrates/fixes temperature profile wrongly saved with strings instead of ints as temperature values.
Added in 1.3.8
"""
if "temperature" in config and "profiles" in config["temperature"]:
profiles = config["temperature"]["profiles"]
if any(map(lambda x: not isinstance(x.get("extruder", 0), int) or not isinstance(x.get("bed", 0), int),
profiles)):
result = []
for profile in profiles:
try:
profile["extruder"] = int(profile["extruder"])
profile["bed"] = int(profile["bed"])
except ValueError:
pass
result.append(profile)
config["temperature"]["profiles"] = result
return True
return False
def backup(self, suffix, path=None):
import shutil
+1 -1
View File
@@ -1 +1 @@
.btn{display:inline-block;*display:inline;*zoom:1;padding:4px 12px;margin-bottom:0;font-size:14px;line-height:20px;text-align:center;vertical-align:middle;cursor:pointer;color:#333;text-shadow:0 1px 1px rgba(255,255,255,.75);background-color:#f5f5f5;background-image:-moz-linear-gradient(top,#fff,#e6e6e6);background-image:-webkit-gradient(linear,0 0,0 100%,from(#fff),to(#e6e6e6));background-image:-webkit-linear-gradient(top,#fff,#e6e6e6);background-image:-o-linear-gradient(top,#fff,#e6e6e6);background-image:linear-gradient(to bottom,#fff,#e6e6e6);background-repeat:repeat-x;*background-color:#e6e6e6;filter:progid:DXImageTransform.Microsoft.gradient(enabled=false);border:1px solid #ccc;*border:0;border-bottom-color:#b3b3b3;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px;*margin-left:.3em;-webkit-box-shadow:inset 0 1px 0 rgba(255,255,255,.2),0 1px 2px rgba(0,0,0,.05);-moz-box-shadow:inset 0 1px 0 rgba(255,255,255,.2),0 1px 2px rgba(0,0,0,.05);box-shadow:inset 0 1px 0 rgba(255,255,255,.2),0 1px 2px rgba(0,0,0,.05)}.btn.active,.btn.disabled,.btn:active,.btn:focus,.btn:hover,.btn[disabled]{color:#333;background-color:#e6e6e6;*background-color:#d9d9d9}.btn.active,.btn:active{background-color:#ccc \9}.btn:first-child{*margin-left:0}.btn:focus,.btn:hover{color:#333;text-decoration:none;background-position:0 -15px;-webkit-transition:background-position .1s linear;-moz-transition:background-position .1s linear;-o-transition:background-position .1s linear;transition:background-position .1s linear}.btn:focus{outline:#333 dotted thin;outline:-webkit-focus-ring-color auto 5px;outline-offset:-2px}.btn.active,.btn:active{background-image:none;outline:0;-webkit-box-shadow:inset 0 2px 4px rgba(0,0,0,.15),0 1px 2px rgba(0,0,0,.05);-moz-box-shadow:inset 0 2px 4px rgba(0,0,0,.15),0 1px 2px rgba(0,0,0,.05);box-shadow:inset 0 2px 4px rgba(0,0,0,.15),0 1px 2px rgba(0,0,0,.05)}.btn.disabled,.btn[disabled]{cursor:default;background-image:none;opacity:.65;filter:alpha(opacity=65);-webkit-box-shadow:none;-moz-box-shadow:none;box-shadow:none}.btn-large{padding:11px 19px;font-size:17.5px;-webkit-border-radius:6px;-moz-border-radius:6px;border-radius:6px}.btn-large [class*=" icon-"],.btn-large [class^=icon-]{margin-top:4px}.btn-small{padding:2px 10px;font-size:11.9px;-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px}.btn-small [class*=" icon-"],.btn-small [class^=icon-]{margin-top:0}.btn-mini [class*=" icon-"],.btn-mini [class^=icon-]{margin-top:-1px}.btn-mini{padding:0 6px;font-size:10.5px;-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px}.btn-block{display:block;width:100%;padding-left:0;padding-right:0;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}.btn-block+.btn-block{margin-top:5px}input[type=submit].btn-block,input[type=reset].btn-block,input[type=button].btn-block{width:100%}.btn-primary{color:#fff;text-shadow:0 -1px 0 rgba(0,0,0,.25);background-color:#006dcc;background-image:-moz-linear-gradient(top,#08c,#04c);background-image:-webkit-gradient(linear,0 0,0 100%,from(#08c),to(#04c));background-image:-webkit-linear-gradient(top,#08c,#04c);background-image:-o-linear-gradient(top,#08c,#04c);background-image:linear-gradient(to bottom,#08c,#04c);background-repeat:repeat-x;border-color:#04c #04c #002a80;border-color:rgba(0,0,0,.1) rgba(0,0,0,.1) rgba(0,0,0,.25);*background-color:#04c;filter:progid:DXImageTransform.Microsoft.gradient(enabled=false)}.btn-primary.active,.btn-primary.disabled,.btn-primary:active,.btn-primary:focus,.btn-primary:hover,.btn-primary[disabled]{color:#fff;background-color:#04c;*background-color:#003bb3}.btn-primary.active,.btn-primary:active{background-color:#039 \9}.btn-warning{color:#fff;text-shadow:0 -1px 0 rgba(0,0,0,.25);background-color:#faa732;background-image:-moz-linear-gradient(top,#fbb450,#f89406);background-image:-webkit-gradient(linear,0 0,0 100%,from(#fbb450),to(#f89406));background-image:-webkit-linear-gradient(top,#fbb450,#f89406);background-image:-o-linear-gradient(top,#fbb450,#f89406);background-image:linear-gradient(to bottom,#fbb450,#f89406);background-repeat:repeat-x;border-color:#f89406 #f89406 #ad6704;border-color:rgba(0,0,0,.1) rgba(0,0,0,.1) rgba(0,0,0,.25);*background-color:#f89406;filter:progid:DXImageTransform.Microsoft.gradient(enabled=false)}.btn-warning.active,.btn-warning.disabled,.btn-warning:active,.btn-warning:focus,.btn-warning:hover,.btn-warning[disabled]{color:#fff;background-color:#f89406;*background-color:#df8505}.btn-warning.active,.btn-warning:active{background-color:#c67605 \9}.btn-danger{color:#fff;text-shadow:0 -1px 0 rgba(0,0,0,.25);background-color:#da4f49;background-image:-moz-linear-gradient(top,#ee5f5b,#bd362f);background-image:-webkit-gradient(linear,0 0,0 100%,from(#ee5f5b),to(#bd362f));background-image:-webkit-linear-gradient(top,#ee5f5b,#bd362f);background-image:-o-linear-gradient(top,#ee5f5b,#bd362f);background-image:linear-gradient(to bottom,#ee5f5b,#bd362f);background-repeaLine truncated
.btn{display:inline-block;*display:inline;*zoom:1;padding:4px 12px;margin-bottom:0;font-size:14px;line-height:20px;text-align:center;vertical-align:middle;cursor:pointer;color:#333;text-shadow:0 1px 1px rgba(255,255,255,.75);background-color:#f5f5f5;background-image:-moz-linear-gradient(top,#fff,#e6e6e6);background-image:-webkit-gradient(linear,0 0,0 100%,from(#fff),to(#e6e6e6));background-image:-webkit-linear-gradient(top,#fff,#e6e6e6);background-image:-o-linear-gradient(top,#fff,#e6e6e6);background-image:linear-gradient(to bottom,#fff,#e6e6e6);background-repeat:repeat-x;*background-color:#e6e6e6;filter:progid:DXImageTransform.Microsoft.gradient(enabled=false);border:1px solid #ccc;*border:0;border-bottom-color:#b3b3b3;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px;*margin-left:.3em;-webkit-box-shadow:inset 0 1px 0 rgba(255,255,255,.2),0 1px 2px rgba(0,0,0,.05);-moz-box-shadow:inset 0 1px 0 rgba(255,255,255,.2),0 1px 2px rgba(0,0,0,.05);box-shadow:inset 0 1px 0 rgba(255,255,255,.2),0 1px 2px rgba(0,0,0,.05)}.btn.active,.btn.disabled,.btn:active,.btn:focus,.btn:hover,.btn[disabled]{color:#333;background-color:#e6e6e6;*background-color:#d9d9d9}.btn.active,.btn:active{background-color:#ccc \9}.btn:first-child{*margin-left:0}.btn:focus,.btn:hover{color:#333;text-decoration:none;background-position:0 -15px;-webkit-transition:background-position .1s linear;-moz-transition:background-position .1s linear;-o-transition:background-position .1s linear;transition:background-position .1s linear}.btn:focus{outline:#333 dotted thin;outline:-webkit-focus-ring-color auto 5px;outline-offset:-2px}.btn.active,.btn:active{background-image:none;outline:0;-webkit-box-shadow:inset 0 2px 4px rgba(0,0,0,.15),0 1px 2px rgba(0,0,0,.05);-moz-box-shadow:inset 0 2px 4px rgba(0,0,0,.15),0 1px 2px rgba(0,0,0,.05);box-shadow:inset 0 2px 4px rgba(0,0,0,.15),0 1px 2px rgba(0,0,0,.05)}.btn.disabled,.btn[disabled]{cursor:default;background-image:none;opacity:.65;filter:alpha(opacity=65);-webkit-box-shadow:none;-moz-box-shadow:none;box-shadow:none}.btn-large{padding:11px 19px;font-size:17.5px;-webkit-border-radius:6px;-moz-border-radius:6px;border-radius:6px}.btn-large [class*=" icon-"],.btn-large [class^=icon-]{margin-top:4px}.btn-small{padding:2px 10px;font-size:11.9px;-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px}.btn-small [class*=" icon-"],.btn-small [class^=icon-]{margin-top:0}.btn-mini [class*=" icon-"],.btn-mini [class^=icon-]{margin-top:-1px}.btn-mini{padding:0 6px;font-size:10.5px;-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px}.btn-block{display:block;width:100%;padding-left:0;padding-right:0;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}.btn-block+.btn-block{margin-top:5px}input[type=submit].btn-block,input[type=reset].btn-block,input[type=button].btn-block{width:100%}.btn-primary{color:#fff;text-shadow:0 -1px 0 rgba(0,0,0,.25);background-color:#006dcc;background-image:-moz-linear-gradient(top,#08c,#04c);background-image:-webkit-gradient(linear,0 0,0 100%,from(#08c),to(#04c));background-image:-webkit-linear-gradient(top,#08c,#04c);background-image:-o-linear-gradient(top,#08c,#04c);background-image:linear-gradient(to bottom,#08c,#04c);background-repeat:repeat-x;border-color:#04c #04c #002a80;border-color:rgba(0,0,0,.1) rgba(0,0,0,.1) rgba(0,0,0,.25);*background-color:#04c;filter:progid:DXImageTransform.Microsoft.gradient(enabled=false)}.btn-primary.active,.btn-primary.disabled,.btn-primary:active,.btn-primary:focus,.btn-primary:hover,.btn-primary[disabled]{color:#fff;background-color:#04c;*background-color:#003bb3}.btn-primary.active,.btn-primary:active{background-color:#039 \9}.btn-warning{color:#fff;text-shadow:0 -1px 0 rgba(0,0,0,.25);background-color:#faa732;background-image:-moz-linear-gradient(top,#fbb450,#f89406);background-image:-webkit-gradient(linear,0 0,0 100%,from(#fbb450),to(#f89406));background-image:-webkit-linear-gradient(top,#fbb450,#f89406);background-image:-o-linear-gradient(top,#fbb450,#f89406);background-image:linear-gradient(to bottom,#fbb450,#f89406);background-repeat:repeat-x;border-color:#f89406 #f89406 #ad6704;border-color:rgba(0,0,0,.1) rgba(0,0,0,.1) rgba(0,0,0,.25);*background-color:#f89406;filter:progid:DXImageTransform.Microsoft.gradient(enabled=false)}.btn-warning.active,.btn-warning.disabled,.btn-warning:active,.btn-warning:focus,.btn-warning:hover,.btn-warning[disabled]{color:#fff;background-color:#f89406;*background-color:#df8505}.btn-warning.active,.btn-warning:active{background-color:#c67605 \9}.btn-danger{color:#fff;text-shadow:0 -1px 0 rgba(0,0,0,.25);background-color:#da4f49;background-image:-moz-linear-gradient(top,#ee5f5b,#bd362f);background-image:-webkit-gradient(linear,0 0,0 100%,from(#ee5f5b),to(#bd362f));background-image:-webkit-linear-gradient(top,#ee5f5b,#bd362f);background-image:-o-linear-gradient(top,#ee5f5b,#bd362f);background-image:linear-gradient(to bottom,#ee5f5b,#bd362f);background-repeaLine truncated
@@ -294,10 +294,7 @@ $(function() {
var entryElement = self.getEntryElement({path: focus.path, origin: focus.location});
if (entryElement) {
// scroll to uploaded element
var entryOffset = entryElement.offsetTop;
self.listElement.slimScroll({
scrollTo: entryOffset + "px"
});
self.listElement.scrollTop(entryElement.offsetTop);
// highlight uploaded element
var element = $(entryElement);
@@ -793,7 +790,7 @@ $(function() {
}
});
self.listElement = $(".gcode_files");
self.listElement = $("#files").find(".scroll-wrapper");
self.addFolderDialog = $("#add_folder_dialog");
self.addFolderDialog.on("shown", function() {
@@ -143,7 +143,6 @@ $(function() {
self.feature_printCancelConfirmation = ko.observable(undefined);
self.feature_g90InfluencesExtruder = ko.observable(undefined);
self.feature_autoUppercaseBlacklist = ko.observable(undefined);
self.feature_legacyPluginAssets = ko.observable(undefined);
self.serial_port = ko.observable();
self.serial_baudrate = ko.observable();
@@ -159,6 +158,7 @@ $(function() {
self.serial_timeoutTemperatureAutoreport = ko.observable(undefined);
self.serial_timeoutSdStatus = ko.observable(undefined);
self.serial_timeoutSdStatusAutoreport = ko.observable(undefined);
self.serial_timeoutBaudrateDetectionPause = ko.observable(undefined);
self.serial_log = ko.observable(undefined);
self.serial_additionalPorts = ko.observable(undefined);
self.serial_additionalBaudrates = ko.observable(undefined);
@@ -729,6 +729,23 @@ $(function() {
});
return result;
}
},
temperature: {
profiles: function() {
var result = [];
_.each(self.temperature_profiles(), function(profile) {
try {
result.push({
name: profile.name,
extruder: Math.floor(_.isNumber(profile.extruder) ? profile.extruder : parseInt(profile.extruder)),
bed: Math.floor(_.isNumber(profile.bed) ? profile.bed : parseInt(profile.bed))
});
} catch (ex) {
// ignore
}
});
return result;
}
}
};
+13 -2
View File
@@ -645,10 +645,14 @@ ul.dropdown-menu li a {
#files {
.gcode_files {
@padding: 5px;
@scrollBar: 10px;
@line-height: 20px;
padding-right: @scrollBar + 2px;
.scroll-wrapper {
overflow-x: hidden;
overflow-y: scroll;
height: 306px;
padding-right: 2px;
}
.entry {
padding: @padding;
@@ -888,6 +892,13 @@ ul.dropdown-menu li a {
}
}
#settings_appearance_managelanguagesdialog_list {
width: auto;
height: 300px;
overflow-x: hidden;
overflow-y: scroll;
padding-right: 2px;
}
#settings_appearance_managelanguagesdialog_emptylist {
overflow: hidden;
@@ -61,7 +61,7 @@
<h4>{{ _('Available Language Packs') }}</h4>
<div data-bind="visible: languagePacksAvailable()">
<div id="settings_appearance_managelanguagesdialog_list" data-bind="slimScrolledForeach: translations.paginatedItems" style="height: 300px">
<div id="settings_appearance_managelanguagesdialog_list" data-bind="foreach: translations.paginatedItems">
<div class="entry">
<strong><a href="#" class="fa" data-bind="toggleContent: { class: 'fa-caret-right fa-caret-down', parent: '.entry', container: '.packs' }"><i class="fa fa-caret-down"></i> <span data-bind="text: $root.languagePackDisplay($data)"></span></a></strong>
<div class="packs">
@@ -1,18 +1,4 @@
<form class="form-horizontal">
<div class="control-group">
<div class="controls">
<label class="checkbox">
<input type="checkbox" data-bind="checked: feature_legacyPluginAssets" id="settings-legacyPluginAssets"> {{ _('Enable legacy plugin asset bundling') }} <span class="label label-info">Compatibility</span>
<span class="help-block">{% trans url="https://octoprint.org/blog/2017/12/01/heads-up-plugin-authors/" %}
Enable this, save and restart your server if you are running into issues with plugins with OctoPrint
1.3.6 or later that used to work with OctoPrint up to version 1.3.5. See <a href="{{ url }}">here</a>
for details on why this is happening. Note that this legacy flag will be removed in a future
OctoPrint version (currently planned for 1.3.8), so urge the authors of affected plugins to push
an update with a fix.
{% endtrans %}</span>
</label>
</div>
</div>
<div class="control-group">
<div class="controls">
<label class="checkbox">
@@ -146,6 +146,16 @@
<div>
<div><small><a href="#" class="muted" data-bind="toggleContent: { class: 'fa-caret-right fa-caret-down', container: '#settings_serial_timeouts_timeouts .hide' }"><i class="fa fa-caret-right"></i> {{ _('Advanced options') }}</a></small></div>
<div class="hide">
<div class="control-group" title="{{ _('Time to wait after opening the serial connection before starting baudrate detection') }}">
<label class="control-label" for="settings-serialTimeoutBaudrateDetectionPause">{{ _('Initial baudrate detection pause') }}</label>
<div class="controls">
<div class="input-append">
<input type="number" step="any" min="0" class="input-mini text-right" data-bind="value: serial_timeoutBaudrateDetectionPause" id="settings-serialTimeoutBaudrateDetectionPause">
<span class="add-on">s</span>
</div>
<span class="help-block">{{ _('Some controllers need a bit of a breather before baudrate detection after initial connect. If baudrate detection fails due to a hanging controller, try increasing this value.') }}</span>
</div>
</div>
<div class="control-group" title="{{ _('Maximum consecutive communication timeouts while idle. More than this and the printer will be considered to be gone. Set to 0 to disable.') }}">
<label class="control-label" for="settings-serialMaxTimeoutsIdle">{{ _('Max. consecutive timeouts while idle') }}</label>
<div class="controls">
@@ -40,11 +40,11 @@
<input type="text" class="span12 text-right" data-bind="value: name">
</div>
<div class="input-append span3">
<input type="number" class="input-mini text-right" data-bind="value: extruder">
<input type="number" min="0" step="1" class="input-mini text-right" data-bind="value: extruder">
<span class="add-on">&deg;C</span>
</div>
<div class="input-append span3">
<input type="number" class="input-mini text-right" data-bind="value: bed">
<input type="number" min="0" step="1" class="input-mini text-right" data-bind="value: bed">
<span class="add-on">&deg;C</span>
</div>
<div class="span2">
+3 -3
View File
@@ -7,9 +7,9 @@
<div class="back-path"><small class="muted">{{ _('Currently in') }} <span data-bind="text: currentPath"></span></small></div>
</div>
<!-- ko slimScrolledForeach: {data: filesAndFolders, slimscroll: {height: "306px", size: "10px", distance: 0, railVisible: true, alwaysVisible: true, scrollBy: "102px"} } -->
<div class="entry" data-bind="attr: { id: $root.getEntryId($data) }, template: { name: $root.templateFor($data), data: $data }, css: $data.type"></div>
<!-- /ko -->
<div class="scroll-wrapper" data-bind="foreach: filesAndFolders">
<div class="entry" data-bind="attr: { id: $root.getEntryId($data) }, template: { name: $root.templateFor($data), data: $data }, css: $data.type"></div>
</div>
<script type="text/html" id="files_template_machinecode">
<div class="title clickable" data-bind="click: function() { if ($root.enableSelect($data)) { $root.loadFile($data, false); } else { return; } }, css: $root.getSuccessClass($data), style: { 'font-weight': $root.listHelper.isSelected($data) ? 'bold' : 'normal' }, text: display"></div>
+55 -35
View File
@@ -418,7 +418,7 @@ class MachineCom(object):
self._printerProfileManager = printerProfileManager
self._state = self.STATE_NONE
self._serial = None
self._baudrateDetectList = baudrateList()
self._baudrateDetectList = []
self._baudrateDetectRetry = 0
self._temperatureTargetSetThreshold = 25
self._tempOffsets = dict()
@@ -1414,10 +1414,15 @@ class MachineCom(object):
self._log("Connected to: %s, starting monitor" % self._serial)
if self._baudrate == 0:
self._serial.timeout = 0.01
try_hello = False
self._log("Starting baud rate detection")
self._log("Starting baud rate detection...")
self._changeState(self.STATE_DETECT_BAUDRATE)
# Some controllers (e.g. Original Prusa) don't appear to like too fast serial interaction after
# open, so let's wait a bit before the first baudrate detection step
time.sleep(settings().getFloat(["serial", "timeout", "baudrateDetectionPause"]))
self._perform_baudrate_detection_step(init=True)
else:
self._changeState(self.STATE_CONNECTING)
@@ -1429,9 +1434,6 @@ class MachineCom(object):
supportRepetierTargetTemp = settings().getBoolean(["serial", "repetierTargetTemp"])
supportWait = settings().getBoolean(["serial", "supportWait"])
connection_timeout = settings().getFloat(["serial", "timeout", "connection"])
detection_timeout = settings().getFloat(["serial", "timeout", "detection"])
# enqueue the "hello command" first thing
if try_hello:
self.sayHello()
@@ -1544,7 +1546,7 @@ class MachineCom(object):
handled = False
# process oks
if line.startswith("ok") or (self.isPrinting() and supportWait and line == "wait"):
if line.startswith("ok") or (self.isPrinting() and not self.job_on_hold and supportWait and line == "wait"):
# ok only considered handled if it's alone on the line, might be
# a response to an M105 or an M114
self._handle_ok()
@@ -1874,30 +1876,8 @@ class MachineCom(object):
### Baudrate detection
if self._state == self.STATE_DETECT_BAUDRATE:
if line == '' or time.time() > self._timeout:
if self._baudrateDetectRetry > 0:
self._serial.timeout = detection_timeout
self._baudrateDetectRetry -= 1
self._serial.write('\n')
self._log("Baudrate test retry: %d" % (self._baudrateDetectRetry))
self.sayHello(tags={"trigger:baudrate_detection",})
elif len(self._baudrateDetectList) > 0:
baudrate = self._baudrateDetectList.pop(0)
try:
self._serial.baudrate = baudrate
if self._serial.timeout != connection_timeout:
self._serial.timeout = connection_timeout
self._log("Trying baudrate: %d" % (baudrate))
self._baudrateDetectRetry = 5
self._timeout = get_new_timeout("communicationBusy" if self._busy_protocol_detected else "communication", self._timeout_intervals)
self._serial.write('\n')
self.sayHello(tags={"trigger:baudrate_detection",})
except:
self._log("Unexpected error while setting baudrate {}: {}".format(baudrate, get_exception_string()))
self._logger.exception("Unexpceted error while setting baudrate {}".format(baudrate))
else:
error_text = "No more baudrates to test, and no suitable baudrate found."
self._trigger_error(error_text, "autodetect_baudrate")
elif 'start' in line or 'ok' in line:
self._perform_baudrate_detection_step()
elif 'start' in line or line.startswith('ok'):
self._onConnected()
if 'start' in line:
self._clear_to_send.set()
@@ -2043,6 +2023,43 @@ class MachineCom(object):
self._log(message + " " + general_message)
self._clear_to_send.set()
def _perform_baudrate_detection_step(self, init=False):
if init:
timeout = settings().getFloat(["serial", "timeout", "connection"])
self._baudrateDetectList = baudrateList()
else:
timeout = settings().getFloat(["serial", "timeout", "detection"])
if self._baudrateDetectRetry > 0:
if self._serial.timeout != timeout:
self._serial.timeout = timeout
self._timeout = time.time() + timeout
self._log("Baudrate test retry #{}".format(5 - self._baudrateDetectRetry))
self._baudrateDetectRetry -= 1
self._do_send_without_checksum("", log=False) # new line to reset things
self.sayHello(tags={"trigger:baudrate_detection", })
elif len(self._baudrateDetectList) > 0:
baudrate = self._baudrateDetectList.pop(0)
try:
self._serial.baudrate = baudrate
if self._serial.timeout != timeout:
self._serial.timeout = timeout
self._timeout = time.time() + timeout
self._log("Trying baudrate: {}".format(baudrate))
self._baudrateDetectRetry = 4
self._do_send_without_checksum("", log=False) # new line to reset things
self.sayHello(tags={"trigger:baudrate_detection", })
except:
self._log("Unexpected error while setting baudrate {}: {}".format(baudrate, get_exception_string()))
self._logger.exception("Unexpected error while setting baudrate {}".format(baudrate))
else:
error_text = "No more baudrates to test, and no suitable baudrate found."
self._trigger_error(error_text, "autodetect_baudrate")
def _finish_heatup(self):
if self._heatupWaitStartTime:
self._heatupWaitTimeLost = self._heatupWaitTimeLost + (time.time() - self._heatupWaitStartTime)
@@ -2285,7 +2302,7 @@ class MachineCom(object):
if baudrate == 0:
baudrates = baudrateList()
serial_obj = serial.Serial(str(port),
115200 if 115200 in baudrates else baudrates[0],
baudrates[0],
timeout=read_timeout,
writeTimeout=10000, # TODO 1.3.8 rename to write_timeout for pyserial >= 3.x
parity=serial.PARITY_ODD)
@@ -2914,7 +2931,9 @@ class MachineCom(object):
modified = True
else:
new_results.append((command, command_type, gcode, subcode, tags))
modified = True
else:
new_results.append((command, command_type, gcode, subcode, tags))
if modified:
if not new_results:
# gcode handler returned None or empty list for all commands, so we'll stop here and return a full out empty result
@@ -2985,11 +3004,12 @@ class MachineCom(object):
command_to_send = command_to_send + "*" + str(checksum)
self._do_send_without_checksum(command_to_send)
def _do_send_without_checksum(self, cmd):
def _do_send_without_checksum(self, cmd, log=True):
if self._serial is None:
return
self._log("Send: " + str(cmd))
if log:
self._log("Send: " + str(cmd))
cmd += "\n"
written = 0