Search code examples
pythongitscriptinggitpython

GitPython pipe output to stdout


Doing some very simple scripting in python. I'm cloning the repository to the server with the following statement in a python script:

Repo.clone_from("source", "target")

How can I get the progress from the clone_from and pipe it to stdout?


Solution

  • You could use a git.remote.RemoteProgress as third parameter for the class method clone_from(url, to_path, progress=None, env=None, **kwargs) you are using:

    class Progress(RemoteProgress):
        def line_dropped(self, line):
            print line
        def update(self, *args):
            print self._cur_line