Merge branch 'fix/slicingDocs' into devel

This commit is contained in:
Gina Häußge 2016-07-12 11:52:59 +02:00
commit a33338684e
4 changed files with 27 additions and 13 deletions

View file

@ -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 }));
};

View file

@ -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)

View file

@ -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

View file

@ -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