예제 #1
0
    def _call_process(self, method, *args, **kwargs):
        """Run the given git command with the specified arguments and return
        the result as a String

        :param method:
            is the command. Contained "_" characters will be converted to dashes,
            such as in 'ls_files' to call 'ls-files'.

        :param args:
            is the list of arguments. If None is included, it will be pruned.
            This allows your commands to call git more conveniently as None
            is realized as non-existent

        :param kwargs:
            is a dict of keyword arguments.
            This function accepts the same optional keyword arguments
            as execute().

        ``Examples``::
            git.rev_list('master', max_count=10, header=True)

        :return: Same as ``execute``"""
        # Handle optional arguments prior to calling transform_kwargs
        # otherwise these'll end up in args, which is bad.
        _kwargs = {k: v for k, v in kwargs.items() if k in execute_kwargs}
        kwargs = {k: v for k, v in kwargs.items() if k not in execute_kwargs}

        insert_after_this_arg = kwargs.pop('insert_kwargs_after', None)

        # Prepare the argument list
        opt_args = self.transform_kwargs(**kwargs)
        ext_args = self.__unpack_args([a for a in args if a is not None])

        if insert_after_this_arg is None:
            args = opt_args + ext_args
        else:
            try:
                index = ext_args.index(insert_after_this_arg)
            except ValueError:
                raise ValueError(
                    "Couldn't find argument '%s' in args %s to insert kwargs after"
                    % (insert_after_this_arg, str(ext_args)))
            # end handle error
            args = ext_args[:index + 1] + opt_args + ext_args[index + 1:]
        # end handle kwargs

        call = [self.GIT_PYTHON_GIT_EXECUTABLE]

        # add persistent git options
        call.extend(self._persistent_git_options)

        # add the git options, then reset to empty
        # to avoid side_effects
        call.extend(self._git_options)
        self._git_options = ()

        call.append(dashify(method))
        call.extend(args)

        return self.execute(call, **_kwargs)
예제 #2
0
파일: cmd.py 프로젝트: andy-maier/GitPython
    def _call_process(self, method, *args, **kwargs):
        """Run the given git command with the specified arguments and return
        the result as a String

        :param method:
            is the command. Contained "_" characters will be converted to dashes,
            such as in 'ls_files' to call 'ls-files'.

        :param args:
            is the list of arguments. If None is included, it will be pruned.
            This allows your commands to call git more conveniently as None
            is realized as non-existent

        :param kwargs:
            is a dict of keyword arguments.
            This function accepts the same optional keyword arguments
            as execute().

        ``Examples``::
            git.rev_list('master', max_count=10, header=True)

        :return: Same as ``execute``"""
        # Handle optional arguments prior to calling transform_kwargs
        # otherwise these'll end up in args, which is bad.
        _kwargs = {k: v for k, v in kwargs.items() if k in execute_kwargs}
        kwargs = {k: v for k, v in kwargs.items() if k not in execute_kwargs}

        insert_after_this_arg = kwargs.pop('insert_kwargs_after', None)

        # Prepare the argument list
        opt_args = self.transform_kwargs(**kwargs)
        ext_args = self.__unpack_args([a for a in args if a is not None])

        if insert_after_this_arg is None:
            args = opt_args + ext_args
        else:
            try:
                index = ext_args.index(insert_after_this_arg)
            except ValueError:
                raise ValueError("Couldn't find argument '%s' in args %s to insert kwargs after"
                                 % (insert_after_this_arg, str(ext_args)))
            # end handle error
            args = ext_args[:index + 1] + opt_args + ext_args[index + 1:]
        # end handle kwargs

        call = [self.GIT_PYTHON_GIT_EXECUTABLE]

        # add persistent git options
        call.extend(self._persistent_git_options)

        # add the git options, then reset to empty
        # to avoid side_effects
        call.extend(self._git_options)
        self._git_options = ()

        call.append(dashify(method))
        call.extend(args)

        return self.execute(call, **_kwargs)
def build_call(*args): # *.foo ellipsis
    """
    returns the arguments as flattened list
    """
    call = []    
    for arg in args:
        if type(arg) is list:
            for element in arg:
                call.append(element)        
        else:
            call.append(arg)
    if debug:
        print_debug("flattened call: "+str(call))
    return call
예제 #4
0
def compile_call():
    global Output_File
    if Output_File is None or Output_File == "":
        Output_File = path.splitext(Filename)[0] + "_" + "Output"
    call = [
        "clang++-" + str(ClangVer)[0], Filename,
        "-o" + str(Optimisation_Level), "-o", Output_File
    ]
    for dir in include_dirs:
        if dir == "":
            continue
        else:
            arg = "--include-directory="
            arg = arg + dir
            call.append(arg)
    for dir in library_dirs:
        if dir == "":
            continue
        else:
            arg = "--library-directory="
            arg = arg + dir
            call.append(arg)
    if Verbose:
        call.append("--verbose")
    return call
예제 #5
0
def sbatch(ex_script, jobname=None, sys_arg=None):
    """ 
    Summary
    -------
    Python interface to slurm sbatch cmd line function
    
    Args
    ----
    ex_script: executable file (e.g. .sh) to pass to sbacth
    jobname: string to pass as a job name
    sys_arg: dict of named arguments to pass to the program being run 
    
    Returns
    -------
    JOBID (class Jid)
    """
    call = []
    if jobname is not None:
        call.append("--job-name=" + jobname)
    if sys_arg is not None:
        args_list = [i for i in sys_arg.items()]
        arg_name = args_list[0][0]
        arg_val = args_list[0][1]
        call.append("--export=" + str(arg_name) + "=" + str(arg_val))
    call.append(ex_script)
    if sys_arg is not None:
        call.append(str(arg_val))
    make_call = subprocess.run(["sbatch"] + call,
                               stdout=subprocess.PIPE).stdout.decode('utf-8')
    jid = str(str.split(make_call.replace('\n', ''), ' ')[3])
    scontrol = subprocess.run(['scontrol', 'show', 'job', jid],
                              stdout=subprocess.PIPE).stdout.decode('utf-8')
    if len(scontrol):
        scontrol = scontrol.split('\n')
        stdout = []
        for i in scontrol:
            if (re.search('StdOut', i)):
                stdout.append(i)
        tofilepath = re.sub(r'|'.join((r'StdOut=', r' ')), '', stdout[0])
    return (Jid(jid, tofilepath))
예제 #6
0
    def _call_process(self, method, *args, **kwargs):
        """Run the given git command with the specified arguments and return
        the result as a String

        :param method:
            is the command. Contained "_" characters will be converted to dashes,
            such as in 'ls_files' to call 'ls-files'.

        :param args:
            is the list of arguments. If None is included, it will be pruned.
            This allows your commands to call git more conveniently as None
            is realized as non-existent

        :param kwargs:
            It contains key-values for the following:
            - the :meth:`execute()` kwds, as listed in :var:`execute_kwargs`;
            - "command options" to be converted by :meth:`transform_kwargs()`;
            - the `'insert_kwargs_after'` key which its value must match one of ``*args``,
              and any cmd-options will be appended after the matched arg.

        Examples::

            git.rev_list('master', max_count=10, header=True)

        turns into::

           git rev-list max-count 10 --header master

        :return: Same as ``execute``"""
        # Handle optional arguments prior to calling transform_kwargs
        # otherwise these'll end up in args, which is bad.
        exec_kwargs = dict(
            (k, v) for k, v in kwargs.items() if k in execute_kwargs)
        opts_kwargs = dict(
            (k, v) for k, v in kwargs.items() if k not in execute_kwargs)

        insert_after_this_arg = opts_kwargs.pop('insert_kwargs_after', None)

        # Prepare the argument list
        opt_args = self.transform_kwargs(**opts_kwargs)
        ext_args = self.__unpack_args([a for a in args if a is not None])

        if insert_after_this_arg is None:
            args = opt_args + ext_args
        else:
            try:
                index = ext_args.index(insert_after_this_arg)
            except ValueError:
                raise ValueError(
                    "Couldn't find argument '%s' in args %s to insert cmd options after"
                    % (insert_after_this_arg, str(ext_args)))
            # end handle error
            args = ext_args[:index + 1] + opt_args + ext_args[index + 1:]
        # end handle opts_kwargs

        call = [self.GIT_PYTHON_GIT_EXECUTABLE]

        # add persistent git options
        call.extend(self._persistent_git_options)

        # add the git options, then reset to empty
        # to avoid side_effects
        call.extend(self._git_options)
        self._git_options = ()

        call.append(dashify(method))
        call.extend(args)

        return self.execute(call, **exec_kwargs)
예제 #7
0
파일: cmd.py 프로젝트: gitprime/GitPython
    def _call_process(self, method, *args, **kwargs):
        """Run the given git command with the specified arguments and return
        the result as a String

        :param method:
            is the command. Contained "_" characters will be converted to dashes,
            such as in 'ls_files' to call 'ls-files'.

        :param args:
            is the list of arguments. If None is included, it will be pruned.
            This allows your commands to call git more conveniently as None
            is realized as non-existent

        :param kwargs:
            It contains key-values for the following:
            - the :meth:`execute()` kwds, as listed in :var:`execute_kwargs`;
            - "command options" to be converted by :meth:`transform_kwargs()`;
            - the `'insert_kwargs_after'` key which its value must match one of ``*args``,
              and any cmd-options will be appended after the matched arg.
        
        Examples::
        
            git.rev_list('master', max_count=10, header=True)
        
        turns into::
        
           git rev-list max-count 10 --header master

        :return: Same as ``execute``"""
        # Handle optional arguments prior to calling transform_kwargs
        # otherwise these'll end up in args, which is bad.
        exec_kwargs = dict((k, v) for k, v in kwargs.items() if k in execute_kwargs)
        opts_kwargs = dict((k, v) for k, v in kwargs.items() if k not in execute_kwargs)

        insert_after_this_arg = opts_kwargs.pop('insert_kwargs_after', None)

        # Prepare the argument list
        opt_args = self.transform_kwargs(**opts_kwargs)
        ext_args = self.__unpack_args([a for a in args if a is not None])

        if insert_after_this_arg is None:
            args = opt_args + ext_args
        else:
            try:
                index = ext_args.index(insert_after_this_arg)
            except ValueError:
                raise ValueError("Couldn't find argument '%s' in args %s to insert cmd options after"
                                 % (insert_after_this_arg, str(ext_args)))
            # end handle error
            args = ext_args[:index + 1] + opt_args + ext_args[index + 1:]
        # end handle opts_kwargs

        call = [self.GIT_PYTHON_GIT_EXECUTABLE]

        # add persistent git options
        call.extend(self._persistent_git_options)

        # add the git options, then reset to empty
        # to avoid side_effects
        call.extend(self._git_options)
        self._git_options = ()

        call.append(dashify(method))
        call.extend(args)

        return self.execute(call, **exec_kwargs)
def getPandocCall(inputfile, outputfile, template=""):
	call = ["pandoc"]

	# Output file
	call.append("-o")
	call.append(outputfile)

	# Standalone file
	call.append("-s")
	if (template != ""):
		call.append("--template")
		call.append(template)

	# Do not parse html blocks
	call.append("-R")

	# Use listings package for code blocks
	call.append("--listings")

	# Input file
	call.append(inputfile)

	return(call)