diff options
author | Michael Auchter <michael.auchter@ni.com> | 2020-10-22 10:34:56 -0500 |
---|---|---|
committer | Aaron Rossetto <aaron.rossetto@ni.com> | 2021-02-09 07:36:08 -0600 |
commit | fa6e7a7430b3f4e4b534ac6d8f7d07b3319e0e39 (patch) | |
tree | 3c0b2ae125322eecf75f88a2d5165e908c8e91de /mpm/python/usrp_mpm | |
parent | 5824046ff307f62b22207c53fb9f7ccc0f13980b (diff) | |
download | uhd-fa6e7a7430b3f4e4b534ac6d8f7d07b3319e0e39.tar.gz uhd-fa6e7a7430b3f4e4b534ac6d8f7d07b3319e0e39.tar.bz2 uhd-fa6e7a7430b3f4e4b534ac6d8f7d07b3319e0e39.zip |
mpm: filesystem_status: tolerate absence of mender
If the mender utility is not installed or exits with a failure, return
NULL for the artifact rather than raising an exception (and disrupting
device initialization).
Diffstat (limited to 'mpm/python/usrp_mpm')
-rw-r--r-- | mpm/python/usrp_mpm/periph_manager/base.py | 4 | ||||
-rw-r--r-- | mpm/python/usrp_mpm/sys_utils/filesystem_status.py | 12 |
2 files changed, 10 insertions, 6 deletions
diff --git a/mpm/python/usrp_mpm/periph_manager/base.py b/mpm/python/usrp_mpm/periph_manager/base.py index 324e47dc9..a6bffafed 100644 --- a/mpm/python/usrp_mpm/periph_manager/base.py +++ b/mpm/python/usrp_mpm/periph_manager/base.py @@ -168,7 +168,9 @@ class PeriphManagerBase(object): version_string = "" mboard_info["mpm_sw_version"] = version_string - mboard_info["fs_version"] = get_fs_version() + fs_version = get_fs_version() + if fs_version is not None: + mboard_info["fs_version"] = fs_version # Mender artifacts are generally not present on a machine hosting # a simulated device--let it slide if not found on sim devices try: diff --git a/mpm/python/usrp_mpm/sys_utils/filesystem_status.py b/mpm/python/usrp_mpm/sys_utils/filesystem_status.py index 865741316..b9617cf0a 100644 --- a/mpm/python/usrp_mpm/sys_utils/filesystem_status.py +++ b/mpm/python/usrp_mpm/sys_utils/filesystem_status.py @@ -38,16 +38,18 @@ def get_mender_artifact(filesystem_root='/', parse_manually=False): # parse mender artifact manually file = pathlib.Path(filesystem_root, 'etc/mender/artifact_info') if not file.exists(): - return 'FILE NOT FOUND' + return None return parse_artifact(file.read_text()) - else: + try: output = subprocess.check_output(['/usr/bin/mender', '-show-artifact']).decode('utf-8') return output.splitlines()[0] + except: + return None def get_fs_version(filesystem_root='/'): file = pathlib.Path(filesystem_root, 'etc/version') if not file.exists(): - return 'FILE NOT FOUND' + return None return file.read_text().splitlines()[0] def get_opkg_status_date(date_only=False, filesystem_root='/'): @@ -57,11 +59,11 @@ def get_opkg_status_date(date_only=False, filesystem_root='/'): tformat = "%Y-%m-%d %H:%M:%S" file = pathlib.Path(filesystem_root, 'var/lib/opkg/status') if not file.exists(): - return 'FILE NOT FOUND' + return None return time.strftime(tformat, time.gmtime(file.stat().st_mtime)) def get_opkg_status_md5sum(filesystem_root='/'): file = pathlib.Path(filesystem_root, 'var/lib/opkg/status') if not file.exists(): - return 'FILE NOT FOUND' + return None return hashlib.md5sum(file.read_text()).hexdigest() |