Returns the executable and all defined arguments.
762920
String[] getCommandLine() {
        List<String> args = new ArrayList<>();
        if (executable != null) {
            args.add(executable);
        }
        for (int i = 0; i < arguments.size(); i++) {
            CommandArgument argument = arguments.get(i);
            args.add(argument.forCommandLine());
        }
        return args.toArray(new String[args.size()]);
    }
103746
protected function parseArguments()
	{
		// Get the list of argument values from the environment.
		$args = $_SERVER['argv'];

		// Set the path used for program execution and remove it form the program arguments.
		$this->executable = array_shift($args);

		// We use a for loop because in some cases we need to look ahead.
		for ($i = 0; $i < count($args); $i++)
		{
			// Get the current argument to analyze.
			$arg = $args[$i];

			// First let's tackle the long argument case.  eg. --foo
			if (strlen($arg) > 2 && substr($arg, 0, 2) == '--')
			{
				// Attempt to split the thing over equals so we can get the key/value pair if an = was used.
				$arg = substr($arg, 2);
				$parts = explode('=', $arg);
				$this->data[$parts[0]] = true;

				// Does not have an =, so let's look ahead to the next argument for the value.
				if (count($parts) == 1 && isset($args[$i + 1]) && preg_match('/^--?.+/', $args[$i + 1]) == 0)
				{
					$this->data[$parts[0]] = $args[$i + 1];

					// Since we used the next argument, increment the counter so we don't use it again.
					$i++;
				}
				elseif (count($parts) == 2)
				// We have an equals sign so take the second "part" of the argument as the value.
				{
					$this->data[$parts[0]] = $parts[1];
				}
			}

			// Next let's see if we are dealing with a "bunch" of short arguments.  eg. -abc
			elseif (strlen($arg) > 2 && $arg[0] == '-')
			{
				// For each of these arguments set the value to TRUE since the flag has been set.
				for ($j = 1; $j < strlen($arg); $j++)
				{
					$this->data[$arg[$j]] = true;
				}
			}

			// OK, so it isn't a long argument or bunch of short ones, so let's look and see if it is a single
			// short argument.  eg. -h
			elseif (strlen($arg) == 2 && $arg[0] == '-')
			{
				// Go ahead and set the value to TRUE and if we find a value later we'll overwrite it.
				$this->data[$arg[1]] = true;

				// Let's look ahead to see if the next argument is a "value".  If it is, use it for this value.
				if (isset($args[$i + 1]) && preg_match('/^--?.+/', $args[$i + 1]) == 0)
				{
					$this->data[$arg[1]] = $args[$i + 1];

					// Since we used the next argument, increment the counter so we don't use it again.
					$i++;
				}
			}

			// Last but not least, we don't have a key/value based argument so just add it to the arguments list.
			else
			{
				$this->args[] = $arg;
			}
		}
	}
352482
def invocation():
    """"""
    cmdargs = [sys.executable] + sys.argv[:]
    invocation = " ".join(shlex.quote(s) for s in cmdargs)
    return invocation
889451
def _ctypes_ex_parameters(executable):
    
    result = []
    for p in executable.ordered_parameters:
        result.extend(p.ctypes_parameter())

    if type(executable).__name__ == "Function":
        result.extend(executable.ctypes_parameter()) #This method inherits from ValueElement.
        
    return result
1067777
def _make_executable(path):
    """"""
    os.chmod(path, os.stat(path).st_mode | stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH)
920745
def __find_executables(path):
    
    
    success = False
    progs = {'dot': '', 'twopi': '', 'neato': '', 'circo': '', 'fdp': '', 'sfdp': ''}
    
    was_quoted = False
    path = path.strip()
    if path.startswith('"') and path.endswith('"'):
        path = path[1:-1]
        was_quoted =  True
    
    if os.path.isdir(path) : 
    
        for prg in progs.iterkeys():
    
            if progs[prg]:
                continue
               
            if os.path.exists( os.path.join(path, prg) ):
                
                if was_quoted:
                    progs[prg] = '"' + os.path.join(path, prg) + '"'
                else:
                    progs[prg] = os.path.join(path, prg)
                    
                success = True
               
            elif os.path.exists( os.path.join(path, prg + '.exe') ):

                if was_quoted:
                    progs[prg] = '"' + os.path.join(path, prg + '.exe') + '"'
                else:
                    progs[prg] = os.path.join(path, prg + '.exe')
                    
                success = True
    
    if success:
    
        return progs
        
    else:
    
        return None
308514
def check_executables():
    """"""
    print("\033[1mCheck executables\033[0m")
    required_executables = [utils.get_nntoolkit()]
    for executable in required_executables:
        path = which(executable)
        if path is None:
            print("%s ... %sNOT%s found" % (executable, Bcolors.WARNING,
                                            Bcolors.ENDC))
        else:
            print("%s ... %sfound%s at %s" % (executable, Bcolors.OKGREEN,
                                              Bcolors.ENDC, path))
265183
def find_executable(executable, path=None):
  
  if path is None:
    path = os.environ['PATH']
  paths = path.split(os.pathsep)
  base, ext = os.path.splitext(executable)

  if (sys.platform == 'win32' or os.name == 'os2') and (ext != '.exe'):
    executable = executable + '.exe'

  if not os.path.isfile(executable):
    for p in paths:
      f = os.path.join(p, executable)
      if os.path.isfile(f):
        # the file exists, we have a shot at spawn working
        return f
    return None
  else:
    return executable
423057
def _get_args():
    """"""
    parser = argparse.ArgumentParser(description=__doc__)
    # add the argument for the Super Mario Bros environment to run
    parser.add_argument('--rom', '-r',
        type=str,
        help='The path to the ROM to play.',
        required=True,
    )
    # add the argument for the mode of execution as either human or random
    parser.add_argument('--mode', '-m',
        type=str,
        default='human',
        choices=['human', 'random'],
        help='The execution mode for the emulation.',
    )
    # add the argument for the number of steps to take in random mode
    parser.add_argument('--steps', '-s',
        type=int,
        default=500,
        help='The number of random steps to take.',
    )
    return parser.parse_args()
1131661
def get_executable():
    '''
    
    '''
    pymap = {}
    with open(os.path.join(OPTIONS.saltdir, 'supported-versions')) as _fp:
        for line in _fp.readlines():
            ns, v_maj, v_min = line.strip().split(':')
            pymap[ns] = (int(v_maj), int(v_min))

    pycmds = (sys.executable, 'python3', 'python27', 'python2.7', 'python26', 'python2.6', 'python2', 'python')
    for py_cmd in pycmds:
        cmd = py_cmd + ' -c  "import sys; sys.stdout.write(\'%s:%s\' % (sys.version_info[0], sys.version_info[1]))"'
        stdout, _ = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True).communicate()
        if sys.version_info[0] == 2 and sys.version_info[1] < 7:
            stdout = stdout.decode(get_system_encoding(), "replace").strip()
        else:
            stdout = stdout.decode(encoding=get_system_encoding(), errors="replace").strip()
        if not stdout:
            continue
        c_vn = tuple([int(x) for x in stdout.split(':')])
        for ns in pymap:
            if c_vn[0] == pymap[ns][0] and c_vn >= pymap[ns] and os.path.exists(os.path.join(OPTIONS.saltdir, ns)):
                return py_cmd

    sys.exit(EX_THIN_PYTHON_INVALID)
1136517
def program_files(self, executable):
        
        if self._get_version() == 6:
            paths = self.REQUIRED_PATHS_6
        elif self._get_version() > 6:
            paths = self.REQUIRED_PATHS_7_1

        return paths
570549
def _find_executables(self):
        
        if len(self.needs) > 0:
            return
        
        for execname, executable in list(self.module.executables.items()):
            skip = False
            #At the moment we can't handle executables that use special derived types.
            if not execname in self.module.publics or not executable.primitive:
                msg.info("Skipping {}.{} because it is not public.".format(self.module.name, execname))
                skip = True
            #Check that all the parameters have intent specified, otherwise we won't handle them well.ha
            if any([p.direction == "" for p in executable.ordered_parameters]):
                msg.warn("Some parameters in {}.{} have no intent".format(self.module.name, execname) +
                         " specified. Can't wrap that executable.")
                skip = True
    
            if not skip:
                self.uses.append(execname)
                for depmod in executable.search_dependencies():
                    if depmod not in self.needs:
                        self.needs.append(depmod)
635951
def _get_script_args(cls, type_, name, header, script_text):
        
        if type_ == 'gui':
            launcher_type = 'gui'
            ext = '-script.pyw'
            old = ['.pyw']
        else:
            launcher_type = 'cli'
            ext = '-script.py'
            old = ['.py', '.pyc', '.pyo']
        hdr = cls._adjust_header(type_, header)
        blockers = [name + x for x in old]
        yield (name + ext, hdr + script_text, 't', blockers)
        yield (
            name + '.exe', get_win_launcher(launcher_type),
            'b'  # write in binary mode
        )
        if not is_64bit():
            # install a manifest for the launcher to prevent Windows
            # from detecting it as an installer (which it will for
            #  launchers like easy_install.exe). Consider only
            #  adding a manifest for launchers detected as installers.
            #  See Distribute #143 for details.
            m_name = name + '.exe.manifest'
            yield (m_name, load_launcher_manifest(name), 't')
1353150
def executables
      scripts = []

      if @bin_dir.directory?
        @bin_dir.entries.each do |path|
          scripts << path.basename.to_s if path.file?
        end
      end

      return scripts
    end
980364
def _getRegisteredExecutable(exeName):
    """"""
    registered = None
    if sys.platform.startswith('win'):
        if os.path.splitext(exeName)[1].lower() != '.exe':
            exeName += '.exe'
        import _winreg
        try:
            key = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths\\" +\
                  exeName
            value = _winreg.QueryValue(_winreg.HKEY_LOCAL_MACHINE, key)
            registered = (value, "from HKLM\\"+key)
        except _winreg.error:
            pass
        if registered and not os.path.exists(registered[0]):
            registered = None
    return registered
148527
def _find_executables(name):
    
    exe_name = name + '.exe' * sys.platform.startswith('win')
    env_path = os.environ.get(name.upper()+ '_PATH', '')
    
    possible_locations = []
    def add(*dirs):
        for d in dirs:
            if d and d not in possible_locations and os.path.isdir(d):
                possible_locations.append(d)
    
    # Get list of possible locations
    add(env_path)
    try:
        add(os.path.dirname(os.path.abspath(__file__)))
    except NameError:  # __file__ may not exist
        pass
    add(os.path.dirname(sys.executable))
    add(os.path.expanduser('~'))
    
    # Platform specific possible locations
    if sys.platform.startswith('win'):
        add('c:\\program files', os.environ.get('PROGRAMFILES'),
            'c:\\program files (x86)', os.environ.get('PROGRAMFILES(x86)'))
    else:
        possible_locations.extend(['/usr/bin','/usr/local/bin','/opt/local/bin'])
    
    def do_check_version(exe):
        try:
            return subprocess.check_output([exe, '--version']).decode().strip()
        except Exception:
            # print('not a good exe', exe)
            return False
    
    # If env path is the exe itself ...
    if os.path.isfile(env_path):
        ver = do_check_version(env_path)
        if ver:
            return env_path, ver
    
    # First try to find obvious locations
    for d in possible_locations:
        for exe in [os.path.join(d, exe_name), os.path.join(d, name, exe_name)]:
            if os.path.isfile(exe):
                ver = do_check_version(exe)
                if ver:
                    return exe, ver
    
    # Maybe the exe is on the PATH
    ver = do_check_version(exe_name)
    if ver:
        return exe_name, ver
        
    # Try harder
    for d in possible_locations:
        for sub in reversed(sorted(os.listdir(d))):
            if sub.startswith(name):
                exe = os.path.join(d, sub, exe_name)
                if os.path.isfile(exe):
                    ver = do_check_version(exe)
                    if ver:
                        return exe, ver
    
    return None, None
67600
private MysqldExecutable getExecutable() {
        try {
            Field f = AbstractProcess.class.getDeclaredField("executable");
            f.setAccessible(true);
            return (MysqldExecutable) f.get(this);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }