From 7301659a1303669612c7b4120b17ac50a62dbd24 Mon Sep 17 00:00:00 2001 From: Christian Poessinger Date: Wed, 11 Nov 2020 18:37:45 +0100 Subject: wwan: T2529: fix validation logic for non existing devices A non existing device usb0b1.4p1.?? device was not detected, as find_device_file() returned None which can not be passed into os.path.exists(). Traceback (most recent call last): File "/usr/libexec/vyos/conf_mode/interfaces-wirelessmodem.py", line 126, in verify(c) File "/usr/libexec/vyos/conf_mode/interfaces-wirelessmodem.py", line 60, in verify if dev_path is None or os.path.exists(find_device_file(dev_path)): File "/usr/lib/python3.7/genericpath.py", line 19, in exists os.stat(path) TypeError: stat: path should be string, bytes, os.PathLike or integer, not NoneType --- src/conf_mode/interfaces-wirelessmodem.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/conf_mode/interfaces-wirelessmodem.py') diff --git a/src/conf_mode/interfaces-wirelessmodem.py b/src/conf_mode/interfaces-wirelessmodem.py index 7d8110096..2da1f0863 100755 --- a/src/conf_mode/interfaces-wirelessmodem.py +++ b/src/conf_mode/interfaces-wirelessmodem.py @@ -56,7 +56,8 @@ def verify(wwan): # we can not use isfile() here as Linux device files are no regular files # thus the check will return False - if not os.path.exists(find_device_file(wwan['device'])): + dev_path = find_device_file(wwan['device']) + if dev_path is None or not os.path.exists(dev_path): raise ConfigError('Device "{device}" does not exist'.format(**wwan)) verify_vrf(wwan) -- cgit v1.2.3