Custom Python executable value has been changed
542307
def python_executable_changed(self, pyexec):
        """"""
        if not self.cus_exec_radio.isChecked():
            return False
        def_pyexec = get_python_executable()
        if not is_text_string(pyexec):
            pyexec = to_text_string(pyexec.toUtf8(), 'utf-8')
        if pyexec == def_pyexec:
            return False
        if (not programs.is_python_interpreter(pyexec) or
                not self.warn_python_compatibility(pyexec)):
            QMessageBox.warning(self, _('Warning'),
                    _("You selected an invalid Python interpreter for the "
                      "console so the previous interpreter will stay. Please "
                      "make sure to select a valid one."), QMessageBox.Ok)
            self.def_exec_radio.setChecked(True)
            return False
        return True
1325952
def exec_python_rc(*args, **kwargs):
    
    cmdargs, kwargs = __wrap_python(args, kwargs)
    return exec_command_rc(*cmdargs, **kwargs)
1351361
function getPythonExecutable(options, platform) {
    if (options.virtualenv) {
      var isWin = /^win/.test(platform);
      var pythonExec = isWin ?
        path.join(options.virtualenv, 'Scripts', 'python.exe') :
        path.join(options.virtualenv, 'bin', 'python');
      delete options.virtualenv;
      return pythonExec;
    } else {
      return 'python';
    }
  }
218180
def fix_builtins(override_debug=False):
    """"""
    override_dict = {}
    orig_print = None
    used_print = None

    if(__builtins__.__class__ is dict):
        builtins_dict = __builtins__
    else:
        try:
            import builtins
        except ImportError:
            import __builtin__ as builtins
        builtins_dict = builtins.__dict__

    def _deprecated(*args, **kwargs):
        """Report the fact that the called function is deprecated."""
        import traceback
        raise DeprecationWarning("the called function is deprecated => " +
                                 traceback.extract_stack(None, 2)[0][3])

    def _print_wrapper(*args, **kwargs):
        flush = kwargs.get("flush", False)
        if "flush" in kwargs:
            del kwargs["flush"]
        orig_print(*args, **kwargs)
        if flush:
            kwargs.get("file", sys.stdout).flush()

    def _print_full(*args, **kwargs):
        opt = {"sep": " ", "end": "\n", "file": sys.stdout, "flush": False}
        for key in kwargs:
            if(key in opt):
                opt[key] = kwargs[key]
            else:
                raise TypeError("'"+key+"' is an invalid keyword argument "
                                "for this function")
        opt["file"].write(opt["sep"].join(str(val) for val in args)+opt["end"])
        if opt["flush"]:
            opt["file"].flush()

    def _sorted(my_list):
        my_list = list(my_list)
        my_list.sort()
        return my_list

    def _format(value, format_spec):
        return value.__format__(format_spec)

    if builtins_dict.get(__name__, False):
        raise RuntimeError(__name__+" already loaded")

    # Exceptions
    if builtins_dict.get("BaseException") is None:
        override_dict["BaseException"] = Exception

    # basestring
    if builtins_dict.get("basestring") is None:
        if builtins_dict.get("bytes") is None:
            import types
            override_dict["basestring"] = types.StringType
        else:
            override_dict["basestring"] = (str, bytes)  # It works only when used in isinstance
    # IntType
    if getattr(int, "__str__", None) is None:
        import types
        override_dict["IntType"] = types.IntType
    else:
        override_dict["IntType"] = int  # Python >= 2.2

    if 'format' not in str.__dict__:
        override_dict["str"] = _Internal.ExtStr
    # Function 'input'
    if builtins_dict.get("raw_input") is not None:
        override_dict["input"] = builtins_dict.get("raw_input")
    override_dict["raw_input"] = _deprecated
    # Function 'print' (also aliased as print_)
    if sys.version_info >= (3, 3):
        used_print = builtins_dict.get("print")
    else:
        orig_print = builtins_dict.get("print")
        if orig_print is not None:
            used_print = _print_wrapper
        else:
            used_print = _print_full
        override_dict["print"] = used_print
    override_dict["print_"] = used_print
    # Function 'sorted'
    if builtins_dict.get("sorted") is None:
        override_dict["sorted"] = _sorted
    # Function 'format'
    if builtins_dict.get("format") is None:
        override_dict["format"] = _format

    override_dict[__name__] = True
    builtins_dict.update(override_dict)
    del override_dict
806385
def _set_program_defaults(cls, programs):
        """"""
        for program in programs:
            val = getattr(cls, program.__name__) \
                and extern.does_external_program_run(program.__name__,
                                                     Settings.verbose)
            setattr(cls, program.__name__, val)
912989
def update(custom_sources=False):
    """"""
    if not shutil.which('git'):
        print('Git executable not found in $PATH.')
        sys.exit(1)

    if not custom_sources:
        print('Creating sources.yaml…')
        write_sources_file()
        print('Cloning sources…')
        sources_file = rel_to_cwd('sources.yaml')
        jobs = yaml_to_job_list(sources_file, rel_to_cwd('sources'))
        git_clone_job_list(jobs)

    print('Cloning templates…')
    jobs = yaml_to_job_list(rel_to_cwd('sources', 'templates', 'list.yaml'),
                            rel_to_cwd('templates'))
    print('Cloning schemes…')
    jobs.extend(yaml_to_job_list(rel_to_cwd('sources', 'schemes', 'list.yaml'),
                                 rel_to_cwd('schemes')))
    git_clone_job_list(jobs)
    print('Completed updating repositories.')
992874
def _ctypes_ex_assign(executable):
    
    result = []
    for p in executable.ordered_parameters:
        _ctypes_code_parameter(result, p, "assign")

    if type(executable).__name__ == "Function":
        _ctypes_code_parameter(result, executable, "assign")

    return result
389117
def _python_shell_default(python_shell, __pub_jid):
    '''
    
    '''
    try:
        # Default to python_shell=True when run directly from remote execution
        # system. Cross-module calls won't have a jid.
        if __pub_jid and python_shell is None:
            return True
        elif __opts__.get('cmd_safe', True) is False and python_shell is None:
            # Override-switch for python_shell
            return True
    except NameError:
        pass
    return python_shell
1259551
def _py_code_variables(lines, executable, lparams, tab):
    
    allparams = executable.ordered_parameters
    if type(executable).__name__ == "Function":
        allparams = allparams + [executable]

    for p in allparams:
        _py_code_parameter(lines, p, "invar", lparams, tab)
        if p.direction == "(out)":
            #We need to reverse the order of the indices to match the fortran code
            #generation of the wrapper.
            _py_code_parameter(lines, p, "outvar", lparams, tab)
            _py_code_parameter(lines, p, "indices", lparams, tab)
        else:
            _py_code_parameter(lines, p, "indices", lparams, tab)
            _py_code_parameter(lines, p, "outvar", lparams, tab)
1110679
def fix_subprocess(override_debug=False, override_exception=False):
    """"""
    import subprocess

    # Exceptions
    if subprocess.__dict__.get("SubprocessError") is None:
        subprocess.SubprocessError = _Internal.SubprocessError
    if _InternalReferences.UsedCalledProcessError is None:
        if "CalledProcessError" in subprocess.__dict__:
            _subprocess_called_process_error(True, subprocess)
        else:
            _subprocess_called_process_error(False, subprocess)
            subprocess.CalledProcessError = _InternalReferences.UsedCalledProcessError

    def _check_output(*args, **kwargs):
        if "stdout" in kwargs:
            raise ValueError("stdout argument not allowed, "
                             "it will be overridden.")
        process = subprocess.Popen(stdout=subprocess.PIPE, *args, **kwargs)
        stdout_data, __ = process.communicate()
        ret_code = process.poll()
        if ret_code is None:
            raise RuntimeWarning("The process is not yet terminated.")
        if ret_code:
            cmd = kwargs.get("args")
            if cmd is None:
                cmd = args[0]
            raise _InternalReferences.UsedCalledProcessError(returncode=ret_code, cmd=cmd, output=stdout_data)
        return stdout_data

    try:
        subprocess.check_output
    except AttributeError:
        subprocess.check_output = _check_output
1218925
def new(self, filename=None):
        """"""
        path = (self.exec_path,)
        if self.exec_path.filetype() in ('py', 'pyw', 'pyz', self.FTYPE):
            # get the absolute path to the python-executable
            p = find_executable("python")
            path = (p, 'python') + path
        else:
            # if run in frozen env (.exe):
            # first arg if execpath of the next session:
            path += (self.exec_path,)
        if filename:
            path += ('-o', filename)
        os.spawnl(os.P_NOWAIT, *path)
195267
def config_value_changed(option):
    
    hook_data = unitdata.HookData()
    with hook_data():
        db = unitdata.kv()
        current = config(option)
        saved = db.get(option)
        db.set(option, current)
        if saved is None:
            return False
        return current != saved
324717
def process_result_value(self, value, dialect):
        
        if value is not None:
            cmd = "value = {}".format(value)
            exec(cmd)
        return value
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
288505
def fix_ipython_startup(fn):
    
    BADSTR = 'TPython::Exec( "" )'
    GOODSTR = 'TPython::Exec( "" );'
    if sys.version_info[0] < 3:
        consts = fn.im_func.func_code.co_consts
    else:
        consts = fn.__code__.co_consts
    if BADSTR not in consts:
        return
    idx = consts.index(BADSTR)
    orig_refcount = sys.getrefcount(consts)
    del consts

    PyTuple_SetItem = ctypes.pythonapi.PyTuple_SetItem
    PyTuple_SetItem.argtypes = (ctypes.py_object,
                                ctypes.c_size_t,
                                ctypes.py_object)

    if sys.version_info[0] < 3:
        consts = ctypes.py_object(fn.im_func.func_code.co_consts)
    else:
        consts = ctypes.py_object(fn.im_func.__code__.co_consts)

    for _ in range(orig_refcount - 2):
        ctypes.pythonapi.Py_DecRef(consts)
    try:
        ctypes.pythonapi.Py_IncRef(GOODSTR)
        PyTuple_SetItem(consts, idx, GOODSTR)
    finally:
        for _ in range(orig_refcount - 2):
            ctypes.pythonapi.Py_IncRef(consts)
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)
1017109
def changed(self, symbol, checked = None):
        """"""
        #Initialize the dictionary if we are the first executable to call this.
        myname = "{}.{}".format(self.module.name, self.name).lower()
        if checked is None:
            checked = []

        if myname not in checked:
            matches = self._get_assignments_in(self._parameters, symbol)
            if (matches is not None and
                (isinstance(matches, bool) and matches == True) or
                (isinstance(matches, list) and len(matches) > 0)):
                return myname
            else:
                #Make sure we don't check any executable twice.
                checked.append(myname)
                #We need to check the dependencies of this executable and
                #see if any of them modify the parameter.
                for dependlist in self.dependencies:
                    for dependency in self.dependencies[dependlist]:
                        if dependency.operator:
                            continue

                        if symbol in dependency.argnames:
                            pindex = dependency.argnames.index(symbol)
                            iexec = dependency.target
                            if iexec is not None:
                                pname = iexec.ordered_parameters[pindex].name.lower()
                                if iexec.changed(pname, checked) != "":
                                    return iexec.full_name
                            else:
                                checked.append(dependency.external_name)
                        else:
                            checked.append(dependency.external_name)
        else:
            return None