Try to install .deb packages given by list.

    Return True, if packages could be installed or are installed already, or if
    they cannot be installed but the user gives feedback to continue.

    Else return False.
766932
def install_packages(packages,
                     what_for='for a complete setup to work properly'):
    '''
    '''
    res = True
    non_installed_packages = _non_installed(packages)
    packages_str = '  '.join(non_installed_packages)
    if non_installed_packages:
        with quiet():
            dpkg = _has_dpkg()
        hint = '  (You may have to install them manually)'
        do_install = False
        go_on = True
        if dpkg:
            if _is_sudoer('Want to install dpkg packages'):
                do_install = True
            else:
                do_install is False  # cannot install anything
                info = yellow(' '.join([
                    'This deb packages are missing to be installed',
                    flo("{what_for}: "), ', '.join(non_installed_packages),
                ]))
                question = '  Continue anyway?'
                go_on = query_yes_no(info + hint + question, default='no')
        else:
            # dpkg == False, unable to determine if packages are installed
            do_install = False  # cannot install anything
            info = yellow(' '.join([
                flo('Required {what_for}: '),
                ', '.join(non_installed_packages),
            ]))
            go_on = query_yes_no(info + hint + '  Continue?', default='yes')
        if not go_on:
            sys.exit('Abort')
        if do_install:
            command = flo('sudo  apt-get install {packages_str}')
            res = run(command).return_code == 0
    return res
335980
def find_installed_packages(self):
        
        list_command = subprocess.Popen(self.list_command, shell=True, stdout=subprocess.PIPE)
        stdout, stderr = list_command.communicate()
        if list_command.returncode != 0:
            raise SystemDependencyError("The command to list the installed system packages failed! ({command})",
                                        command=self.list_command)
        installed_packages = sorted(stdout.decode().split())
        logger.debug("Found %i installed system package(s): %s", len(installed_packages), installed_packages)
        return installed_packages
9649
def install
      return false unless install? quiet: !(logger.level == Logger::DEBUG)

      UNIT_TYPES.each do |type|
        units[type.to_s.pluralize.to_sym].each do |unit|
          return nil unless install_unit(unit, type)
        end
      end
      true
    end
1292175
def is_installed(self, pkgname):
        

        return any(d for d in self.get_distributions() if d.project_name == pkgname)
1008431
def _ask_to_confirm(self, ui, pac_man, *to_install):
        
        ret = DialogHelper.ask_for_package_list_confirm(
            ui, prompt=pac_man.get_perm_prompt(to_install),
            package_list=to_install,
        )
        return bool(ret)
892166
def check_exec_installed(exec_list):
    
    all_installed = True
    for exe in exec_list:
        if not is_tool(exe):
            print("Executable: " + exe + " is not installed")
            all_installed = False
    return all_installed
290867
def installed_packages(self):
        
        packages = []
        CMDLINE = [sys.executable, "-mpip", "freeze"]
        try:
            for package in subprocess.check_output(CMDLINE) \
                    .decode('utf-8'). \
                    splitlines():
                for comparator in ["==", ">=", "<=", "<", ">"]:
                    if comparator in package:
                        # installed package names usually look like Pillow==2.8.1
                        # ignore others, like external packages that pip show
                        # won't understand
                        name = package.partition(comparator)[0]
                        packages.append(name)
        except RuntimeError as e:
            if logger.isEnabledFor(logging.DEBUG):
                logger.debug("Exception checking existing packages.")
                logger.debug("cmdline: %s", CMDLINE)
                ex_type, ex, tb = sys.exc_info()
                traceback.print_tb(tb)
                logger.debug()
        return packages
779311
function isInstalled(dep) {
    if (_.has(exceptions, dep)) return exceptions[dep];
    return installedDeps.has(dep);
}
1230862
def verify_dependencies(self):
        

        for i in range(1, len(self.deps)):
            assert(not (isinstance(self.deps[i], Transformation) and
                   isinstance(self.deps[i - 1], Analysis))
                   ), "invalid dep order for %s" % self
964784
def list_packages(conn=None):
    '''
    
    '''
    close = False
    if conn is None:
        close = True
        conn = init()

    ret = []
    data = conn.execute('SELECT package FROM packages')
    for pkg in data.fetchall():
        ret.append(pkg)

    if close:
        conn.close()
    return ret
718097
def is_installed(gemname, version=None):
    """"""
    cmdline = ['gem', 'list', '-i', gemname]
    if version:
        cmdline.extend(['-v', version])
    try:
        subprocess.check_output(cmdline, shell=False)
        return True
    except (OSError, subprocess.CalledProcessError) as err:
        if err.returncode == 1:
            return False
        else:
            raise error.ButcherError(
                'Failure running gem. Error was: %s. Output: %s', err,
                err.output)
805827
def _check_all_deps(self, pkg_name=None, pkg_file=None, formula_def=None):
        '''
        
        '''
        if pkg_file and not os.path.exists(pkg_file):
            raise SPMInvocationError('Package file {0} not found'.format(pkg_file))

        self.repo_metadata = self._get_repo_metadata()
        if not formula_def:
            for repo in self.repo_metadata:
                if not isinstance(self.repo_metadata[repo]['packages'], dict):
                    continue
                if pkg_name in self.repo_metadata[repo]['packages']:
                    formula_def = self.repo_metadata[repo]['packages'][pkg_name]['info']

        if not formula_def:
            raise SPMInvocationError('Unable to read formula for {0}'.format(pkg_name))

        # Check to see if the package is already installed
        pkg_info = self._pkgdb_fun('info', pkg_name, self.db_conn)
        pkgs_to_install = []
        if pkg_info is None or self.opts['force']:
            pkgs_to_install.append(pkg_name)
        elif pkg_info is not None and not self.opts['force']:
            raise SPMPackageError(
                'Package {0} already installed, not installing again'.format(formula_def['name'])
            )

        optional_install = []
        recommended_install = []
        if 'dependencies' in formula_def or 'optional' in formula_def or 'recommended' in formula_def:
            self.avail_pkgs = {}
            for repo in self.repo_metadata:
                if not isinstance(self.repo_metadata[repo]['packages'], dict):
                    continue
                for pkg in self.repo_metadata[repo]['packages']:
                    self.avail_pkgs[pkg] = repo

            needs, unavail, optional, recommended = self._resolve_deps(formula_def)

            if unavail:
                raise SPMPackageError(
                    'Cannot install {0}, the following dependencies are needed:\n\n{1}'.format(
                        formula_def['name'], '\n'.join(unavail))
                )

            if optional:
                optional_install.extend(optional)
                for dep_pkg in optional:
                    pkg_info = self._pkgdb_fun('info', formula_def['name'])
                    msg = dep_pkg
                    if isinstance(pkg_info, dict):
                        msg = '{0} [Installed]'.format(dep_pkg)
                    optional_install.append(msg)

            if recommended:
                recommended_install.extend(recommended)
                for dep_pkg in recommended:
                    pkg_info = self._pkgdb_fun('info', formula_def['name'])
                    msg = dep_pkg
                    if isinstance(pkg_info, dict):
                        msg = '{0} [Installed]'.format(dep_pkg)
                    recommended_install.append(msg)

            if needs:
                pkgs_to_install.extend(needs)
                for dep_pkg in needs:
                    pkg_info = self._pkgdb_fun('info', formula_def['name'])
                    msg = dep_pkg
                    if isinstance(pkg_info, dict):
                        msg = '{0} [Installed]'.format(dep_pkg)

        return pkgs_to_install, optional_install, recommended_install
1258498
def check_need_install():
    
    need_install_flag = False
    for root, _, basename_list in os.walk(SRC):
        if os.path.basename(root) != "__pycache__":
            for basename in basename_list:
                src = os.path.join(root, basename)
                dst = os.path.join(root.replace(SRC, DST), basename)
                if os.path.exists(dst):
                    if md5_of_file(src) != md5_of_file(dst):
                        return True
                else:
                    return True
    return need_install_flag
525742
def install?(quiet: false)
      result = true
      UNIT_TYPES.each do |type|
        units[type.to_s.pluralize.to_sym].each do |unit|
          result = install_unit?(unit, type, quiet) ? result : false
        end
      end
      result
    end
662732
def is_package(name):
    
    name = name.lower()  # compare package name against lowercase name
    packages = pkg_resources.working_set.by_key.keys()
    for package in packages:
        if package.lower().replace('-', '_') == name:
            return True
    return False
955022
def install_packages
      packages = []
      @scripts.each { |s| packages.push(s.packages) if s.packages && !s.packages.empty? }
      return true if packages.empty?

      success   = false
      installer = RightScale::Platform.installer

      @audit.create_new_section("Installing packages: #{packages.uniq.join(' ')}")
      audit_time do
        success = retry_execution('Installation of packages failed, retrying...') do
          begin
            installer.install(packages)
          rescue Exception => e
            @audit.append_output(installer.output)
            report_failure('Failed to install packages', e.message)
          else
            @audit.append_output(installer.output)
          end
          $?.success?
        end
      end
      report_failure('Failed to install packages', 'Package install exited with bad status') unless success
      true
    end
184807
def get_deps_list(self, pkg_name, installed_distros=None):
        
        # https://github.com/Miserlou/Zappa/issues/1478.  Using `pkg_resources`
        # instead of `pip` is the recommended approach.  The usage is nearly
        # identical.
        import pkg_resources
        deps = []
        if not installed_distros:
            installed_distros = pkg_resources.WorkingSet()
        for package in installed_distros:
            if package.project_name.lower() == pkg_name.lower():
                deps = [(package.project_name, package.version)]
                for req in package.requires():
                    deps += self.get_deps_list(pkg_name=req.project_name, installed_distros=installed_distros)
        return list(set(deps))