Compare commits

...
13 Commits
Author SHA1 Message Date
Gina Häußge 458ab91f91 🔖 Preparing release of 1.4.1rc4 2020-07-29 10:35:49 +02:00
Gina Häußge ab8ad72bc3 🥅 PMGR: Ensure validity of latest release data
Closes #3661
2020-07-28 19:33:48 +02:00
Gina Häußge 57b085ff5c 🐛 Remove accidentally committed debug code
See #3653
2020-07-27 16:00:39 +02:00
Gina Häußge 0cfc08748b 🐛 Set closed state even if not yet open
And also ensure we only attempt serial auto detect if we are still in
the correct state for it.

Closes #3653
2020-07-27 15:59:47 +02:00
Gina Häußge 0188745d05 🐛 Fix 500 on /api/files/local
Closes #3655
2020-07-27 12:08:39 +02:00
Gina Häußge 5246e2ccb4 🐛 Fix for some bugs in auto detection
Probably related to #3653
2020-07-27 11:35:07 +02:00
Gina Häußge f1d4cb670a 🐛 Fix held back messages not actually being sent
Probably part of #3653
2020-07-27 11:35:07 +02:00
Gina Häußge 9dd1e95eae 🐛 Fix a potential race condition
If the comm layer starts sending state changes (e.g. to auto detect)
before the constructor returns, self._comm in the printer interface is
still None and thus states can't be decoded.

Probably part of #3653
2020-07-27 11:34:55 +02:00
Gina Häußge 6083943e03 🚸 Improve disconnect response while not operational
We don't want to try to send our beforeDisconnect script if we aren't
properly connected, as that will severely delay Disconnect execution, so
we now limit that to operational states and thus allow a quick(er)
connection abort during auto detection or connection attempt.
2020-07-24 13:55:03 +02:00
Gina Häußge a8ba43308e 🐛 Don't drop state messages due to rate limits
Instead hold them back until the next slot.

Otherwise we might never get the final switch to Offline as after that
there are no current data upgrades anymore.
2020-07-24 13:54:56 +02:00
Gina Häußge 4511d8667b ✅ E2E: Add basic upload test 2020-07-22 14:02:36 +02:00
Gina Häußge af3a63fd9b 🐛 Fix a duplicated id 2020-07-21 17:50:12 +02:00
Gina Häußge 93e54f57e0 🔖 staging/maintenance is now 1.4.1rc4.dev 2020-07-15 14:21:32 +02:00
15 changed files with 125 additions and 68 deletions

No files matched your search

+5 -5
View File
@@ -24,13 +24,13 @@ maintenance 1.4.1 2da7aa358d950b4567aaab8f18d6b5779193e077 pep440-dev
fix/.* 1.4.1 2da7aa358d950b4567aaab8f18d6b5779193e077 pep440-dev
improve/.* 1.4.1 2da7aa358d950b4567aaab8f18d6b5779193e077 pep440-dev
# staging/maintenance is currently the branch for preparation of 1.4.1rc3
# staging/maintenance is currently the branch for preparation of 1.4.1rc4
# so is regressionfix/...
staging/maintenance 1.4.1rc3 650d54d1885409fa1d411eb54b9e8c7ff428910f pep440-dev
regressionfix/.* 1.4.1rc3 650d54d1885409fa1d411eb54b9e8c7ff428910f pep440-dev
staging/maintenance 1.4.1rc4 650d54d1885409fa1d411eb54b9e8c7ff428910f pep440-dev
regressionfix/.* 1.4.1rc4 650d54d1885409fa1d411eb54b9e8c7ff428910f pep440-dev
# staging/devel is currently inactive (but has the 1.4.1rc3 namespace)
staging/devel 1.4.1rc3 650d54d1885409fa1d411eb54b9e8c7ff428910f pep440-dev
# staging/devel is currently inactive (but has the 1.4.1rc4 namespace)
staging/devel 1.4.1rc4 650d54d1885409fa1d411eb54b9e8c7ff428910f pep440-dev
# every other branch is a development branch and thus gets resolved to 1.5.0-dev for now
.* 1.5.0 2da7aa358d950b4567aaab8f18d6b5779193e077 pep440-dev
+1 -2
View File
@@ -17,7 +17,6 @@ thanks to everyone who contributed!
* D Brian Kimmel
* DeltaMaker 3D Printers
* Dennis Breining
* Dorian Gray
* Eric Betts
* Ernesto Martinez
* Franziska Kunsmann
@@ -66,4 +65,4 @@ thanks to everyone who contributed!
* Sven Mueller
* Ulrich Kempken
and 1886 more wonderful people pledging on the [Patreon campaign](https://patreon.com/foosel) or via [Github Sponsors](https://github.com/users/foosel/sponsorship)!
and 1932 more wonderful people pledging on the [Patreon campaign](https://patreon.com/foosel) or via [Github Sponsors](https://github.com/users/foosel/sponsorship)!
@@ -13,8 +13,8 @@ from octoprint.util.version import get_octoprint_version_string, is_released_oct
from flask import jsonify
from flask_babel import gettext
SENTRY_URL_SERVER = "https://829e2245ec4d4693a0b708523004c4eb@o118517.ingest.sentry.io/1373987"
SENTRY_URL_COREUI = "https://fcbbcf95f5514b59866c5e7360fba1fe@o118517.ingest.sentry.io/1374096"
SENTRY_URL_SERVER = "https://912dd511a2274c6f99705d926c2b5126@o118517.ingest.sentry.io/1373987"
SENTRY_URL_COREUI = "https://572ed52f42d241c484db1c741e3c131e@o118517.ingest.sentry.io/1374096"
SETTINGS_DEFAULTS = dict(enabled=False,
enabled_unreleased=False,
@@ -268,7 +268,7 @@
<small class="prop" data-bind="visible: $data.stats !== undefined" title="{{ _('Active instances past month')|edq }}"><i class="fa fa-server"></i> <span data-bind="text: $data.stats !== undefined ? formatNumberK($data.stats.instances_month) : 0"></span></small>
<small class="prop" data-bind="visible: $data.github !== undefined && $data.github.stars !== undefined" title="{{ _('Github stars')|edq }}"><i class="fa fa-star"></i> <span data-bind="text: ($data.github !== undefined && $data.github.stars !== undefined) ? formatNumberK($data.github.stars) : 0"></span></small>
<small class="prop" data-bind="visible: $data.github !== undefined && $data.github.last_push !== undefined" title="{{ _('Last push to main branch')|edq }}"><i class="fa fa-refresh"></i> <span data-bind="text: ($data.github !== undefined && $data.github.last_push !== undefined) ? $data.github.last_push.substring(0, 10) : ''"></span></small>
<small class="prop" data-bind="visible: $data.github !== undefined && $data.github.latest_release != undefined" title="{{ _('Latest release & date')|edq }}"><i class="fa fa-tag"></i> <span data-bind="text: $data.github !== undefined && $data.github.latest_release !== undefined ? $data.github.latest_release.tag : ''"></span> (<span data-bind="text: $data.github !== undefined && $data.github.latest_release !== undefined ? $data.github.latest_release.date.substring(0, 10) : ''"></span>)</small>
<small class="prop" data-bind="visible: $data.github !== undefined && $data.github.latest_release != undefined && $data.github.latest_release.tag && $data.github.latest_release.date" title="{{ _('Latest release & date')|edq }}"><i class="fa fa-tag"></i> <span data-bind="text: $data.github !== undefined && $data.github.latest_release !== undefined && $data.github.latest_release.tag ? $data.github.latest_release.tag : ''"></span> (<span data-bind="text: $data.github !== undefined && $data.github.latest_release !== undefined && $data.github.latest_release.date ? $data.github.latest_release.date.substring(0, 10) : ''"></span>)</small>
</div>
</div>
+4 -1
View File
@@ -267,6 +267,7 @@ class Printer(PrinterInterface, comm.MachineComPrintCallback):
logging.getLogger("SERIAL").info("serial.log is currently not enabled, you can enable it via Settings > Serial Connection > Log communication to serial.log")
self._comm = comm.MachineCom(port, baudrate, callbackObject=self, printerProfileManager=self._printerProfileManager)
self._comm.start()
def disconnect(self, *args, **kwargs):
"""
@@ -1505,7 +1506,9 @@ class StateMonitor(object):
self._last_update = monotonic_time()
self._change_event.clear()
except Exception:
logging.getLogger(__name__).exception("Looks like something crashed inside the state update worker. Please report this on the OctoPrint issue tracker (make sure to include logs!)")
logging.getLogger(__name__).exception("Looks like something crashed inside the state update worker. "
"Please report this on the OctoPrint issue tracker (make sure "
"to include logs!)")
def get_current_data(self):
with self._progress_lock:
+6 -1
View File
@@ -63,7 +63,12 @@ def _create_lastmodified(path, recursive):
return max(lms)
else:
storage, path_in_storage = path.split("/", 1)
if "/" in path:
storage, path_in_storage = path.split("/", 1)
else:
storage = path
path_in_storage = None
try:
return fileManager.last_modified(storage, path=path_in_storage, recursive=recursive)
except Exception:
+21 -9
View File
@@ -117,9 +117,12 @@ class PrinterStateConnection(octoprint.vendor.sockjs.tornado.SockJSConnection,
self._remoteAddress = None
self._user = self._userManager.anonymous_user_factory()
self._throttleFactor = 1
self._lastCurrent = 0
self._baseRateLimit = 0.5
self._throttle_factor = 1
self._last_current = 0
self._base_rate_limit = 0.5
self._held_back_current = None
self._held_back_mutex = threading.RLock()
self._register_hooks = self._pluginManager.get_hooks("octoprint.server.sockjs.register")
self._authed_hooks = self._pluginManager.get_hooks("octoprint.server.sockjs.authed")
@@ -222,18 +225,27 @@ class PrinterStateConnection(octoprint.vendor.sockjs.tornado.SockJSConnection,
except ValueError:
self._logger.warning("Got invalid throttle factor from client {}, ignoring: {!r}".format(self._remoteAddress, message["throttle"]))
else:
self._throttleFactor = throttle
self._logger.debug("Set throttle factor for client {} to {}".format(self._remoteAddress, self._throttleFactor))
self._throttle_factor = throttle
self._logger.debug("Set throttle factor for client {} to {}".format(self._remoteAddress, self._throttle_factor))
def on_printer_send_current_data(self, data):
if not self._user.has_permission(Permissions.STATUS):
return
# make sure we rate limit the updates according to our throttle factor
now = time.time()
if now < self._lastCurrent + self._baseRateLimit * self._throttleFactor:
return
self._lastCurrent = now
with self._held_back_mutex:
if self._held_back_current is not None:
self._held_back_current.cancel()
self._held_back_current = None
now = time.time()
delta = self._last_current + self._base_rate_limit * self._throttle_factor - now
if delta > 0:
self._held_back_current = threading.Timer(delta, lambda: self.on_printer_send_current_data(data))
self._held_back_current.start()
return
self._last_current = now
# add current temperature, log and message backlogs to sent data
with self._temperatureBacklogMutex:
+4 -4
View File
@@ -4,7 +4,7 @@
<span class="search-clear" data-bind="click: clearSearchQuery"><i class="fa fa-remove"></i></span>
</div>
</form>
<div class="gcode_files" data-bind="visible: $root.loginState.hasPermissionKo($root.access.permissions.FILES_LIST)">
<div class="gcode_files" data-test-id="files-list" data-bind="visible: $root.loginState.hasPermissionKo($root.access.permissions.FILES_LIST)">
<div class="entry back clickable" data-bind="visible: currentPath() != '', click: function() { $root.navigateUp(); }" style="display: none">
<div class="back-arrow"><i class="fa fa-arrow-left"></i> {{ _('Back') }}</div>
<div class="back-path"><small class="muted">{{ _('Currently in') }} <span data-bind="text: currentPath"></span></small></div>
@@ -67,18 +67,18 @@
<span class="btn btn-primary fileinput-button span6" style="margin-bottom: 10px">
<i class="fa fa-upload"></i>
<span>{{ _('Upload') }}</span>
<input id="gcode_upload" accept="{{ ",".join(supportedExtensions) }}" type="file" name="file" class="fileinput-button">
<input id="gcode_upload" data-test-id="upload-local" accept="{{ ",".join(supportedExtensions) }}" type="file" name="file" class="fileinput-button">
</span>
<span class="btn btn-primary fileinput-button span6" data-bind="enable: $root.isSdReady() && !$root.isPrinting(), css: {disabled: !$root.isSdReady() || $root.isPrinting()}" style="margin-bottom: 10px">
<i class="fa fa-upload"></i>
<span>{{ _('Upload to SD') }}</span>
<input id="gcode_upload_sd" accept="{{ ",".join(supportedExtensions) }}" type="file" name="file" class="fileinput-button" data-bind="enable: isSdReady()">
<input id="gcode_upload_sd" data-test-id="upload-sd" accept="{{ ",".join(supportedExtensions) }}" type="file" name="file" class="fileinput-button" data-bind="enable: isSdReady()">
</span>
{% else %}
<span class="btn btn-primary fileinput-button span12" style="margin-bottom: 10px">
<i class="icon-upload-alt icon-white"></i>
<span>{{ _('Upload') }}</span>
<input id="gcode_upload" accept="{{ ",".join(supportedExtensions) }}" type="file" name="file" class="fileinput-button">
<input id="gcode_upload" data-test-id="upload-local" accept="{{ ",".join(supportedExtensions) }}" type="file" name="file" class="fileinput-button">
</span>
{% endif %}
</div>
+1 -1
View File
@@ -109,7 +109,7 @@
<button class="btn btn-block control-box" data-bind="enable: isOperational() && !isPrinting(), click: function() { $root.sendRetractCommand() }">{{ _('Retract') }}</button>
<!-- Flow rate -->
<div id="control-jog-feedrate" class="jog-panel">
<div id="control-jog-flowrate" class="jog-panel">
<label>{{ _('Flow rate modifier:') }} <a class="text-info" href="javascript:void(0)" data-bind="popover: {placement: 'top', trigger: 'hover', title: '{{ _('Please note!') }}', content: '{{ _('The flow rate can only be set, it cannot be read back from the firmware due to a limitation of the communication protocol. There is no way to show the current setting.') }}'}"><i class="fa fa-info-circle"></i></a></label>
<div class="input-append control-box">
<input type="number" class="input-mini" min="1" step="1" data-bind="value: flowRate, event: { blur: resetFlowRateDisplay, focus: cancelFlowRateDisplayReset }, css: { pulsate_text_opacity: flowRateResetter() !== undefined }">
+38 -16
View File
@@ -648,12 +648,17 @@ class MachineCom(object):
self._monitoring_active = True
self.monitoring_thread = threading.Thread(target=self._monitor, name="comm._monitor")
self.monitoring_thread.daemon = True
self.monitoring_thread.start()
# sending thread
self._send_queue_active = True
self.sending_thread = threading.Thread(target=self._send_loop, name="comm.sending_thread")
self.sending_thread.daemon = True
def start(self):
# doing this here instead of __init__ combats a race condition where
# self._comm in the printer interface is still None on first pushs from
# the comm layer during detection
self.monitoring_thread.start()
self.sending_thread.start()
def __del__(self):
@@ -959,7 +964,7 @@ class MachineCom(object):
self._send_queue_active = False
if self._serial is not None:
if not is_error:
if not is_error and self._state in self.OPERATIONAL_STATES:
self.sendGcodeScript("beforePrinterDisconnected")
if wait:
if timeout is not None:
@@ -990,15 +995,17 @@ class MachineCom(object):
self._logger.exception("Error while trying to close serial port")
is_error = True
# if we are printing, this will also make sure of firing PRINT_FAILED
if is_error:
self._changeState(self.STATE_CLOSED_WITH_ERROR)
else:
self._changeState(self.STATE_CLOSED)
else:
deactivate_monitoring_and_send_queue()
self._serial = None
# if we are printing, this will also make sure of firing PRINT_FAILED
if is_error:
self._changeState(self.STATE_CLOSED_WITH_ERROR)
else:
self._changeState(self.STATE_CLOSED)
if settings().getBoolean(["feature", "sdSupport"]):
self._sdFileList = []
@@ -1677,6 +1684,10 @@ class MachineCom(object):
self._changeState(self.STATE_DETECT_SERIAL)
self._perform_detection_step(init=True)
if not self._state in (self.STATE_CONNECTING, self.STATE_DETECT_SERIAL):
# we got cancelled during connection, bail
return
# Start monitoring the serial port
self._log("Connected to: %s, starting monitor" % self._serial)
@@ -2403,19 +2414,30 @@ class MachineCom(object):
self._detection_candidates))))
def attempt_handshake():
timeout = self._get_communication_timeout_interval()
if self._serial.timeout != timeout:
self._serial.timeout = timeout
self._timeout = self._ok_timeout = monotonic_time() + timeout
log("Handshake attempt #{} with timeout {}s".format(self._detection_retry + 1, timeout))
self._detection_retry += 1
self._do_send_without_checksum(b"", log=False) # new line to reset things
self.sayHello(tags={"trigger:detection", })
timeout = self._get_communication_timeout_interval()
log("Handshake attempt #{} with timeout {}s".format(self._detection_retry, timeout))
try:
if self._serial.timeout != timeout:
self._serial.timeout = timeout
self._timeout = self._ok_timeout = monotonic_time() + timeout
except Exception:
self._log("Unexpected error while setting timeout {}: {}".format(timeout, get_exception_string()))
self._logger.exception("Unexpected error while setting timeout {}".format(timeout))
else:
self._do_send_without_checksum(b"", log=False) # new line to reset things
self.sayHello(tags={"trigger:detection", })
while len(self._detection_candidates) > 0 or self._detection_retry < self.DETECTION_RETRIES:
if self._state not in (self.STATE_DETECT_SERIAL,):
return
if self._detection_retry < self.DETECTION_RETRIES:
if self._serial is None:
self._detection_retry = self.DETECTION_RETRIES
continue
attempt_handshake()
return
+3
View File
@@ -0,0 +1,3 @@
M117 I'm just a test upload during E2E
G28 X0 Y0
M117 That is all folks!
+24
View File
@@ -0,0 +1,24 @@
import { prepare_server, login, await_coreui } from "../util/util"
context('Upload tests', () => {
const username = 'admin';
const password = 'test';
beforeEach(() => {
prepare_server();
// login
login(username, password);
cy.visit('/');
await_coreui();
});
it("uploads file to local via button", () => {
cy.get('[data-test-id=upload-local]')
.attachFile("e2e-test.gcode");
cy.wait("@files");
cy.get('[data-test-id=files-list]')
.contains("e2e-test.gcode");
});
});
+13
View File
@@ -428,6 +428,14 @@
"resolved": "https://registry.npmjs.org/cypress-commands/-/cypress-commands-1.1.0.tgz",
"integrity": "sha512-Q8Jr25pHJQFXwln6Hp8O+Hgs8Z506Y2wA9F1Te2cTajjc5L9gtt9WPOcw1Ogh+OgyqaMHF+uq31vdfImRTio5Q=="
},
"cypress-file-upload": {
"version": "4.0.7",
"resolved": "https://registry.npmjs.org/cypress-file-upload/-/cypress-file-upload-4.0.7.tgz",
"integrity": "sha512-rFFmnoZ2bWyWFpSV09AhkSUgYEiVy70pcQ6nf/mGTMTrVHvKCCCIfRu3TbgVYHbgBq+0hqjfjQrtz4IbgH7qZA==",
"requires": {
"mime": "2.4.6"
}
},
"cypress-plugin-retries": {
"version": "1.5.2",
"resolved": "https://registry.npmjs.org/cypress-plugin-retries/-/cypress-plugin-retries-1.5.2.tgz",
@@ -1083,6 +1091,11 @@
"resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz",
"integrity": "sha1-VSmk1nZUE07cxSZmVoNbD4Ua/O4="
},
"mime": {
"version": "2.4.6",
"resolved": "https://registry.npmjs.org/mime/-/mime-2.4.6.tgz",
"integrity": "sha512-RZKhC3EmpBchfTGBVb8fb+RL2cWyw/32lshnsETttkBAyAUXSGHxbEJWWRXc751DrIxG1q04b8QwMbAwkRPpUA=="
},
"mime-db": {
"version": "1.44.0",
"resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.44.0.tgz",
+1
View File
@@ -19,6 +19,7 @@
"dependencies": {
"cypress": "^4.9.0",
"cypress-commands": "^1.1.0",
"cypress-file-upload": "^4.0.7",
"cypress-plugin-retries": "^1.5.2",
"cypress-terminal-report": "^1.4.1",
"cypress-wait-until": "^1.7.1"
+1 -26
View File
@@ -1,27 +1,2 @@
// ***********************************************
// This example commands.js shows you how to
// create various custom commands and overwrite
// existing commands.
//
// For more comprehensive examples of custom
// commands please read more here:
// https://on.cypress.io/custom-commands
// ***********************************************
//
//
// -- This is a parent command --
// Cypress.Commands.add("login", (email, password) => { ... })
//
//
// -- This is a child command --
// Cypress.Commands.add("drag", { prevSubject: 'element'}, (subject, options) => { ... })
//
//
// -- This is a dual command --
// Cypress.Commands.add("dismiss", { prevSubject: 'optional'}, (subject, options) => { ... })
//
//
// -- This will overwrite an existing command --
// Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... })
import 'cypress-wait-until';
import 'cypress-file-upload';