mirror of
https://git.disroot.org/pranav/pybatmesh.git
synced 2024-11-27 01:02:15 +05:30
fixed bug in previous commit
Added function to get glob as sorted list. This fixes the errors reported by systemd-networkd
This commit is contained in:
parent
a81449b898
commit
798cd3e988
@ -35,4 +35,4 @@ See README.md for documentation.
|
||||
#
|
||||
# In case you forgot to change the version, skip the number
|
||||
# and put the next number in the next commit.
|
||||
__version__ = "0.4.0a4"
|
||||
__version__ = "0.4.0a5"
|
||||
|
@ -40,6 +40,20 @@ from naxalnet.daemon import Daemon
|
||||
from naxalnet.network import NetworkD
|
||||
|
||||
|
||||
def get_sorted_glob(directory: str, glob: str):
|
||||
"""return sorted list of filenames matching glob"""
|
||||
path = Path(directory)
|
||||
g = path.glob(glob)
|
||||
sorted_list = []
|
||||
for i in g:
|
||||
# g is a list of PosixPath objects.
|
||||
# So we add their absolute path as str.
|
||||
sorted_list.append(str(i))
|
||||
# sorted_list is not sorted, so we sort them here
|
||||
sorted_list.sort()
|
||||
return sorted_list
|
||||
|
||||
|
||||
def setup_mesh():
|
||||
"""configure networkd to setup the mesh"""
|
||||
try:
|
||||
@ -52,10 +66,9 @@ def setup_mesh():
|
||||
networkd = NetworkD(runtime_dir=args.networkd_runtime_dir)
|
||||
# TODO: replace with valus from args
|
||||
networkd.set_vars(batdev="bat0", bridgedev="bridge0")
|
||||
for i in Path(args.networkd_config_dir).glob(MESH_GLOB):
|
||||
path = str(i)
|
||||
logger.debug("Adding network config %s", path)
|
||||
networkd.add_config(path)
|
||||
for i in get_sorted_glob(args.networkd_config_dir, MESH_GLOB):
|
||||
logger.debug("Adding network config %s", i)
|
||||
networkd.add_config(i)
|
||||
except PermissionError:
|
||||
logger.exception("A PermissionError occured while copying files")
|
||||
logger.error(REPORT_BUG_INFO)
|
||||
|
Loading…
Reference in New Issue
Block a user