Merge branch 'maintenance' into devel

This commit is contained in:
Gina Häußge committed 2017-08-25 14:57:00 +02:00
commit adbcc07bae
27 files changed
+337 -104

No files matched your search

+3 -3
View File
@@ -22,10 +22,10 @@ maintenance 1.3.6 1a6dbb3f4a5bef857cdeb13c031b9deca2cf30a2 pep440-dev
fix/.* 1.3.6 1a6dbb3f4a5bef857cdeb13c031b9deca2cf30a2 pep440-dev
improve/.* 1.3.6 1a6dbb3f4a5bef857cdeb13c031b9deca2cf30a2 pep440-dev
# staging/maintenance is currently the branch for preparation of 1.3.5rc3
# staging/maintenance is currently the branch for preparation of 1.3.5rc4
# so is regressionfix/...
staging/maintenance 1.3.5rc3 1f9fe8c8689f727566ae92707fe1e3f40064dcdf pep440-dev
regressionfix/.* 1.3.5rc3 1f9fe8c8689f727566ae92707fe1e3f40064dcdf pep440-dev
staging/maintenance 1.3.5rc4 679674df2282af0c4500367fa93864c6defa3802 pep440-dev
regressionfix/.* 1.3.5rc4 679674df2282af0c4500367fa93864c6defa3802 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
+10
View File
@@ -1,5 +1,15 @@
# OctoPrint Changelog
## 1.3.5rc3 (2017-08-25)
### Bug fixes
* [#2059](https://github.com/foosel/OctoPrint/issues/2059) - Fix an issue causing the new temperature controls to wrap on touch enabled devices when the temperature dropdown is opened.
* [#2090](https://github.com/foosel/OctoPrint/issues/2090) - Fix an issue causing an aborted server startup under Windows if the timing is just right.
* Fix an issue causing rollover of `serial.log` to fail under Windows.
([Commits](https://github.com/foosel/OctoPrint/compare/1.3.5rc2...1.3.5rc3))
## 1.3.5rc2 (2017-07-27)
### Bug fixes
+2 -1
View File
@@ -46,6 +46,7 @@ thanks to everyone who contributed!
* Masayoshi Mitsui
* Michael Aumock
* Miles Flavel
* mitchell hirsch
* Mohammed khorakiwala
* Noe Ruiz
* Patrick McGinnis
@@ -66,4 +67,4 @@ thanks to everyone who contributed!
* Timeshell.ca
* Trent Shumay
and 1117 more wonderful people pledging on the [Patreon campaign](https://patreon.com/foosel)!
and 1130 more wonderful people pledging on the [Patreon campaign](https://patreon.com/foosel)!
+2 -2
View File
@@ -45,7 +45,7 @@ Installing CuraEngine
You'll need a build of ``legacy`` branch of `CuraEngine <http://github.com/Ultimaker/CuraEngine>`_
in order to be able to use the Cura OctoPrint plugin. You can find the ``legacy`` branch
`here <https://github.com/ultimaker/curaengine/tree/legacy>`_.
`here <https://github.com/ultimaker/curaengine/tree/legacy>`__.
If you previously used the `old variant of the Cura integration <https://github.com/foosel/OctoPrint/wiki/Cura-Integration>`_,
you probably still have a fully functional binary lying around in the
@@ -60,7 +60,7 @@ Compiling for Raspbian
.. note::
A binary of CuraEngine 15.04.06 precompiled on Raspbian Jessie Lite 2016-03-18 is available
`here <http://bit.ly/octopi_cura_engine_150406>`_. Don't forget to make it
`here <http://bit.ly/octopi_cura_engine_150406>`__. Don't forget to make it
executable after copying it to your preferred destination on your Pi
(suggestion: ``/usr/local/bin``) with ``chmod +x cura_engine``. Use at your
own risk.
+28 -2
View File
@@ -79,7 +79,7 @@ property instead, manually instantiate your implementation instance and then add
.. onlineinclude:: https://raw.githubusercontent.com/OctoPrint/Plugin-Examples/master/custom_action_command.py
:linenos:
:tab-width: 4
:caption: `custom_action_command.py <https://github.com/OctoPrint/Plugin-Examples/blob/master/custom_action_command.py>`_
:caption: `custom_action_command.py <https://github.com/OctoPrint/Plugin-Examples/blob/master/custom_action_command.py>`__
:name: sec-plugin-concepts-hooks-example
.. _sec-plugins-hooks-ordering:
@@ -370,7 +370,7 @@ octoprint.comm.protocol.action
.. onlineinclude:: https://raw.githubusercontent.com/OctoPrint/Plugin-Examples/master/custom_action_command.py
:linenos:
:tab-width: 4
:caption: `custom_action_command.py <https://github.com/OctoPrint/Plugin-Examples/blob/master/custom_action_command.py>`_
:caption: `custom_action_command.py <https://github.com/OctoPrint/Plugin-Examples/blob/master/custom_action_command.py>`__
:param object comm_instance: The :class:`~octoprint.util.comm.MachineCom` instance which triggered the hook.
:param str line: The complete line as received from the printer, format ``// action:<command>``
@@ -555,6 +555,32 @@ octoprint.comm.protocol.scripts
:return: A 2-tuple in the form ``(prefix, postfix)`` or None
:rtype: tuple or None
.. _sec-plugins-hook-comm-protocol-temperatures-received:
octoprint.comm.protocol.temperatures.received
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. py:function:: protocol_temperatures_received_hook(comm_instance, parsed_temperatures, *args, **kwargs)
Get the parsed temperatures returned by the printer, allowing handlers to modify them prior to handing them off
to the system. Handlers are expected to either return ``parsed_temperatures`` as-is or a modified copy thereof.
``parsed_temperatures`` is a dictionary mapping from tool/bed identifier (``B``, ``T0``, ``T1``) to a 2-tuple of
actual and target temperature, e.g. ``{'B': (45.2, 50.0), 'T0': (178.9, 210.0), 'T1': (21.3, 0.0)}``.
This hook can be useful in cases where a printer e.g. is prone to returning garbage data from time to time, allowing
additional sanity checking to be applied and invalid values to be filtered out. If a handler returns an empty
dictionary or ``None``, no further processing will take place.
**Example**
The following example shows how to filter out actual temperatures that are outside a sane range of 1°C to 300°C.
.. onlineinclude:: https://raw.githubusercontent.com/OctoPrint/Plugin-Examples/master/sanitize_temperatures.py
:linenos:
:tab-width: 4
:caption: `sanitize_temperatures.py <https://github.com/OctoPrint/Plugin-Examples/blob/master/sanitize_temperatures.py>`_
.. _sec-plugins-hook-comm-transport-serial-factory:
octoprint.comm.transport.serial.factory
+2 -1
View File
@@ -194,7 +194,8 @@ def init_logging(settings, use_logging_file=True, logging_file=None, default_con
"level": "DEBUG",
"formatter": "serial",
"backupCount": 3,
"filename": os.path.join(settings.getBaseFolder("logs"), "serial.log")
"filename": os.path.join(settings.getBaseFolder("logs"), "serial.log"),
"delay": True
}
},
"loggers": {
+31 -3
View File
@@ -40,6 +40,7 @@ class Events(object):
# State changes
PRINTER_STATE_CHANGED = "PrinterStateChanged"
PRINTER_RESET = "PrinterReset"
# connect/disconnect by client
CLIENT_OPENED = "ClientOpened"
@@ -62,6 +63,7 @@ class Events(object):
# SD Upload
TRANSFER_STARTED = "TransferStarted"
TRANSFER_DONE = "TransferDone"
TRANSFER_FAILED = "TransferFailed"
# print job
PRINT_STARTED = "PrintStarted"
@@ -132,9 +134,11 @@ class EventManager(object):
self._registeredListeners = collections.defaultdict(list)
self._logger = logging.getLogger(__name__)
self._startup_signaled = False
self._shutdown_signaled = False
self._queue = queue.Queue()
self._held_back = queue.Queue()
self._worker = threading.Thread(target=self._work)
self._worker.daemon = True
@@ -161,7 +165,8 @@ class EventManager(object):
octoprint.plugin.call_plugin(octoprint.plugin.types.EventHandlerPlugin,
"on_event",
args=(event, payload))
args=(event, payload),
initialized=True)
self._logger.info("Event loop shut down")
except:
self._logger.exception("Ooops, the event bus worker loop crashed")
@@ -177,7 +182,30 @@ class EventManager(object):
payload being a payload object specific to the event.
"""
self._queue.put((event, payload))
send_held_back = False
if event == Events.STARTUP:
self._logger.info("Processing startup event, this is our first event")
self._startup_signaled = True
send_held_back = True
self._enqueue(event, payload)
if send_held_back:
self._logger.info("Adding {} events to queue that "
"were held back before startup event".format(self._held_back.qsize()))
while True:
try:
self._queue.put(self._held_back.get(block=False))
except queue.Empty:
break
def _enqueue(self, event, payload):
if self._startup_signaled:
q = self._queue
else:
q = self._held_back
q.put((event, payload))
if event == Events.UPDATED_FILES and "type" in payload and payload["type"] == "printables":
# when sending UpdatedFiles with type "printables", also send another event with deprecated type "gcode"
@@ -185,7 +213,7 @@ class EventManager(object):
import copy
legacy_payload = copy.deepcopy(payload)
legacy_payload["type"] = "gcode"
self._queue.put((event, legacy_payload))
q.put((event, legacy_payload))
def subscribe(self, event, callback):
"""
+3 -2
View File
@@ -1353,8 +1353,9 @@ class LocalFileStorage(StorageInterface):
except:
self._logger.exception("Error while reading .metadata.yaml from {path}".format(**locals()))
else:
self._metadata_cache[path] = deepcopy(metadata)
return metadata
if isinstance(metadata, dict):
self._metadata_cache[path] = deepcopy(metadata)
return metadata
return dict()
def _save_metadata(self, path, metadata):
@@ -28,6 +28,7 @@ class VirtualPrinter(object):
custom_action_regex = re.compile("action_custom ([a-zA-Z0-9_]+)(\s+.*)?")
prepare_ok_regex = re.compile("prepare_ok (.*)")
send_regex = re.compile("send (.*)")
set_ambient_regex = re.compile("set_ambient ([-+]?[0-9]*\.?[0-9]+)")
def __init__(self, seriallog_handler=None, read_timeout=5.0, write_timeout=10.0):
import logging
@@ -71,11 +72,13 @@ class VirtualPrinter(object):
self.sharedNozzle = settings().getBoolean(["devel", "virtualPrinter", "sharedNozzle"])
self.temperatureCount = (1 if self.sharedNozzle else self.extruderCount)
self.temp = [0.0] * self.temperatureCount
self._ambient_temperature = settings().getFloat(["devel", "virtualPrinter", "ambientTemperature"])
self.temp = [self._ambient_temperature] * self.temperatureCount
self.targetTemp = [0.0] * self.temperatureCount
self.bedTemp = self._ambient_temperature
self.bedTargetTemp = 0.0
self.lastTempAt = time.time()
self.bedTemp = 1.0
self.bedTargetTemp = 1.0
self._relative = True
self._lastX = 0.0
@@ -259,6 +262,13 @@ class VirtualPrinter(object):
data += "\n"
if data.startswith("!!DEBUG:") or data.strip() == "!!DEBUG":
debug_command = ""
if data.startswith("!!DEBUG:"):
debug_command = data[len("!!DEBUG:"):].strip()
self._debugTrigger(debug_command)
continue
# shortcut for writing to SD
if self._writingToSdHandle is not None and not "M29" in data:
self._writingToSdHandle.write(data)
@@ -269,12 +279,6 @@ class VirtualPrinter(object):
from octoprint._version import get_versions
self._send("OctoPrint VirtualPrinter v" + get_versions()["version"])
continue
elif data.startswith("!!DEBUG:") or data.strip() == "!!DEBUG":
debug_command = ""
if data.startswith("!!DEBUG:"):
debug_command = data[len("!!DEBUG:"):].strip()
self._debugTrigger(debug_command)
continue
# if we are sending oks before command output, send it now
if len(data.strip()) > 0 and self._okBeforeCommandOutput:
@@ -620,6 +624,7 @@ class VirtualPrinter(object):
custom_action_match = VirtualPrinter.custom_action_regex.match(data)
prepare_ok_match = VirtualPrinter.prepare_ok_regex.match(data)
send_match = VirtualPrinter.send_regex.match(data)
set_ambient_match = VirtualPrinter.set_ambient_regex.match(data)
if sleep_match is not None:
interval = int(sleep_match.group(1))
@@ -645,6 +650,9 @@ class VirtualPrinter(object):
self._prepared_oks.append(ok)
elif send_match is not None:
self._send(send_match.group(1))
elif set_ambient_match is not None:
self._ambient_temperature = float(set_ambient_match.group(1))
self._send("// set ambient temperature to {}".format(self._ambient_temperature))
except:
pass
@@ -719,7 +727,7 @@ class VirtualPrinter(object):
if settings().getBoolean(["devel", "virtualPrinter", "includeCurrentToolInTemps"]):
if includeTarget:
output = "T:%.2f /%.2f %s" % (self.temp[self.currentExtruder], self.targetTemp[self.currentExtruder] + 1, allTempsString)
output = "T:%.2f /%.2f %s" % (self.temp[self.currentExtruder], self.targetTemp[self.currentExtruder], allTempsString)
else:
output = "T:%.2f %s" % (self.temp[self.currentExtruder], allTempsString)
else:
@@ -1000,28 +1008,34 @@ class VirtualPrinter(object):
if os.path.exists(f) and os.path.isfile(f):
os.remove(f)
def _simulateTemps(self, delta=1):
def _simulateTemps(self, delta=0.5):
timeDiff = self.lastTempAt - time.time()
self.lastTempAt = time.time()
def simulate(actual, target, ambient):
if target > 0 and abs(actual - target) > delta:
goal = target
factor = 10
elif not target and abs(actual - ambient) > delta:
goal = ambient
factor = 2
else:
return actual
old = actual
actual += math.copysign(timeDiff * factor, goal - actual)
if math.copysign(1, goal - old) != math.copysign(1, goal - actual):
actual = goal
return actual
for i in range(len(self.temp)):
if i in self.pinnedExtruders:
self.temp[i] = self.pinnedExtruders[i]
continue
if abs(self.temp[i] - self.targetTemp[i]) > delta:
oldVal = self.temp[i]
self.temp[i] += math.copysign(timeDiff * 10, self.targetTemp[i] - self.temp[i])
if math.copysign(1, self.targetTemp[i] - oldVal) != math.copysign(1, self.targetTemp[i] - self.temp[i]):
self.temp[i] = self.targetTemp[i]
if self.temp[i] < 0:
self.temp[i] = 0
if abs(self.bedTemp - self.bedTargetTemp) > delta:
oldVal = self.bedTemp
self.bedTemp += math.copysign(timeDiff * 10, self.bedTargetTemp - self.bedTemp)
if math.copysign(1, self.bedTargetTemp - oldVal) != math.copysign(1, self.bedTargetTemp - self.bedTemp):
self.bedTemp = self.bedTargetTemp
if self.bedTemp < 0:
self.bedTemp = 0
self.temp[i] = simulate(self.temp[i], self.targetTemp[i], self._ambient_temperature)
self.bedTemp = simulate(self.bedTemp, self.bedTargetTemp, self._ambient_temperature)
def _processBuffer(self):
while self.buffered is not None:
+16 -7
View File
@@ -71,6 +71,7 @@ class Printer(PrinterInterface, comm.MachineComPrintCallback):
self._sdStreaming = False
self._sdFilelistAvailable = threading.Event()
self._streamingFinishedCallback = None
self._streamingFailedCallback = None
self._selectedFileMutex = threading.RLock()
self._selectedFile = None
@@ -579,12 +580,13 @@ class Printer(PrinterInterface, comm.MachineComPrintCallback):
return []
return map(lambda x: (x[0][1:], x[1]), self._comm.getSdFiles())
def add_sd_file(self, filename, absolutePath, streamingFinishedCallback):
def add_sd_file(self, filename, absolutePath, on_success=None, on_failure=None):
if not self._comm or self._comm.isBusy() or not self._comm.isSdReady():
self._logger.error("No connection to printer or printer is busy")
return
self._streamingFinishedCallback = streamingFinishedCallback
self._streamingFinishedCallback = on_success
self._streamingFailedCallback = on_failure
self.refresh_sd_files(blocking=True)
existingSdFiles = map(lambda x: x[0], self._comm.getSdFiles())
@@ -1171,19 +1173,26 @@ class Printer(PrinterInterface, comm.MachineComPrintCallback):
self._updateProgressData(completion=0.0, filepos=0, printTime=0)
self._stateMonitor.set_state({"text": self.get_state_string(), "flags": self._getStateFlags()})
def on_comm_file_transfer_done(self, filename):
def on_comm_file_transfer_done(self, filename, failed=False):
self._sdStreaming = False
if self._streamingFinishedCallback is not None:
# in case of SD files, both filename and absolutePath are the same, so we set the (remote) filename for
# both parameters
self._streamingFinishedCallback(filename, filename, FileDestinations.SDCARD)
# in case of SD files, both filename and absolutePath are the same, so we set the (remote) filename for
# both parameters
if failed:
if self._streamingFailedCallback is not None:
self._streamingFailedCallback(filename, filename, FileDestinations.SDCARD)
else:
if self._streamingFinishedCallback is not None:
self._streamingFinishedCallback(filename, filename, FileDestinations.SDCARD)
self._setCurrentZ(None)
self._setJobData(None, None, None)
self._updateProgressData()
self._stateMonitor.set_state({"text": self.get_state_string(), "flags": self._getStateFlags()})
def on_comm_file_transfer_failed(self, filename):
self.on_comm_file_transfer_done(filename, failed=True)
def on_comm_force_disconnect(self):
self.disconnect()
+17 -11
View File
@@ -220,14 +220,13 @@ class Server(object):
### IMPORTANT!
###
### Do not start any subprocesses until the intermediary server shuts down again or they WILL inherit the
### open port and prevent us from firing up Tornado later. Thanks to close_fds not being available on Popen
### on Windows if you also want to be able to redirect stdout/stderr/stdin and fnctl also not being available
### we don't have a good way around this issue besides being careful not to spawn processes here.
### Best do not start any subprocesses until the intermediary server shuts down again or they MIGHT inherit the
### open port and prevent us from firing up Tornado later.
###
### Which kinda sucks tbh.
### The intermediary server's socket should have the CLOSE_EXEC flag (or its equivalent) set where possible, but
### we can only do that if fcntl is availabel or we are on Windows, so better safe than sorry.
###
### See also issue #2035
### See also issues #2035 and #2090
# then initialize the plugin manager
pluginManager.reload_plugins(startup=True, initialize_implementations=False)
@@ -1385,10 +1384,11 @@ class Server(object):
bind_and_activate=False)
# if possible, make sure our socket's port descriptor isn't handed over to subprocesses
if fcntl is not None and hasattr(fcntl, "FD_CLOEXEC"):
flags = fcntl.fcntl(self._intermediary_server.socket, fcntl.F_GETFD)
flags |= fcntl.FD_CLOEXEC
fcntl.fcntl(self._intermediary_server.socket, fcntl.F_SETFD, flags)
from octoprint.util.platform import set_close_exec
try:
set_close_exec(self._intermediary_server.fileno())
except:
self._logger.exception("Error while attempting to set_close_exec on intermediary server socket")
# then bind the server and have it serve our handler until stopped
try:
@@ -1398,7 +1398,13 @@ class Server(object):
self._intermediary_server.server_close()
raise
thread = threading.Thread(target=self._intermediary_server.serve_forever)
def serve():
try:
self._intermediary_server.serve_forever()
except:
self._logger.exception("Error in intermediary server")
thread = threading.Thread(target=serve)
thread.daemon = True
thread.start()
+2 -1
View File
@@ -380,7 +380,8 @@ default_settings = {
"m115ReportCapabilities": False,
"capabilities": {
"AUTOREPORT_TEMP": True
}
},
"ambientTemperature": 21.3
}
}
}
+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
+7 -1
View File
@@ -238,11 +238,17 @@ function DataUpdater(allViewModels, connectCallback, disconnectCallback) {
if (payload.error && payload.error.indexOf("autodetect") == -1) { // ignore "failed to autodetect"
new PNotify({
title: gettext("Unhandled communication error"),
text: _.sprintf(gettext("The was an unhandled error while talking to the printer. Due to that OctoPrint disconnected. Error: %(error)s"), payload),
text: _.sprintf(gettext("There was an unhandled error while talking to the printer. Due to that OctoPrint disconnected. Error: %(error)s"), payload),
type: "error",
hide: false
});
}
} else if (type == "PrinterReset") {
new PNotify({
title: gettext("Printer reset detected"),
text: gettext("It looks like the printer was reset while a connection was active. If this was intentional you may safely ignore this message. Otherwise you should investigate why your printer reset itself, since this will interrupt prints and also file transfers to your printer's SD."),
hide: false
});
}
var legacyEventHandlers = {
+8
View File
@@ -1120,3 +1120,11 @@ var escapeUnprintableCharacters = function(str) {
}
return result;
};
var copyToClipboard = function(text) {
var temp = $("<input>");
$("body").append(temp);
temp.val(text).select();
document.execCommand("copy");
temp.remove();
};
@@ -954,6 +954,23 @@ $(function() {
self.requestData({focus: {location: "sdcard", path: payload.remote}});
};
self.onEventTransferFailed = function(payload) {
self.uploadProgress
.removeClass("progress-striped")
.removeClass("active");
self.uploadProgressBar
.css("width", "0");
self.uploadProgressText("");
new PNotify({
title: gettext("Streaming failed"),
text: _.sprintf(gettext("Did not finish streaming %(local)s to %(remote)s on SD"), payload),
type: "error"
});
self.requestData();
};
self.onServerConnect = self.onServerReconnect = function(payload) {
self._enableDragNDrop(true);
self.requestData();
@@ -475,6 +475,10 @@ $(function() {
});
};
self.copyApiKey = function() {
copyToClipboard(self.api_key());
};
self.showTranslationManager = function() {
self.translationManagerDialog.modal();
return false;
@@ -152,6 +152,10 @@ $(function() {
});
};
self.copyApikey = function() {
copyToClipboard(self.editorApikey());
};
self._updateApikey = function(apikey) {
self.editorApikey(apikey);
self.requestData();
@@ -69,6 +69,10 @@ $(function() {
});
};
self.copyApikey = function() {
copyToClipboard(self.access_apikey());
};
self.generateApikey = function() {
if (!CONFIG_ACCESS_CONTROL) return;
+5 -1
View File
@@ -687,7 +687,11 @@
if (!isActive) {
if ('ontouchstart' in document.documentElement) {
// if mobile we we use a backdrop because click events don't delegate
$('<div class="dropdown-backdrop"/>').insertBefore($(this)).on('click', clearMenus)
// PATCH by foosel based on CapnBry's suggestion - see foosel/OctoPrint#2059 for details
//$('<div class="dropdown-backdrop"/>').insertBefore($(this)).on('click', clearMenus)
$('<div class="dropdown-backdrop"/>').insertAfter($(this)).on('click', clearMenus)
// /PATCH
}
$parent.toggleClass('open')
}
+4 -8
View File
@@ -1313,17 +1313,13 @@ _::-webkit-full-page-media, _:future, :root .full-sized-box {
min-height: inherit;
width: 100%;
}
:not(:last-child) {
border-right: 0;
}
}
}
.input-append.input-block-level > input {
border-right: 0;
}
.input-prepend.input-block-level > input {
border-left: 0;
}
.btn-input-dec,
.btn-input-enc {
//font-size: 80%;
@@ -9,7 +9,7 @@
</thead>
<tbody data-bind="foreach: users.listHelper.paginatedItems">
<tr>
<td class="settings_users_name"><span data-bind="text: name"></span><span class="muted" data-bind="visible: $root.api_enabled() && apikey"><br /><small>{{ _('API Key') }}: <span data-bind="text: apikey"></span></small></span></td>
<td class="settings_users_name"><span data-bind="text: name"></span><span class="muted" data-bind="visible: $root.api_enabled() && apikey"><br /><small>{{ _('API Key') }}: <span data-bind="text: apikey"></span> <a href="javascript:void(0)" title="{{ _('Copy API Key to clipboard') }}" data-bind="click: copyToClipboard(apikey)"><i class="fa fa-copy"></i></a></small></span></td>
<td class="settings_users_active"><i class="fa" data-bind="css: { 'fa-check-square-o': active, 'fa-square-o': !active }"></i></td>
<td class="settings_users_admin"><i class="fa" data-bind="css: { 'fa-check-square-o': admin, 'fa-square-o': !admin }"></i></td>
<td class="settings_users_actions">
@@ -136,10 +136,11 @@
<div class="control-group">
<label class="control-label">{{ _('Current API Key') }}</label>
<div class="controls">
<div class="input-append">
<input type="text" class="input-block-level uneditable-input" data-bind="value: $root.users.editorApikey, valueUpdate: 'input', attr: {placeholder: '{{ _('N/A') }}'}">
<a class="btn" title="Generate new Apikey" data-bind="click: function() { $root.users.confirmGenerateApikey(); }"><i class="fa fa-refresh"></i></a>
<a class="btn btn-danger" title="Delete Apikey" data-bind="click: function() { $root.users.confirmDeleteApikey(); }"><i class="fa fa-trash-o"></i></a>
<div class="input-append input-block-level">
<input type="text" disabled="disabled" data-bind="value: $root.users.editorApikey, valueUpdate: 'input', attr: {placeholder: '{{ _('N/A') }}'}">
<a class="btn add-on" title="Copy API Key to clipboard" data-bind="click: $root.users.copyApikey, enable: $root.users.editorApikey"><i class="fa fa-copy"></i></a>
<a class="btn add-on" title="Generate new API Key" data-bind="click: function() { $root.users.confirmGenerateApikey(); }"><i class="fa fa-refresh"></i></a>
<a class="btn add-on btn-danger" title="Delete API Key" data-bind="click: function() { $root.users.confirmDeleteApikey(); }"><i class="fa fa-trash-o"></i></a>
</div>
</div>
@@ -16,9 +16,10 @@
<div class="control-group">
<label class="control-label" for="settings-apiKey">{{ _('API Key') }}</label>
<div class="controls">
<div class="input-append">
<input type="text" class="input-block-level" disabled="disabled" id="settings-apikey" data-bind="value: api_key, attr: {placeholder: '{{ _('N/A') }}'}">
<button class="btn" title="Generate new API Key" data-bind="click: generateApiKey, enable: api_key"><i class="fa fa-refresh"></i></button>
<div class="input-append input-block-level">
<input type="text" disabled="disabled" id="settings-apikey" data-bind="value: api_key, attr: {placeholder: '{{ _('N/A') }}'}">
<a class="btn add-on" title="Copy API Key to clipboard" data-bind="click: copyApiKey, enable: api_key"><i class="fa fa-copy"></i></a>
<a class="btn add-on" title="Generate new API Key" data-bind="click: generateApiKey, enable: api_key"><i class="fa fa-refresh"></i></a>
</div>
<span class="help-block">{{ _('Please note that changes to the API key are applied immediately, without having to "Save" first.') }}</span>
</div>
@@ -105,7 +105,7 @@
<div class="control-group">
<div class="controls">
<label class="checkbox">
<input type="checkbox" data-bind="checked: serial_disconnectOnErrors" id="settings-disconnectOnErrors"> {{ _('Not only cancel ongoing prints but also disconnect on unhandled errors from the firmware.') }}</span>
<input type="checkbox" data-bind="checked: serial_disconnectOnErrors" id="settings-disconnectOnErrors"> {{ _('Not only cancel ongoing prints but also disconnect on unhandled errors from the firmware.') }}
</label>
</div>
</div>
@@ -23,10 +23,11 @@
<div class="control-group">
<label class="control-label" for="userSettings-access_apikey">{{ _('Current API Key') }}</label>
<div class="controls">
<div class="input-append">
<input type="text" class="input-block-level" disabled="disabled" id="userSettings-access_apikey" data-bind="value: access_apikey, attr: {placeholder: '{{ _('N/A') }}'}">
<button class="btn" title="Generate new API Key" data-bind="click: generateApikey"><i class="fa fa-refresh"></i></button>
<button class="btn btn-danger" title="Delete API Key" data-bind="click: deleteApikey, enable: access_apikey"><i class="fa fa-trash-o"></i></button>
<div class="input-append input-block-level">
<input type="text" disabled="disabled" id="userSettings-access_apikey" data-bind="value: access_apikey, attr: {placeholder: '{{ _('N/A') }}'}">
<a class="btn add-on" title="Copy API Key to clipboard" data-bind="click: copyApikey, enable: access_apikey"><i class="fa fa-copy"></i></a>
<a class="btn add-on" title="Generate new API Key" data-bind="click: generateApikey"><i class="fa fa-refresh"></i></a>
<a class="btn btn-danger add-on" title="Delete API Key" data-bind="click: deleteApikey, enable: access_apikey"><i class="fa fa-trash-o"></i></a>
</div>
<span class="help-block">{{ _('Please note that changes to the API key are applied immediately, without having to "Confirm" first.') }}</span>
</div>
+70 -21
View File
@@ -442,6 +442,8 @@ class MachineCom(object):
self._gcodescript_hooks = self._pluginManager.get_hooks("octoprint.comm.protocol.scripts")
self._serial_factory_hooks = self._pluginManager.get_hooks("octoprint.comm.transport.serial.factory")
self._temperature_hooks = self._pluginManager.get_hooks("octoprint.comm.protocol.temperatures.received")
# SD status data
self._sdEnabled = settings().getBoolean(["feature", "sdSupport"])
self._sdAvailable = False
@@ -878,7 +880,7 @@ class MachineCom(object):
def startFileTransfer(self, filename, localFilename, remoteFilename):
if not self.isOperational() or self.isBusy():
logging.info("Printer is not operational or busy")
self._logger.info("Printer is not operational or busy")
return
with self._jobLock:
@@ -891,6 +893,39 @@ class MachineCom(object):
eventManager().fire(Events.TRANSFER_STARTED, {"local": localFilename, "remote": remoteFilename})
self._callback.on_comm_file_transfer_started(remoteFilename, self._currentFile.getFilesize())
def cancelFileTransfer(self):
if not self.isOperational() or not self.isStreaming():
self._logger.info("Printer is not operational or not streaming")
return
self._finishFileTransfer(failed=True)
def _finishFileTransfer(self, failed=False):
with self._jobLock:
remote = self._currentFile.getRemoteFilename()
self._sendCommand("M29")
if failed:
self.deleteSdFile(remote)
payload = {
"local": self._currentFile.getLocalFilename(),
"remote": remote,
"time": self.getPrintTime()
}
self._currentFile = None
self._changeState(self.STATE_OPERATIONAL)
if failed:
self._callback.on_comm_file_transfer_failed(remote)
eventManager().fire(Events.TRANSFER_FAILED, payload)
else:
self._callback.on_comm_file_transfer_done(remote)
eventManager().fire(Events.TRANSFER_DONE, payload)
self.refreshSdFiles()
def selectFile(self, filename, sd):
if self.isBusy():
return
@@ -921,13 +956,18 @@ class MachineCom(object):
self._callback.on_comm_print_job_cancelled()
def cancelPrint(self, firmware_error=None):
if not self.isOperational() or self.isStreaming():
if not self.isOperational():
return
if not self.isBusy() or self._currentFile is None:
# we aren't even printing, nothing to cancel...
return
if self.isStreaming():
# we are streaming, we handle cancelling that differently...
self.cancelFileTransfer()
return
def _on_M400_sent():
# we don't call on_print_job_cancelled on our callback here
# because we do this only after our M114 has been answered
@@ -1092,6 +1132,14 @@ class MachineCom(object):
current_tool = self._currentTool if self._currentTool is not None else 0
maxToolNum, parsedTemps = parse_temperature_line(line, current_tool)
for name, hook in self._temperature_hooks.items():
try:
parsedTemps = hook(self, parsedTemps)
if parsedTemps is None or not parsedTemps:
return
except:
self._logger.exception("Error while processing temperatures in {}, skipping".format(name))
if "T0" in parsedTemps.keys():
for n in range(maxToolNum + 1):
tool = "T%d" % n
@@ -1525,11 +1573,22 @@ class MachineCom(object):
self.STATE_PAUSED,
self.STATE_TRANSFERING_FILE):
if line == "start": # exact match, to be on the safe side
message = "Printer sent 'start' while already operational. External reset? " \
"Resetting line numbers to be on the safe side"
self._log(message)
self._logger.warn(message)
self.resetLineNumbers()
if self._state in (self.STATE_OPERATIONAL,):
message = "Printer sent 'start' while already operational. External reset? " \
"Resetting line numbers to be on the safe side"
self._log(message)
self._logger.warn(message)
self.resetLineNumbers()
else:
verb = "streaming to SD" if self.isStreaming() else "printing"
message = "Printer sent 'start' while {}. External reset? " \
"Aborting job since printer lost state.".format(verb)
self._log(message)
self._logger.warn(message)
self.cancelPrint()
eventManager().fire(Events.PRINTER_RESET)
except:
self._logger.exception("Something crashed inside the serial connection loop, please report this in OctoPrint's bug tracker:")
@@ -1965,20 +2024,7 @@ class MachineCom(object):
line = self._currentFile.getNext()
if line is None:
if self.isStreaming():
self._sendCommand("M29")
remote = self._currentFile.getRemoteFilename()
payload = {
"local": self._currentFile.getLocalFilename(),
"remote": remote,
"time": self.getPrintTime()
}
self._currentFile = None
self._changeState(self.STATE_OPERATIONAL)
self._callback.on_comm_file_transfer_done(remote)
eventManager().fire(Events.TRANSFER_DONE, payload)
self.refreshSdFiles()
self._finishFileTransfer()
else:
self._callback.on_comm_print_job_done()
self._changeState(self.STATE_OPERATIONAL)
@@ -2727,6 +2773,9 @@ class MachineComPrintCallback(object):
def on_comm_file_transfer_done(self, filename):
pass
def on_comm_file_transfer_failed(self, filename):
pass
def on_comm_force_disconnect(self):
pass
+41
View File
@@ -0,0 +1,41 @@
# coding=utf-8
from __future__ import absolute_import, division, print_function
__license__ = 'GNU Affero General Public License http://www.gnu.org/licenses/agpl.html'
__copyright__ = "Copyright (C) 2017 The OctoPrint Project - Released under terms of the AGPLv3 License"
import sys
try:
import fcntl
except ImportError:
fcntl = None
# set_close_exec
if fcntl is not None and hasattr(fcntl, "FD_CLOEXEC"):
def set_close_exec(handle):
flags = fcntl.fcntl(handle, fcntl.F_GETFD)
flags |= fcntl.FD_CLOEXEC
fcntl.fcntl(handle, fcntl.F_SETFD, flags)
elif sys.platform == "win32":
def set_close_exec(handle):
import ctypes
import ctypes.wintypes
# see https://msdn.microsoft.com/en-us/library/ms724935(v=vs.85).aspx
SetHandleInformation = ctypes.windll.kernel32.SetHandleInformation
SetHandleInformation.argtypes = (ctypes.wintypes.HANDLE, ctypes.wintypes.DWORD, ctypes.wintypes.DWORD)
SetHandleInformation.restype = ctypes.c_bool
HANDLE_FLAG_INHERIT = 0x00000001
result = SetHandleInformation(handle, HANDLE_FLAG_INHERIT, 0)
if not result:
raise ctypes.GetLastError()
else:
def set_close_exec(handle):
# no-op
pass