1
0
mirror of https://github.com/pi-hole/pi-hole synced 2024-12-22 06:48:07 +00:00

Tweak get_directories_recursive (#5105)

This commit is contained in:
Adam Warner 2023-01-14 17:21:24 +00:00 committed by GitHub
commit 57f29a2c5d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -136,15 +136,9 @@ def test_installPiholeWeb_fresh_install_no_errors(host):
def get_directories_recursive(host, directory): def get_directories_recursive(host, directory):
if directory is None: if directory is None:
return directory return directory
ls = host.run("ls -d {}".format(directory + "/*/")) # returns all non-hidden subdirs of 'directory'
directories = list(filter(bool, ls.stdout.splitlines())) dirs_raw = host.run("find {} -type d -not -path '*/.*'".format(directory))
dirs = directories dirs = list(filter(bool, dirs_raw.stdout.splitlines()))
for dirval in directories:
dir_rec = get_directories_recursive(host, dirval)
if isinstance(dir_rec, str):
dirs.extend([dir_rec])
else:
dirs.extend(dir_rec)
return dirs return dirs
@ -520,7 +514,7 @@ def test_installPihole_fresh_install_readableBlockpage(host, test_webpage):
check_admin = test_cmd.format("x", webroot + "/admin", webuser) check_admin = test_cmd.format("x", webroot + "/admin", webuser)
actual_rc = host.run(check_admin).rc actual_rc = host.run(check_admin).rc
assert exit_status_success == actual_rc assert exit_status_success == actual_rc
directories = get_directories_recursive(host, webroot + "/admin/*/") directories = get_directories_recursive(host, webroot + "/admin/")
for directory in directories: for directory in directories:
check_pihole = test_cmd.format("r", directory, webuser) check_pihole = test_cmd.format("r", directory, webuser)
actual_rc = host.run(check_pihole).rc actual_rc = host.run(check_pihole).rc