diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 057d9d623..6e9a6b433 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -90,52 +90,52 @@ jobs: run: | pip install dist/OctoPrint-*.tar.gz - test-e2e: - name: ๐Ÿงช E2E tests - needs: build - runs-on: ubuntu-16.04 - steps: - - name: โฌ‡ Checkout code - uses: actions/checkout@v2 - - - name: โฌ‡ Download build result - uses: actions/download-artifact@v1 - with: - name: dist - path: dist - - name: ๐Ÿ— Set up Python 3.7 - uses: actions/setup-python@v1 - with: - python-version: 3.7 - - name: ๐Ÿš€ Install wheel - run: | - pip install dist/OctoPrint-*-py2.py3-none-any.whl - - - name: ๐Ÿ— Create base config for test server - run: | - mkdir e2econfig - cp -r .github/fixtures/with_acl/* e2econfig - - - name: ๐Ÿš€ Run Cypress - uses: cypress-io/github-action@v2 - with: - working-directory: tests/cypress - browser: chrome - start: 'octoprint -b ${{ github.workspace }}/e2econfig serve --host 127.0.0.1 --port 5000' - wait-on: 'http://127.0.0.1:5000/online.txt' - - - name: โฌ† Upload screenshots - uses: actions/upload-artifact@v1 - if: failure() - with: - name: cypress-screenshots - path: tests/cypress/screenshots - - name: โฌ† Upload videos - uses: actions/upload-artifact@v1 - if: always() - with: - name: cypress-videos - path: tests/cypress/videos + #test-e2e: + # name: ๐Ÿงช E2E tests + # needs: build + # runs-on: ubuntu-16.04 + # steps: + # - name: โฌ‡ Checkout code + # uses: actions/checkout@v2 + # + # - name: โฌ‡ Download build result + # uses: actions/download-artifact@v1 + # with: + # name: dist + # path: dist + # - name: ๐Ÿ— Set up Python 3.7 + # uses: actions/setup-python@v1 + # with: + # python-version: 3.7 + # - name: ๐Ÿš€ Install wheel + # run: | + # pip install dist/OctoPrint-*-py2.py3-none-any.whl + # + # - name: ๐Ÿ— Create base config for test server + # run: | + # mkdir e2econfig + # cp -r .github/fixtures/with_acl/* e2econfig + # + # - name: ๐Ÿš€ Run Cypress + # uses: cypress-io/github-action@v2 + # with: + # working-directory: tests/cypress + # browser: chrome + # start: 'octoprint -b ${{ github.workspace }}/e2econfig serve --host 127.0.0.1 --port 5000' + # wait-on: 'http://127.0.0.1:5000/online.txt' + # + # - name: โฌ† Upload screenshots + # uses: actions/upload-artifact@v1 + # if: failure() + # with: + # name: cypress-screenshots + # path: tests/cypress/screenshots + # - name: โฌ† Upload videos + # uses: actions/upload-artifact@v1 + # if: always() + # with: + # name: cypress-videos + # path: tests/cypress/videos publish-on-testpypi: name: ๐Ÿ“ฆ Publish on TestPyPI @@ -143,7 +143,7 @@ jobs: needs: - test-unit - test-install - - test-e2e + #- test-e2e runs-on: ubuntu-latest steps: - name: โฌ‡ Download build result diff --git a/docs/configuration/config_yaml.rst b/docs/configuration/config_yaml.rst index f96751326..9b2fc337c 100644 --- a/docs/configuration/config_yaml.rst +++ b/docs/configuration/config_yaml.rst @@ -283,10 +283,14 @@ The following settings are only relevant to you if you want to do OctoPrint deve # false, no minification will take place regardless of the minify setting below. bundle: true - # If set to true, OctoPrint will minify its viewmodels (that includes those of plugins). Note: if bundle is + # If set to true, OctoPrint will the core and library javascript assets. Note: if bundle is # set to false, no minification will take place either. minify: true + # If set to true, OctoPrint will also minify the third party plugin javascript assets. Note: if bundle or + # minify are set to false, no minification of the plugin assets will take place either. + minify_plugins: false + # Whether to delete generated web assets on server startup (forcing a regeneration) clean_on_startup: true diff --git a/src/octoprint/server/__init__.py b/src/octoprint/server/__init__.py index b31f11597..2f667995d 100644 --- a/src/octoprint/server/__init__.py +++ b/src/octoprint/server/__init__.py @@ -1605,7 +1605,11 @@ class Server(object): filters.append("rjsmin") filters.append("gzip") - js_filters = js_plugin_filters = filters + js_filters = filters + if self._settings.getBoolean(["devel", "webassets", "minify_plugins"]): + js_plugin_filters = js_filters + else: + js_plugin_filters = [x for x in js_filters if x not in ("rjsmin",)] def js_bundles_for_plugins(collection, filters=None): """Produces JsPluginBundle instances that output IIFE wrapped assets""" @@ -1645,7 +1649,7 @@ class Server(object): js_app_bundle = Bundle(js_plugins_bundle, js_core_bundle, output="webassets/packed_app.js", - filters=",".join(js_filters)) + filters=",".join(js_plugin_filters)) js_client_core_bundle = Bundle(*clientjs_core, output="webassets/packed_client_core.js", @@ -1660,7 +1664,7 @@ class Server(object): js_client_bundle = Bundle(js_client_core_bundle, js_client_plugins_bundle, output="webassets/packed_client.js", - filters=",".join(js_filters)) + filters=",".join(js_plugin_filters)) # -- CSS ------------------------------------------------------------------------------------------------------- diff --git a/src/octoprint/server/api/settings.py b/src/octoprint/server/api/settings.py index 9967022ae..791cbde28 100644 --- a/src/octoprint/server/api/settings.py +++ b/src/octoprint/server/api/settings.py @@ -145,7 +145,8 @@ def getSettings(): "baudrateOptions": connectionOptions["baudrates"], "autoconnect": s.getBoolean(["serial", "autoconnect"]), "timeoutConnection": s.getFloat(["serial", "timeout", "connection"]), - "timeoutDetection": s.getFloat(["serial", "timeout", "detection"]), + "timeoutDetectionFirst": s.getFloat(["serial", "timeout", "detectionFirst"]), + "timeoutDetectionConsecutive": s.getFloat(["serial", "timeout", "detectionConsecutive"]), "timeoutCommunication": s.getFloat(["serial", "timeout", "communication"]), "timeoutCommunicationBusy": s.getFloat(["serial", "timeout", "communicationBusy"]), "timeoutTemperature": s.getFloat(["serial", "timeout", "temperature"]), @@ -442,8 +443,9 @@ def _saveSettings(data): if "baudrate" in data["serial"]: s.setInt(["serial", "baudrate"], data["serial"]["baudrate"]) if "exclusive" in data["serial"]: s.setBoolean(["serial", "exclusive"], data["serial"]["exclusive"]) if "timeoutConnection" in data["serial"]: s.setFloat(["serial", "timeout", "connection"], data["serial"]["timeoutConnection"], min=1.0) - if "timeoutDetection" in data["serial"]: s.setFloat(["serial", "timeout", "detection"], data["serial"]["timeoutDetection"], min=1.0) - if "timeoutCommunication" in data["serial"]: s.setFloat(["serial", "timeout", "communication"], data["serial"]["timeoutCommunication"], min=1.0) + if "timeoutDetectionFirst" in data["serial"]: s.setFloat(["serial", "timeout", "detectionFirst"], data["serial"]["timeoutDetectionFirst"], min=1.0) + if "timeoutDetectionConsecutive" in data["serial"]: s.setFloat(["serial", "timeout", "detectionConsecutive"], data["serial"]["timeoutDetectionConsecutive"], min=1.0) + if "timeoutCommunication" in data["serial"]: s.setFloat(["serial", "timeout", "communication"], data["serial"]["timeoutCommunicationFirst"], min=1.0) if "timeoutCommunicationBusy" in data["serial"]: s.setFloat(["serial", "timeout", "communicationBusy"], data["serial"]["timeoutCommunicationBusy"], min=1.0) if "timeoutTemperature" in data["serial"]: s.setFloat(["serial", "timeout", "temperature"], data["serial"]["timeoutTemperature"], min=1.0) if "timeoutTemperatureTargetSet" in data["serial"]: s.setFloat(["serial", "timeout", "temperatureTargetSet"], data["serial"]["timeoutTemperatureTargetSet"], min=1.0) diff --git a/src/octoprint/settings.py b/src/octoprint/settings.py index de9e7d63e..485cf1738 100644 --- a/src/octoprint/settings.py +++ b/src/octoprint/settings.py @@ -98,7 +98,8 @@ default_settings = { "autoconnect": False, "log": False, "timeout": { - "detection": 1, + "detectionFirst": 10, + "detectionConsecutive": 2, "connection": 10, "communication": 30, "communicationBusy": 3, @@ -414,7 +415,8 @@ default_settings = { "webassets": { "bundle": True, "clean_on_startup": True, - "minify": True + "minify": True, + "minify_plugins": False }, "useFrozenDictForPrinterState": True, "showLoadingAnimation": True, diff --git a/src/octoprint/static/js/app/viewmodels/settings.js b/src/octoprint/static/js/app/viewmodels/settings.js index e04568caa..57520e5bf 100644 --- a/src/octoprint/static/js/app/viewmodels/settings.js +++ b/src/octoprint/static/js/app/viewmodels/settings.js @@ -158,7 +158,8 @@ $(function() { self.serial_baudrateOptions = ko.observableArray([]); self.serial_autoconnect = ko.observable(undefined); self.serial_timeoutConnection = ko.observable(undefined); - self.serial_timeoutDetection = ko.observable(undefined); + self.serial_timeoutDetectionFirst = ko.observable(undefined); + self.serial_timeoutDetectionConsecutive = ko.observable(undefined); self.serial_timeoutCommunication = ko.observable(undefined); self.serial_timeoutCommunicationBusy = ko.observable(undefined); self.serial_timeoutTemperature = ko.observable(undefined); diff --git a/src/octoprint/templates/dialogs/settings/serialconnection.jinja2 b/src/octoprint/templates/dialogs/settings/serialconnection.jinja2 index 93be8ae92..f9c86634d 100644 --- a/src/octoprint/templates/dialogs/settings/serialconnection.jinja2 +++ b/src/octoprint/templates/dialogs/settings/serialconnection.jinja2 @@ -173,14 +173,25 @@ -
- +
+
- + s
+ {{ _('First handshake attempt')}}
+
+
+ + s +
+ {{ _('Consecutive handshake attempts')}} +
+
+
+
diff --git a/src/octoprint/util/comm.py b/src/octoprint/util/comm.py index 280fa9478..1dcb270cb 100644 --- a/src/octoprint/util/comm.py +++ b/src/octoprint/util/comm.py @@ -1677,15 +1677,14 @@ class MachineCom(object): return try_hello = not settings().getBoolean(["serial", "waitForStartOnConnect"]) self._changeState(self.STATE_CONNECTING) + self._timeout = self._ok_timeout = self._get_new_communication_timeout() else: self._changeState(self.STATE_DETECT_SERIAL) self._perform_detection_step(init=True) + # Start monitoring the serial port self._log("Connected to: %s, starting monitor" % self._serial) - #Start monitoring the serial port. - self._timeout = self._ok_timeout = self._get_new_communication_timeout() - startSeen = False supportRepetierTargetTemp = settings().getBoolean(["serial", "repetierTargetTemp"]) supportWait = settings().getBoolean(["serial", "supportWait"]) @@ -1874,7 +1873,8 @@ class MachineCom(object): and (not self.job_on_hold or self._resendActive) and not self._long_running_command and not self._heating and now >= self._ok_timeout)) \ - and (not self._blockWhileDwelling or not self._dwelling_until or now > self._dwelling_until): + and (not self._blockWhileDwelling or not self._dwelling_until or now > self._dwelling_until)\ + and not self._state in (self.STATE_DETECT_SERIAL,): # We have two timeout variants: # # Variant 1: No line at all received within the communication timeout. This can always happen. @@ -2253,7 +2253,7 @@ class MachineCom(object): ### Serial detection if self._state == self.STATE_DETECT_SERIAL: - if line == '' or monotonic_time() > self._timeout: + if line == '' or monotonic_time() > self._ok_timeout: self._perform_detection_step() elif 'start' in line or line.startswith('ok'): self._onConnected() @@ -2412,7 +2412,6 @@ class MachineCom(object): self._logger.info("Serial detection: {}".format(message)) if init: - timeout = settings().getFloat(["serial", "timeout", "connection"]) port = self._port baudrate = self._baudrate @@ -2431,27 +2430,26 @@ class MachineCom(object): baudrate_candidates = baudrateList([115200, 250000]) self._detection_candidates = [(p, b) for p in port_candidates for b in baudrate_candidates] + self._detection_retry = self.DETECTION_RETRIES log("Performing autodetection with {} " \ "port/baudrate candidates: {}".format(len(self._detection_candidates), ", ".join(map(lambda x: "{}@{}".format(x[0], x[1]), self._detection_candidates)))) - else: - timeout = settings().getFloat(["serial", "timeout", "detection"]) - def attempt_handshake(): + timeout = self._get_communication_timeout_interval() if self._serial.timeout != timeout: self._serial.timeout = timeout - self._timeout = monotonic_time() + timeout + self._timeout = self._ok_timeout = monotonic_time() + timeout - log("Handshake attempt #{}".format(self._detection_retry + 1)) + 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", }) - while len(self._detection_candidates) > 0: + while len(self._detection_candidates) > 0 or self._detection_retry < self.DETECTION_RETRIES: if self._detection_retry < self.DETECTION_RETRIES: attempt_handshake() return @@ -2460,6 +2458,7 @@ class MachineCom(object): (p, b) = self._detection_candidates.pop(0) try: + log("Trying port {}, baudrate {}".format(p, b)) if self._serial is None or self._serial.port != p: if not self._open_serial(p, b, trigger_errors=False): log("Could not open port {}, baudrate {}, skipping".format(p, b)) @@ -2467,7 +2466,6 @@ class MachineCom(object): else: self._serial.baudrate = b - log("Trying port {}, baudrate {}".format(p, b)) self._detection_retry = 0 attempt_handshake() @@ -2689,6 +2687,15 @@ class MachineCom(object): return interval def _get_communication_timeout_interval(self): + # special rules during serial detection + if self._state in (self.STATE_DETECT_SERIAL,): + if self._detection_retry == 0: + # first try + return self._timeout_intervals.get("detectionFirst", 10.0) + else: + # consecutive tries + return self._timeout_intervals.get("detectionConsecutive", 2.0) + # communication timeout if self._busy_protocol_support: comm_timeout = self._timeout_intervals.get("communicationBusy", 2.0) @@ -2910,8 +2917,7 @@ class MachineCom(object): eventManager().fire(Events.ERROR, {"error": self.getErrorString(), "reason": reason}) if close: if self._send_m112_on_error and not self.isSdPrinting() and reason not in ("connection", - "autodetect_baudrate", - "autodetect_port"): + "autodetect"): self._trigger_emergency_stop(close=False) self.close(is_error=True)