Exemple #1
0
    def _get_package_manager(self):
        """ Gets the remote server package manager in an OS agnostic way.

        Returns:
            string: The package manager, if supported.

        Raises:
            ServerError: If the connection closes or we fail to retrieve the package manager.

        """
        stdin, stdout, stderr = self.ssh_client.exec_command(
            "bash -c '%s'" % get_bash_script(Server.SCRIPT_DETECT_PM))

        package_manager = stdout.read().rstrip()

        if package_manager.startswith('[ERROR]'):
            raise ServerError('Could not retrieve the package manager.\n\t> %s' % package_manager)

        return package_manager
Exemple #2
0
    def _get_package_manager(self):
        """ Gets the remote server package manager in an OS agnostic way.

        Returns:
            string: The package manager, if supported.

        Raises:
            ServerError: If the connection closes or we fail to retrieve the package manager.

        """
        stdin, stdout, stderr = self.ssh_client.exec_command(
            "bash -c '%s'" % get_bash_script(Server.SCRIPT_DETECT_PM))

        package_manager = stdout.read().rstrip()

        if package_manager.startswith('[ERROR]'):
            raise ServerError(
                'Could not retrieve the package manager.\n\t> %s' %
                package_manager)

        return package_manager
Exemple #3
0
    def _validate_single_dep_installed(self, pm, dep):
        """ Validates that a specific dependency is installed on the remote server.

        Args:
            pm (string): The server's package manager name.
            dep (string: The dependency to validate.

        Returns:
            bool: If the dependency is installed.

        """
        script = "%s\nis_installed %s %s" % (get_bash_script(Server.SCRIPT_DEP_INSTALLED), pm, dep)
        command = "bash -c '%s'" % script
        stdin, stdout, stderr = self.ssh_client.exec_command(command)

        ret_code, errors = stdout.read().rstrip(), stderr.read().rstrip()

        # if errors is not '':
        # Terminal.print_warn('Got errors from dependency checker script.\n\t> %s' % errors)

        return ret_code == '0'
Exemple #4
0
    def _validate_single_dep_installed(self, pm, dep):
        """ Validates that a specific dependency is installed on the remote server.

        Args:
            pm (string): The server's package manager name.
            dep (string: The dependency to validate.

        Returns:
            bool: If the dependency is installed.

        """
        script = "%s\nis_installed %s %s" % (get_bash_script(
            Server.SCRIPT_DEP_INSTALLED), pm, dep)
        command = "bash -c '%s'" % script
        stdin, stdout, stderr = self.ssh_client.exec_command(command)

        ret_code, errors = stdout.read().rstrip(), stderr.read().rstrip()

        # if errors is not '':
        # Terminal.print_warn('Got errors from dependency checker script.\n\t> %s' % errors)

        return ret_code == '0'