Check that ruby is installed
357454
def _check_ruby(ret, ruby, user=None):
    '''
    
    '''
    match_version = True
    match_micro_version = False
    micro_version_regex = re.compile(r'-([0-9]{4}\.[0-9]{2}|p[0-9]+)$')
    if micro_version_regex.search(ruby):
        match_micro_version = True
    if re.search('^[a-z]+$', ruby):
        match_version = False
    ruby = re.sub('^ruby-', '', ruby)

    for impl, version, default in __salt__['rvm.list'](runas=user):
        if impl != 'ruby':
            version = '{impl}-{version}'.format(impl=impl, version=version)
        if not match_micro_version:
            version = micro_version_regex.sub('', version)
        if not match_version:
            version = re.sub('-.*', '', version)
        if version == ruby:
            ret['result'] = True
            ret['comment'] = 'Requested ruby exists.'
            ret['default'] = default
            break
    return ret
77429
def check_need_install():
    
    md5_root, md5_dst = list(), list()
    need_install_flag = False
    for root, _, basename_list in os.walk(_ROOT):
        if os.path.basename(root) != "__pycache__":
            for basename in basename_list:
                src = os.path.join(root, basename)
                dst = os.path.join(root.replace(_ROOT, _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
1101935
def _check_cygwin_installed(cyg_arch='x86_64'):
    '''
    
    '''
    path_to_cygcheck = os.sep.join(['C:',
                                    _get_cyg_dir(cyg_arch),
                                    'bin', 'cygcheck.exe'])
    LOG.debug('Path to cygcheck.exe: %s', path_to_cygcheck)
    if not os.path.exists(path_to_cygcheck):
        LOG.debug('Could not find cygcheck.exe')
        return False
    return True
1276772
def checks_pass?
      rv = true
      unless File.exist?(@platform)
        puts "No platform or invalid platform configuration given: (#{@platform}) !"
        puts "Use either property 'platform' via RakeOE::Config object in the Rakefile or environment variable TOOLCHAIN_ENV"
        rv = false
      end
      rv
    end
358195
def synx_installed?
      match = `#{synx} --version`.match(/Synx (\d+)\.(\d+)\.(\d+)/i)
      if match
        major, minor, patch = match.captures.map { |c| Integer(c) }
        major > 0 || minor > 2 || (minor == 2 && patch > 1)
      else
        false
      end
    end
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
922175
def check_if_exiftool_is_already_installed():
    
    result = 1;
    command = ["exiftool", "-ver"]

    with open(os.devnull, "w") as fnull:
        result = subprocess.call(
            command,
            stdout = fnull,
            stderr = fnull
        )
    #Exiftool is not installed
    if result != 0:
        print_a_header('Exiftool needs to be installed on your system')
        print_a_header('Visit http://www.sno.phy.queensu.ca/~phil/exiftool/')
        return False
    else:
        return True
405361
def was_installed_by_pip(pkg):
    # type: (str) -> bool
    
    try:
        dist = pkg_resources.get_distribution(pkg)
        return (dist.has_metadata('INSTALLER') and
                'pip' in dist.get_metadata_lines('INSTALLER'))
    except pkg_resources.DistributionNotFound:
        return False
900722
def is_installed(self):
        
        return self.is_configured() and os.access(self.bin(), os.X_OK)
629504
def check(self):
        ""
        config = self.load_config()
        if not check_dependency_epubcheck():
            sys.exit(error('Unavailable command.'))
        epub_file = u"%s.epub" % config['fileroot']
        epub_path = join(CWD, 'build', epub_file)
        print success("Starting to check %s..." % epub_file)
        epubcheck = u'epubcheck %s' % epub_path
        epubcheck = shell(epubcheck.encode())
        for line in epubcheck.errors():
            print error(line)
        for line in epubcheck.output():
            print line
622598
def is_installed(prog):
    """"""
    with open(os.devnull, 'w') as devnull:
        try:
            if os.name == 'nt':
                retcode = subprocess.call(['where', prog], stdout=devnull)
            else:
                retcode = subprocess.call(['which', prog], stdout=devnull)
        except OSError as e:
            # If where or which doesn't exist, a "ENOENT" error will occur (The
            # FileNotFoundError subclass on Python 3).
            if e.errno != errno.ENOENT:
                raise
            retcode = 1

    return retcode == 0
25275
def isApplicationInstalled(self, pchAppKey):
        """"""

        fn = self.function_table.isApplicationInstalled
        result = fn(pchAppKey)
        return result
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)
53321
def is_python_binding_installed(self):
        
        is_installed = False
        is_install_error = False

        try:
            is_installed = self.is_python_binding_installed_on_pip()
        except InstallError:
            # Consider a case of pip is not installed in old Python (<= 2.6).
            is_install_error = True
        if not is_installed or is_install_error:
            for rpm_dir in self.python_lib_rpm_dirs:
                init_py = os.path.join(rpm_dir, '__init__.py')
                if os.path.isfile(init_py):
                    is_installed = True
                    break

        return is_installed
781174
def _CheckInstallSuccess(self):
    """"""
    if not os.path.exists(self.install_path):
      raise RuntimeError("Install failed, no files at: %s" % self.install_path)

    try:
      output = subprocess.check_output(["sc", "query", self.service_name])
      service_running = "RUNNING" in output
    except subprocess.CalledProcessError as e:
      if e.returncode == 1060:
        # 1060 means: The specified service does not exist as an installed
        # service.
        service_running = False
      else:
        raise

    if self.expect_service_running:
      if not service_running:
        raise RuntimeError(
            "GRR service not running after install, sc query output: %s" %
            output)
    else:
      if service_running:
        raise RuntimeError(
            "GRR service running after install with expect_service_running == "
            "False, sc query output: %s" % output)
1098271
def check_executable(tool_name):
    """"""
    result = subprocess.call(['which', tool_name], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
    if result != 0:
        message = "The executable '%s' cannot be found in your $PATH" % tool_name
        raise Exception(message)
1191023
def installed?(package)
      fail LookupFailed, 'No supported package tool found.' if tool.nil?

      cmd = tools[tool]
      fail LookupFailed, "Package tool '#{cmd}' not found." if command?(cmd).nil?

      send tool, package
    end