Return if msiexec.exe will be used and the command to invoke it.
513266
def _get_msiexec(use_msiexec):
    '''
    
    '''
    if use_msiexec is False:
        return False, ''
    if isinstance(use_msiexec, six.string_types):
        if os.path.isfile(use_msiexec):
            return True, use_msiexec
        else:
            log.warning(
                "msiexec path '%s' not found. Using system registered "
                "msiexec instead", use_msiexec
            )
            use_msiexec = True
    if use_msiexec is True:
        return True, 'msiexec'
1207337
def is_exe(fpath):
    
    return os.path.isfile(fpath) and os.access(fpath, os.X_OK)
67565
def which(program, add_win_suffixes=True):
    
    def is_exe(fpath):
        """Determine if program exists and is executable."""
        return os.path.isfile(fpath) and os.access(fpath, os.X_OK)

    fpath, fname = os.path.split(program)
    if add_win_suffixes and platform.system().lower() == 'windows' and not (
            fname.endswith('.exe') or fname.endswith('.cmd')):
        fnames = [fname + '.exe', fname + '.cmd']
    else:
        fnames = [fname]

    for i in fnames:
        if fpath:
            exe_file = os.path.join(fpath, i)
            if is_exe(exe_file):
                return exe_file
        else:
            for path in os.environ['PATH'].split(os.pathsep):
                exe_file = os.path.join(path, i)
                if is_exe(exe_file):
                    return exe_file

    return None
352482
def invocation():
    """"""
    cmdargs = [sys.executable] + sys.argv[:]
    invocation = " ".join(shlex.quote(s) for s in cmdargs)
    return invocation
1219623
def check_output(self, cmd):
        
        ret, output = self._call(cmd, True)
        if ret != 0:  # pragma: no cover
            raise RemoteCommandFailure(command=cmd, ret=ret)
        logger.debug("Output: %r", output)
        return output
28829
def perform_command(self):
        
        # if no actual arguments, print help
        if len(self.actual_arguments) < 1:
            return self.print_help(short=True)

        # check if we have a recognized tool switch
        for cls, switches in self.TOOLS:
            if self.has_option(switches):
                arguments = [a for a in sys.argv if a not in switches]
                return cls(invoke=(self.invoke + u" %s" % switches[0])).run(arguments=arguments)

        # check if we have -h, --help, or --version
        if u"-h" in self.actual_arguments:
            return self.print_help(short=True)
        if u"--help" in self.actual_arguments:
            return self.print_help(short=False)
        if u"--version" in self.actual_arguments:
            return self.print_name_version()

        # default to run ExecuteTaskCLI
        return ExecuteTaskCLI(invoke=self.invoke).run(arguments=sys.argv)
494131
def check_tool_aux(command):
    
    assert isinstance(command, basestring)
    dirname = os.path.dirname(command)
    if dirname:
        if os.path.exists(command):
            return command
        # Both NT and Cygwin will run .exe files by their unqualified names.
        elif on_windows() and os.path.exists(command + '.exe'):
            return command
        # Only NT will run .bat files by their unqualified names.
        elif os_name() == 'NT' and os.path.exists(command + '.bat'):
            return command
    else:
        paths = path.programs_path()
        if path.glob(paths, [command]):
            return command
979746
def has_shell_command(self, command):
        
        try:
            output = self.shell(['command', '-v',
                                 command]).decode('utf-8').strip()
            return command in output
        except AdbError:
            # If the command doesn't exist, then 'command -v' can return
            # an exit code > 1.
            return False
909162
def is_executable(path):
    ''''''
    return (stat.S_IXUSR & os.stat(path)[stat.ST_MODE]
            or stat.S_IXGRP & os.stat(path)[stat.ST_MODE]
            or stat.S_IXOTH & os.stat(path)[stat.ST_MODE])
1293178
def run!(cmd)
      cmd = @before_run_block.call(cmd) if @before_run_block
      return false unless cmd
      say "!txtgrn!> #{cmd}" unless Runfile.quiet
      exec cmd
    end
1260985
def exec_or_exit(cmd)
      status = execute(cmd)
      if (status.to_i.nonzero?)
        error("The command '#{cmd}' failed with exit status #{status.to_i}")
      end
      status
    end
560405
def isexec(path):
    '''
    
    '''
    return os.path.isfile(path) and os.access(path, os.X_OK)
383379
def _run_command(self, cmdline):
        """"""
        try:
            if self.verbose:
                print(cmdline)
            subprocess.check_call(cmdline, shell=True)
        except subprocess.CalledProcessError:
            print('when running: ', cmdline)
            raise
334014
static String extractMsi(String msiFile) {
        LOGGER.entering(msiFile);

        Process process = null;
        String exeFilePath = null;
        boolean isMsiExtracted = true;
        try {
            process = Runtime.getRuntime().exec(
                    new String[] { "msiexec", "/a", msiFile, "/qn", "TARGETDIR=" + SeLionConstants.SELION_HOME_DIR });
            process.waitFor();
        } catch (IOException e) {
            LOGGER.log(Level.SEVERE, "Could not find file " + msiFile, e);
            isMsiExtracted = false;
        } catch (InterruptedException e) {
            LOGGER.log(Level.SEVERE, "Exception waiting for msiexec to be finished", e);
            isMsiExtracted = false;
        } finally {
            process.destroy();
        }

        if (isMsiExtracted) {
            moveExeFileToSeLionHomeAndDeleteExtras();
            exeFilePath = FileUtils.getFile(SeLionConstants.SELION_HOME_DIR + SeLionConstants.EDGE_DRIVER)
                    .getAbsolutePath();
        }

        LOGGER.exiting(exeFilePath);
        return exeFilePath;

    }
8693
def execute(cmd):
    """"""
    proc = Popen(cmd, stdout=PIPE)
    stdout, _ = proc.communicate()
    if proc.returncode != 0:
        raise CalledProcessError(proc.returncode, " ".join(cmd))

    return stdout.decode('utf8')
552552
def selfcheck(tools):
    
    msg = []
    for tool_name, check_cli in collections.OrderedDict(tools).items():
        try:
            subprocess.check_output(check_cli, shell=True, stderr=subprocess.STDOUT)
        except subprocess.CalledProcessError:
            msg.append('%r not found or not usable.' % tool_name)
    return '\n'.join(msg) if msg else 'Your system is ready.'
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