Merge branch 'staging/hotfix' into maintenance
This commit is contained in:
commit
25684e3c4a
5 files changed
+35
-10
No files matched your search
+2
-2
@@ -24,8 +24,8 @@ maintenance 1.6.0 b7a45b79bf86339f0b28177ac1eaebb56d00ea37 pep440-dev
|
||||
fix/.* 1.6.0 b7a45b79bf86339f0b28177ac1eaebb56d00ea37 pep440-dev
|
||||
improve/.* 1.6.0 b7a45b79bf86339f0b28177ac1eaebb56d00ea37 pep440-dev
|
||||
|
||||
# staging/hotfix is the branch for preparation of the 1.4.3 hotfix release
|
||||
staging/hotfix 1.4.3 3ab84ed7e4c3aaaf71fe0f184b465f25d689f929 pep440-dev
|
||||
# staging/hotfix is the branch for preparation of the 1.5.1 hotfix release
|
||||
staging/hotfix 1.5.1 f67c15a9a47794a68be9aed4f2d5a12a87e70179 pep440-dev
|
||||
|
||||
# staging/maintenance is currently the branch for preparation of 1.5.0rc4
|
||||
# so is regressionfix/...
|
||||
|
||||
@@ -675,6 +675,7 @@ class FileManager(object):
|
||||
path=None,
|
||||
filter=None,
|
||||
recursive=None,
|
||||
level=0,
|
||||
force_refresh=False,
|
||||
):
|
||||
if not destinations:
|
||||
@@ -685,7 +686,11 @@ class FileManager(object):
|
||||
result = {}
|
||||
for dst in destinations:
|
||||
result[dst] = self._storage_managers[dst].list_files(
|
||||
path=path, filter=filter, recursive=recursive, force_refresh=force_refresh
|
||||
path=path,
|
||||
filter=filter,
|
||||
recursive=recursive,
|
||||
level=level,
|
||||
force_refresh=force_refresh,
|
||||
)
|
||||
return result
|
||||
|
||||
|
||||
@@ -90,7 +90,9 @@ class StorageInterface(object):
|
||||
"""
|
||||
raise NotImplementedError()
|
||||
|
||||
def list_files(self, path=None, filter=None, recursive=True, force_refresh=False):
|
||||
def list_files(
|
||||
self, path=None, filter=None, recursive=True, level=0, force_refresh=False
|
||||
):
|
||||
"""
|
||||
List all files in storage starting at ``path``. If ``recursive`` is set to True (the default), also dives into
|
||||
subfolders.
|
||||
@@ -610,7 +612,9 @@ class LocalFileStorage(StorageInterface):
|
||||
folder_path = os.path.join(path, name)
|
||||
return os.path.exists(folder_path) and os.path.isdir(folder_path)
|
||||
|
||||
def list_files(self, path=None, filter=None, recursive=True, force_refresh=False):
|
||||
def list_files(
|
||||
self, path=None, filter=None, recursive=True, level=0, force_refresh=False
|
||||
):
|
||||
if path:
|
||||
path = self.sanitize_path(to_unicode(path))
|
||||
base = self.path_in_storage(path)
|
||||
@@ -629,6 +633,15 @@ class LocalFileStorage(StorageInterface):
|
||||
result[key] = node
|
||||
return result
|
||||
|
||||
def strip_grandchildren(nodes):
|
||||
result = {}
|
||||
for key, node in nodes.items():
|
||||
if node["type"] == "folder":
|
||||
node = copy.copy(node)
|
||||
node["children"] = strip_children(node["children"])
|
||||
result[key] = node
|
||||
return result
|
||||
|
||||
def apply_filter(nodes, filter_func):
|
||||
result = {}
|
||||
for key, node in nodes.items():
|
||||
@@ -636,14 +649,17 @@ class LocalFileStorage(StorageInterface):
|
||||
if node["type"] == "folder":
|
||||
node = copy.copy(node)
|
||||
node["children"] = apply_filter(
|
||||
node.get("children", []), filter_func
|
||||
node.get("children", {}), filter_func
|
||||
)
|
||||
result[key] = node
|
||||
return result
|
||||
|
||||
result = self._list_folder(path, base=base, force_refresh=force_refresh)
|
||||
if not recursive:
|
||||
result = strip_children(result)
|
||||
if level > 0:
|
||||
result = strip_grandchildren(result)
|
||||
else:
|
||||
result = strip_children(result)
|
||||
if callable(filter):
|
||||
result = apply_filter(result, filter)
|
||||
return result
|
||||
|
||||
@@ -231,7 +231,7 @@ def readGcodeFile(target, filename):
|
||||
|
||||
def _getFileDetails(origin, path, recursive=True):
|
||||
parent, path = os.path.split(path)
|
||||
files = _getFileList(origin, path=parent, recursive=recursive)
|
||||
files = _getFileList(origin, path=parent, recursive=recursive, level=1)
|
||||
|
||||
for f in files:
|
||||
if f["name"] == path:
|
||||
@@ -245,7 +245,9 @@ def _getFileDetails(origin, path, recursive=True):
|
||||
message="{func}({func_args},{func_kwargs}) took {timing:.2f}ms",
|
||||
incl_func_args=True,
|
||||
)
|
||||
def _getFileList(origin, path=None, filter=None, recursive=False, allow_from_cache=True):
|
||||
def _getFileList(
|
||||
origin, path=None, filter=None, recursive=False, level=0, allow_from_cache=True
|
||||
):
|
||||
if origin == FileDestinations.SDCARD:
|
||||
sdFileList = printer.get_sd_files()
|
||||
|
||||
@@ -301,6 +303,7 @@ def _getFileList(origin, path=None, filter=None, recursive=False, allow_from_cac
|
||||
path=path,
|
||||
filter=filter_func,
|
||||
recursive=recursive,
|
||||
level=level,
|
||||
force_refresh=not allow_from_cache,
|
||||
)[origin].values()
|
||||
)
|
||||
|
||||
@@ -184,7 +184,8 @@ def interface_addresses(family=None, interfaces=None):
|
||||
continue
|
||||
if family in ifaddresses:
|
||||
for ifaddress in ifaddresses[family]:
|
||||
if not ifaddress["addr"].startswith("169.254."):
|
||||
address = netaddr.IPAddress(ifaddress["addr"])
|
||||
if not address.is_link_local() and not address.is_loopback():
|
||||
yield ifaddress["addr"]
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user