This commit is contained in:
Matthias Urlichs committed 2019-01-28 07:50:55 +01:00
1 parent c74e3a0a0b
commit fcb0f877b8
3 files changed
+23 -11

No files matched your search

+14 -9
View File
@@ -44,6 +44,11 @@ try:
except ImportError:
from scandir import scandir, walk
try:
long
except NameError:
long = int
#~~ monkey patching
def enable_additional_translations(default_locale="en", additional_folders=None):
@@ -154,8 +159,8 @@ def fix_webassets_cache():
import shutil
if not os.path.exists(self.directory):
error_logger.warn("Cache directory {} doesn't exist, not going "
"to attempt to write cache file".format(self.directory))
error_logger.warning("Cache directory {} doesn't exist, not going "
"to attempt to write cache file".format(self.directory))
md5 = '%s' % cache.make_md5(self.V, key)
filename = os.path.join(self.directory, md5)
@@ -177,8 +182,8 @@ def fix_webassets_cache():
from webassets.cache import make_md5
if not os.path.exists(self.directory):
error_logger.warn("Cache directory {} doesn't exist, not going "
"to attempt to read cache file".format(self.directory))
error_logger.warning("Cache directory {} doesn't exist, not going "
"to attempt to read cache file".format(self.directory))
return None
try:
@@ -190,7 +195,7 @@ def fix_webassets_cache():
filename = os.path.join(self.directory, '%s' % hash)
try:
f = open(filename, 'rb')
f = io.open(filename, 'rb')
except IOError as e:
if e.errno != errno.ENOENT:
error_logger.exception("Got an exception while trying to open webasset file {}".format(filename))
@@ -202,7 +207,7 @@ def fix_webassets_cache():
unpickled = webassets.cache.safe_unpickle(result)
if unpickled is None:
warnings.warn('Ignoring corrupted cache file %s' % filename)
warnings.warning('Ignoring corrupted cache file %s' % filename)
return unpickled
cache.FilesystemCache.set = fixed_set
@@ -844,7 +849,7 @@ class PreemptiveCache(object):
cache_data = None
with self._lock:
try:
with open(self.cachefile, "r") as f:
with io.open(self.cachefile, "r") as f:
cache_data = yaml.safe_load(f)
except IOError as e:
import errno
@@ -1063,7 +1068,7 @@ def check_lastmodified(lastmodified):
return False
from datetime import datetime
if isinstance(lastmodified, (int, long, float, complex)):
if isinstance(lastmodified, (int, long, float)):
lastmodified = datetime.fromtimestamp(lastmodified).replace(microsecond=0)
if not isinstance(lastmodified, datetime):
@@ -1469,7 +1474,7 @@ def collect_plugin_assets(enable_gcodeviewer=True, preferred_stylesheet="css"):
def asset_exists(category, asset):
exists = os.path.exists(os.path.join(basefolder, asset))
if not exists:
logger.warn("Plugin {} is referring to non existing {} asset {}".format(name, category, asset))
logger.warning("Plugin {} is referring to non existing {} asset {}".format(name, category, asset))
return exists
if "js" in all_assets:
+8 -1
View File
@@ -44,6 +44,11 @@ try:
except ImportError:
from chainmap import ChainMap
try:
from collections.abc import KeysView
except ImportError:
from collections import KeysView
from octoprint.util import atomic_write, is_hidden_path, dict_merge, CaseInsensitiveSet
_APPNAME = "OctoPrint"
@@ -1436,6 +1441,8 @@ class Settings(object):
value = preprocessor(value)
if do_copy:
if isinstance(value, KeysView):
value = list(value)
value = copy.deepcopy(value)
if asdict:
@@ -1445,7 +1452,7 @@ class Settings(object):
if not isinstance(last, (list, tuple)):
if asdict:
return results.values().pop()
return list(results.values()).pop()
else:
return results.pop()
else:
+1 -1
View File
@@ -107,7 +107,7 @@ def get_all_template_paths(loader):
def collect_templates_for_loader(loader):
if isinstance(loader, SelectedFilesLoader):
import copy
return copy.copy(loader.files.values())
return copy.copy(list(loader.files.values()))
elif isinstance(loader, FilteredFileSystemLoader):
result = []