🐛 Solve sorted issues under Python 3.x

sorted does no longer support sorting None values under Python 3. This
patch introduces a utility function that ensures that None values are
replaced by a configurable default value ("" by default) and utilizes
it in places where sorted gets called with a custom sorting key that
can potentially consist of None values.

Closes #3300
This commit is contained in:
Gina Häußge committed 2019-10-10 14:54:07 +02:00
1 parent 09a4fb2515
commit a889bec4d8
8 files changed
+26 -12

No files matched your search

+3 -1
View File
@@ -20,6 +20,8 @@ import octoprint.filemanager.util
import octoprint.filemanager.storage
import octoprint.slicing
from octoprint.util import sv
import os
import psutil
import hashlib
@@ -85,7 +87,7 @@ def _create_etag(path, filter, recursive, lm=None):
if path.endswith("/files") or path.endswith("/files/sdcard"):
# include sd data in etag
hash_update(repr(sorted(printer.get_sd_files(), key=lambda x: x[0])))
hash_update(repr(sorted(printer.get_sd_files(), key=lambda x: sv(x[0]))))
hash_update(_DATA_FORMAT_VERSION) # increment version if we change the API format