diff options
Diffstat (limited to 'mpm/python/usrp_mpm/sys_utils/filesystem_status.py')
-rw-r--r-- | mpm/python/usrp_mpm/sys_utils/filesystem_status.py | 12 |
1 files changed, 7 insertions, 5 deletions
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() |