summaryrefslogtreecommitdiff
path: root/python/vyos/util.py
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2020-08-13 18:31:08 +0200
committerChristian Poessinger <christian@poessinger.com>2020-08-15 15:02:00 +0000
commitb082a6fb211ef19d75c4c81414be9aa1b9248b45 (patch)
tree85ee394234198a669c4be22cc97f1e2f3ab5050b /python/vyos/util.py
parent8efb8ba1efa9d51ec376bac0bfcb48cf200447a9 (diff)
downloadvyos-1x-b082a6fb211ef19d75c4c81414be9aa1b9248b45.tar.gz
vyos-1x-b082a6fb211ef19d75c4c81414be9aa1b9248b45.zip
lcd: T2564: flatten CLI interface
* set system lcd device <device> * set system lcd model <modeml> Both device and model have completion helpers for supported interfaces and LCD displays.
Diffstat (limited to 'python/vyos/util.py')
-rw-r--r--python/vyos/util.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/python/vyos/util.py b/python/vyos/util.py
index 7078762df..c07fef599 100644
--- a/python/vyos/util.py
+++ b/python/vyos/util.py
@@ -661,3 +661,15 @@ def check_kmod(k_mod):
if not os.path.exists(f'/sys/module/{module}'):
if call(f'modprobe {module}') != 0:
raise ConfigError(f'Loading Kernel module {module} failed')
+
+def find_device_file(device):
+ """ Recurively search /dev for the given device file and return its full path.
+ If no device file was found 'None' is returned """
+ from fnmatch import fnmatch
+
+ for root, dirs, files in os.walk('/dev'):
+ for basename in files:
+ if fnmatch(basename, device):
+ return os.path.join(root, basename)
+
+ return None