diff options
Diffstat (limited to 'src/software/openlmi/software/util/common.py')
-rw-r--r-- | src/software/openlmi/software/util/common.py | 42 |
1 files changed, 28 insertions, 14 deletions
diff --git a/src/software/openlmi/software/util/common.py b/src/software/openlmi/software/util/common.py index a5b7c60..685171a 100644 --- a/src/software/openlmi/software/util/common.py +++ b/src/software/openlmi/software/util/common.py @@ -699,15 +699,22 @@ class SoftwareFileCheck: """ if not isinstance(file_check, SoftwareFileCheck.FileCheck): raise TypeError("file_check must be an instance of FileCheck") - return ( file_check.exists - and all( val[0] == val[1] - #pylint: disable=W0212 - for k, val in file_check._asdict().items() - if ( isinstance(val, tuple) - and ( k != "last_modification_time" - or file_check.file_type[0] == \ - SoftwareFileCheck.filetype_str2pywbem("file") - )))) + passed = file_check.exists + for k, val in file_check._asdict().items(): + if not passed: + break + if not isinstance(val, tuple): + continue + if ( k == "last_modification_time" + and file_check.file_type[0] != \ + SoftwareFileCheck.filetype_str2pywbem("file")): + continue + if ( k == "file_mode" + and file_check.file_type[0] == \ + SoftwareFileCheck.filetype_str2pywbem("symlink")): + continue + passed = val[0] == val[1] + return passed @staticmethod def _filecheck2model_flags(file_check): @@ -718,14 +725,21 @@ class SoftwareFileCheck: flags = [] for k, value in file_check._asdict().items(): #pylint: disable=W0212 if isinstance(value, tuple): - if ( k != "last_modification_time" - or file_check.file_type[0] == - SoftwareFileCheck.filetype_str2pywbem('file')): + if ( k == "last_modification_time" + and file_check.file_type[0] != \ + SoftwareFileCheck.filetype_str2pywbem('file')): # last_modification_time check is valid only for # regular files - flag = file_check.exists and value[0] == value[1] + flag = file_check.exists + elif ( k == "file_mode" + and file_check.file_type[0] == \ + SoftwareFileCheck.filetype_str2pywbem('symlink')): + # do not check mode of symlinks + flag = ( file_check.exists + and ( file_check.file_type[0] + == file_check.file_type[1])) else: - flag = True + flag = file_check.exists and value[0] == value[1] flags.append(flag) elif isinstance(value, bool): flags.append(value) |