diff --git a/src/octoprint/plugins/softwareupdate/static/js/softwareupdate.js b/src/octoprint/plugins/softwareupdate/static/js/softwareupdate.js index 9188a25a..b4feaeed 100644 --- a/src/octoprint/plugins/softwareupdate/static/js/softwareupdate.js +++ b/src/octoprint/plugins/softwareupdate/static/js/softwareupdate.js @@ -395,7 +395,7 @@ $(function() { }; self.confirmUpdate = function() { - self.confirmationDialog.hide(); + self.confirmationDialog.modal("hide"); self.performUpdate(self.forceUpdate, _.map(self.availableAndPossible(), function(info) { return info.key })); }; diff --git a/src/octoprint/plugins/virtual_printer/virtual.py b/src/octoprint/plugins/virtual_printer/virtual.py index fa76a1a5..68c7b9e2 100644 --- a/src/octoprint/plugins/virtual_printer/virtual.py +++ b/src/octoprint/plugins/virtual_printer/virtual.py @@ -683,10 +683,13 @@ class VirtualPrinter(object): 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) diff --git a/src/octoprint/server/__init__.py b/src/octoprint/server/__init__.py index 68342342..f5dbbbd1 100644 --- a/src/octoprint/server/__init__.py +++ b/src/octoprint/server/__init__.py @@ -707,10 +707,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 @@ -741,11 +756,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)) @@ -758,6 +768,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 40087c3a..4eb03131 100644 --- a/src/octoprint/server/util/flask.py +++ b/src/octoprint/server/util/flask.py @@ -430,7 +430,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