Check to see if given python is installed.
978415
def _python_installed(ret, python, user=None):
    '''
    
    '''
    default = __salt__['pyenv.default'](runas=user)
    for version in __salt__['pyenv.versions'](user):
        if version == python:
            ret['result'] = True
            ret['comment'] = 'Requested python exists.'
            ret['default'] = default == python
            break

    return ret
115731
def is_installed(self, package):
        """"""
        if isinstance(package, tuple):
            package = '=='.join(package)
        if package.endswith('.git'):
            pkg_name = os.path.split(package)[1][:-4]
            return pkg_name in self.installed_package_names or \
                    pkg_name.replace('_', '-') in self.installed_package_names
        pkg_tuple = split_package_name(package)
        if pkg_tuple[1] is not None:
            return pkg_tuple in self.installed_packages
        else:
            return pkg_tuple[0].lower() in self.installed_package_names
1289638
def is_installed():
  # type: () -> bool
  
  try:
    # noinspection PyUnresolvedReferences
    from ccurl import Curl as CCurl
  except ImportError:
    return False
  else:
    # noinspection PyUnresolvedReferences
    from iota.crypto import Curl
    return issubclass(Curl, CCurl)
928806
def _isInstalled(fullFname):
    
    if not fullFname: return False
    if not os.path.exists(fullFname): return False
    instAreas = []
    try:
        import site
        instAreas = site.getsitepackages()
    except:
        pass # python 2.6 and lower don't have site.getsitepackages()
    if len(instAreas) < 1:
        instAreas = [ os.path.dirname(os.__file__) ]
    for ia in instAreas:
        if fullFname.find(ia) >= 0:
            return True
    return False
1205922
def is_rpm_installed():
    """"""
    try:
        version_result = subprocess.run(["rpm", "--usage"],
                                        stdout=subprocess.PIPE,
                                        stderr=subprocess.PIPE)
        rpm_installed = not version_result.returncode
    except FileNotFoundError:
        rpm_installed = False
    return rpm_installed
800227
def is_in_pythonpath(self, dirname):
        """"""
        return fixpath(dirname) in [fixpath(_p) for _p in self.pythonpath]
583261
def _check_ver(pyver, op, wanted):
    '''
    
    '''
    pyver = distutils.version.LooseVersion(pyver)
    wanted = distutils.version.LooseVersion(wanted)
    return getattr(operator, '__{}__'.format(op))(pyver, wanted)
1140518
def is_plugin_installed(name):
    
    for directory in plugin_paths:
        if isdir(join(directory, name)):
            return True
    return False
761569
def check_py_version():
    """"""
    try:
        if sys.version_info >= (2, 7):
            return
    except:
        pass
    print(" ")
    print(" ERROR - memtop needs python version at least 2.7")
    print(("Chances are that you can install newer version from your "
           "repositories, or even that you have some newer version "
           "installed yet."))
    print("(one way to find out which versions are installed is to try "
          "following: 'which python2.7' , 'which python3' and so...)")
    print(" ")
    sys.exit(-1)
826270
def is_python_script(filename):
    '''
    '''
    if filename.lower().endswith('.py'):
        return True

    if not os.path.isfile(filename):
        return False

    try:
        with open(filename, 'rb') as fp:
            if fp.read(2) != b'#!':
                return False
            return re.match(r'.*python', str_(fp.readline()))
    except IOError:
        pass

    return False
789347
def check_version(self, name, majorv=2, minorv=7):
        
        if sys.version_info.major == majorv and sys.version_info.minor != minorv:
            sys.stderr.write("ERROR: %s is only for >= Python %d.%d but you are running %d.%d\n" %\
                        (name, majorv, minorv, sys.version_info.major, sys.version_info.minor))
            sys.exit(1)
760270
def check_installed_debian(pkgname):
    
    import utool as ut
    #pkgname = 'espeak'
    #pkgname = 'sudo'
    #ut.cmd('hash ' + pkgname + ' 2>/dev/null')
    tup = ut.cmd('hash ' + pkgname + ' 2>/dev/null', quiet=True, pad_stdout=False)
    out, err, ret = tup
    is_installed = (ret == 0)
    return is_installed
894307
def check_program(self, name):
        
        if not check_program(name):
            raise management.CommandError(
                "The program \"{name:s}\" is not available in the shell. "
                "Please ensure that \"{name:s}\" is installed and reachable "
                "through your PATH environment variable.".format(
                    name=name))
25275
def isApplicationInstalled(self, pchAppKey):
        """"""

        fn = self.function_table.isApplicationInstalled
        result = fn(pchAppKey)
        return result
1326512
def is_py_script(filename):
    ""
    if not os.path.exists(filename) and os.path.isfile(filename):
        return False
    elif filename.endswith(".py"):
        return True
    elif not os.access(filename, os.X_OK):
        return False
    else:
        try:
            with open(filename, "r") as fp:
                first_line = fp.readline().strip()
            return "#!" in first_line and "python" in first_line
        except StopIteration:
            return False
1106973
def python_executable(self):
        """"""
        return self.get(property_name='python_executable',
                        default=sys.executable or os.path.join(self.install_prefix, 'bin', 'python'))
534054
def is_package_installed(distribution, pkg):
    
    if ('centos' in distribution or
            'el' in distribution or
            'redhat' in distribution):
        return(is_rpm_package_installed(pkg))

    if ('ubuntu' in distribution or
            'debian' in distribution):
        return(is_deb_package_installed(pkg))