def get_installation_status()

in src/core/src/package_managers/PackageManager.py [0:0]


    def get_installation_status(self, code, out, exec_cmd, package, version, simulate=False):
        """
        Returns result of the package installation

        Parameters:
        code (int): Output code of the command run to install packages.
        out (string): Output string of the command run to install packages.
        exec_cmd (string): Command used to install packages.
        package (string): Package name.
        version (string): Package version.
        simulate (bool): Whether this function call is from test run.

        Returns:
        install_result (string): Package installation result
        """
        install_result = Constants.INSTALLED
        package_no_longer_required = False
        code_path = "| Install"
        start_time = time.time()

        # special case of package no longer being required (or maybe even present on the system)
        if code == 1 and self.get_package_manager_setting(Constants.PKG_MGR_SETTING_IDENTITY) == Constants.YUM:
            self.composite_logger.log_debug("[PM] > Detecting if package is no longer required (as return code is 1):")
            if self.STR_NOTHING_TO_DO in out:
                code_path += " > Nothing to do. (succeeded)"
                self.composite_logger.log_debug("[PM]    > Evidence of package no longer required detected.")
                package_no_longer_required = True
                code = 0
            else:
                code_path += " > Nothing to do. (possible failure, tbd)"
                self.composite_logger.log_debug("[PM]    > Evidence of package no longer required NOT detected.")

        if not package_no_longer_required:
            if not self.is_package_version_installed(package, version):
                if code == 0 and self.STR_ONLY_UPGRADES.replace('<PACKAGE>', package) in out:
                    # It is premature to fail this package. In the *unlikely* case it never gets picked up, it'll remain NotStarted.
                    # The NotStarted status must not be written again in the calling function (it's not at the time of this writing).
                    code_path += " > Package has no prior version. (no operation; return 'not started')"
                    install_result = Constants.PENDING
                    self.composite_logger.log_warning(" |- Package " + package + " (" + version + ") needs to already have an older version installed in order to be upgraded. " +
                                                   "\n |- Another upgradeable package requiring it as a dependency can cause it to get installed later. No action may be required.\n")

                elif code == 0 and self.STR_OBSOLETED.replace('<PACKAGE>', self.get_composite_package_identifier(package, version)) in out:
                    # Package can be obsoleted by another package installed in the run (via dependencies)
                    code_path += " > Package obsoleted. (succeeded)"
                    install_result = Constants.INSTALLED    # close approximation to obsoleted
                    self.composite_logger.log_debug("[PM] > Package was discovered to be obsoleted.")

                elif code == 0 and len(out.split(self.STR_REPLACED)) > 1 and package in out.split(self.STR_REPLACED)[1]:
                    code_path += " > Package replaced. (succeeded)"
                    install_result = Constants.INSTALLED    # close approximation to replaced
                    self.composite_logger.log_debug("[PM] > Package was discovered to be replaced by another during its installation.")

                else:  # actual failure
                    install_result = Constants.FAILED
                    if code != 0:
                        code_path += " > Package NOT installed. (failed)"
                        self.composite_logger.log_error(" |- Package failed to install: " + package + " (" + version + "). " +
                                                     "\n |- Error code: " + str(code) + ". Command used: " + exec_cmd +
                                                     "\n |- Command output: " + out + "\n")
                    else:
                        code_path += " > Package NOT installed but return code: 0. (failed)"
                        self.composite_logger.log_error(" |- Package appears to have not been installed: " + package + " (" + version + "). " +
                                                     "\n |- Return code: 0. Command used: " + exec_cmd + "\n" +
                                                     "\n |- Command output: " + out + "\n")
            elif code != 0:
                code_path += " > Info, package installed, non-zero return. (succeeded)"
                self.composite_logger.log_warning(" - [Info] Desired package version was installed, but the package manager returned a non-zero return code: " + str(code) + ". Command used: " + exec_cmd + "\n")
            else:
                code_path += " > Info, Package installed, zero return. (succeeded)"

        if not simulate:
            package_size = self.get_package_size(out)
            if install_result == Constants.FAILED:
                error = self.telemetry_writer.write_package_info(package, version, package_size, round(time.time() - start_time, 2), install_result, code_path, exec_cmd, str(out))
            else:
                error = self.telemetry_writer.write_package_info(package, version, package_size, round(time.time() - start_time, 2), install_result, code_path, exec_cmd)

            if error is not None:
                self.composite_logger.log_debug('\nEXCEPTION writing package telemetry: ' + repr(error))

        return install_result