def check_general_operating_system_release(self): """ Checks if the OS version is supported Returns: Check.Result, str, str: Result of the check Human readable message describing the check Operating system version """ check_str = "OS Kernel Version" actual_os = platform.system() actual_os_version = platform.release() # make sure the os is supported first if actual_os in self.SUPPORTED_OS.keys(): # use the os as a lookup for the version expected_os_version = self.SUPPORTED_OS[actual_os] unmaintained_os_version = self.UNMAINTAINED_OS[actual_os] if version.is_version_gte(actual_os_version, expected_os_version): return Check.Result.PASS, check_str, actual_os_version elif version.is_version_gte(actual_os_version, unmaintained_os_version): return Check.Result.WARN, check_str, actual_os_version return Check.Result.FAIL, check_str, actual_os_version
def check_general_operating_system_release(self): """ Checks if the OS version is supported Returns: Check.Result, str, str: Result of the check Human readable message describing the check Operating system version """ check_str = "Operating Sytem Release Version" actual_os = platform.system() actual_os_version = platform.release() # make sure the os is supported first if actual_os in self.SUPPORTED_OS.keys(): # use the os as a lookup for the version expected_os_version = self.SUPPORTED_OS[actual_os] unmaintained_os_version = self.UNMAINTAINED_OS[actual_os] if version.is_version_gte(actual_os_version, expected_os_version): return Check.Result.PASS, check_str, actual_os_version elif version.is_version_gte(actual_os_version, unmaintained_os_version): return Check.Result.WARN, check_str, actual_os_version return Check.Result.FAIL, check_str, actual_os_version
def test_is_version_gte(doctor, actual_version, expected_version, return_value): """ Ensures the logic of is_version_gte is correct and handle bad input """ if isinstance(return_value, bool): assert version.is_version_gte( actual_version, expected_version) == return_value else: with pytest.raises(return_value): version.is_version_gte(actual_version, expected_version)
def test_is_version_gte(doctor, actual_version, expected_version, return_value): """ Ensures the logic of is_version_gte is correct and handle bad input """ if isinstance(return_value, bool): assert version.is_version_gte(actual_version, expected_version) == return_value else: with pytest.raises(return_value): version.is_version_gte(actual_version, expected_version)
def check_general_python_version(self): """ Checks if the python version is valid Returns: Check.Result, str, str: Result of the check Human readable message describing the check The python version """ check_str = "Python Version" actual_py_version = platform.python_version() if version.is_version_gte(actual_py_version, self.SUPPORTED_PYTHON_VERSION): return Check.Result.PASS, check_str, actual_py_version return Check.Result.FAIL, check_str, actual_py_version
def check_general_two1_version(self): """ Checks if the installed two1 version is up-to-date Returns: Check.Result, str, str: Result of the check Human readable message describing the check The actaul two1 version installed on the system """ check_str = "21 Tool Version" latest_version = version.get_latest_two1_version_pypi() actual_version = two1.TWO1_VERSION if version.is_version_gte(actual_version, latest_version): return Check.Result.PASS, check_str, actual_version return Check.Result.FAIL, check_str, actual_version
def check_general_two1_version(self): """ Checks if the installed two1 version is up-to-date Returns: Check.Result, str, str: Result of the check Human readable message describing the check The actaul two1 version installed on the system """ check_str = "21 Tool Version" latest_version = version.get_latest_two1_version_pypi() actual_version = two1.TWO1_VERSION if version.is_version_gte(actual_version, latest_version): return Check.Result.PASS, check_str, actual_version else: return Check.Result.FAIL, check_str, actual_version
def check_update(self): """Check for any new updates to 21""" do_update_check = False try: if 'last_update_check' not in self.state: do_update_check = True elif self.last_update_check < time.time() - self.update_check_interval: do_update_check = True except TypeError: do_update_check = True if do_update_check: actual_version = two1.TWO1_VERSION latest_version = version.get_latest_two1_version_pypi() self.set('last_update_check', time.time(), should_save=True) if not version.is_version_gte(actual_version, latest_version): logger.warning(uxstring.UxString.update_required)
def check_update(self): """Check for any new updates to 21""" do_update_check = False try: if 'last_update_check' not in self.state: do_update_check = True elif self.last_update_check < time.time( ) - self.update_check_interval: do_update_check = True except TypeError: do_update_check = True if do_update_check: actual_version = two1.TWO1_VERSION latest_version = version.get_latest_two1_version_pypi() self.set('last_update_check', time.time(), should_save=True) if not version.is_version_gte(actual_version, latest_version): logger.warning(uxstring.UxString.update_required)