From d96a91ecc310953a4301a3105e494bd4cc78b557 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Wed, 6 Jul 2016 15:30:36 +0200 Subject: [PATCH 1/4] Fix modal background of update confirmation not vanishing --- .../plugins/softwareupdate/static/js/softwareupdate.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/octoprint/plugins/softwareupdate/static/js/softwareupdate.js b/src/octoprint/plugins/softwareupdate/static/js/softwareupdate.js index 3816793a..58c6e227 100644 --- a/src/octoprint/plugins/softwareupdate/static/js/softwareupdate.js +++ b/src/octoprint/plugins/softwareupdate/static/js/softwareupdate.js @@ -342,7 +342,7 @@ $(function() { }; self.confirmUpdate = function() { - self.confirmationDialog.hide(); + self.confirmationDialog.modal("hide"); self.performUpdate(self.forceUpdate, _.map(self.availableAndPossible(), function(info) { return info.key })); }; From a7fe2d51489cb9b414107ad5a1889cdca8a84f62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Thu, 7 Jul 2016 10:22:37 +0200 Subject: [PATCH 2/4] Clean up old AND invalid entries in preemptive cache config --- src/octoprint/server/__init__.py | 25 ++++++++++++++++++------- src/octoprint/server/util/flask.py | 2 +- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/src/octoprint/server/__init__.py b/src/octoprint/server/__init__.py index 34dbf07a..97d7831b 100644 --- a/src/octoprint/server/__init__.py +++ b/src/octoprint/server/__init__.py @@ -779,10 +779,25 @@ class Server(object): preemptive_cache_timeout = settings().getInt(["server", "preemptiveCache", "until"]) cutoff_timestamp = time.time() - preemptive_cache_timeout * 24 * 60 * 60 - def filter_old_entries(entry): + def filter_current_entries(entry): + """Returns True for entries younger than the cutoff date""" return "_timestamp" in entry and entry["_timestamp"] > cutoff_timestamp - cache_data = preemptive_cache.clean_all_data(lambda root, entries: filter(filter_old_entries, entries)) + def filter_http_entries(entry): + """Returns True for entries targeting http or https.""" + return "base_url" in entry \ + and entry["base_url"] \ + and (entry["base_url"].startswith("http://") + or entry["base_url"].startswith("https://")) + + def filter_entries(entry): + """Combined filter.""" + filters = (filter_current_entries, + filter_http_entries) + return all([f(entry) for f in filters]) + + # filter out all old and non-http entries + cache_data = preemptive_cache.clean_all_data(lambda root, entries: filter(filter_entries, entries)) if not cache_data: return @@ -795,11 +810,6 @@ class Server(object): kwargs = dict((k, v) for k, v in kwargs.items() if not k.startswith("_") and not k == "plugin") kwargs.update(additional_request_data) - base_url = kwargs.get("base_url", "") - if not (base_url.startswith("http://") or base_url.startswith("https://")): - self._logger.info("Skipping preemptive cache entry with base url {}, neither http:// nor https:// and possibly broken".format(base_url)) - continue - try: if plugin: self._logger.info("Preemptively caching {} (plugin {}) for {!r}".format(route, plugin, kwargs)) @@ -811,6 +821,7 @@ class Server(object): except: self._logger.exception("Error while trying to preemptively cache {} for {!r}".format(route, kwargs)) + # asynchronous caching import threading cache_thread = threading.Thread(target=execute_caching, name="Preemptive Cache Worker") cache_thread.daemon = True diff --git a/src/octoprint/server/util/flask.py b/src/octoprint/server/util/flask.py index 4f6b3dbe..649704da 100644 --- a/src/octoprint/server/util/flask.py +++ b/src/octoprint/server/util/flask.py @@ -420,7 +420,7 @@ class PreemptiveCache(object): self._logger.debug("Removed root {} from preemptive cache".format(root)) elif len(entries) < old_count: all_data[root] = entries - self._logger.debug("Removed {} from preemptive cache for root {}".format(old_count - len(entries), root)) + self._logger.debug("Removed {} entries from preemptive cache for root {}".format(old_count - len(entries), root)) self.set_all_data(all_data) return all_data From 58ee5f17f7baddd1985745452fc08df92021d3ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Fri, 8 Jul 2016 16:44:40 +0200 Subject: [PATCH 3/4] Fix simulation of moves on virtual printer --- src/octoprint/plugins/virtual_printer/virtual.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/octoprint/plugins/virtual_printer/virtual.py b/src/octoprint/plugins/virtual_printer/virtual.py index 8d253f14..1d9adba6 100644 --- a/src/octoprint/plugins/virtual_printer/virtual.py +++ b/src/octoprint/plugins/virtual_printer/virtual.py @@ -569,10 +569,13 @@ class VirtualPrinter(): pass if duration: - slept = 0 - while duration - slept > self._read_timeout and not self._killed: - time.sleep(self._read_timeout) - slept += self._read_timeout + if duration > self._read_timeout: + slept = 0 + while duration - slept > self._read_timeout and not self._killed: + time.sleep(self._read_timeout) + slept += self._read_timeout + else: + time.sleep(duration) def _setPosition(self, line): matchX = re.search("X([0-9.]+)", line) From 12fcfda4814b14c61f8825d78e4d0b2a6656bb4c Mon Sep 17 00:00:00 2001 From: cvignac Date: Sun, 10 Jul 2016 15:40:24 +0300 Subject: [PATCH 4/4] Typo correction in slicing.rst In 'Retrieve all slicing profiles' : 'GET /api/slicing/profiles' -> 'GET /api/slicing' --- docs/api/slicing.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/api/slicing.rst b/docs/api/slicing.rst index 5204da15..5a56b960 100644 --- a/docs/api/slicing.rst +++ b/docs/api/slicing.rst @@ -32,7 +32,7 @@ List All Slicers and Slicing Profiles .. sourcecode:: http - GET /api/slicing/profiles HTTP/1.1 + GET /api/slicing HTTP/1.1 Host: example.com X-Api-Key: abcdef...