diff options
author | jez <jezreel@gmail.com> | 2011-05-21 10:13:45 +0000 |
---|---|---|
committer | Sebastian Thiel <byronimo@gmail.com> | 2011-06-07 21:11:11 +0200 |
commit | 863b386e195bb2b609b25614f732b1b502bc79a4 (patch) | |
tree | 78630d2680d4d47fc2b4d8451b8f46f45b9e77ae /git/util.py | |
parent | dfe3ba3e5c08ee88afe89cc331081bbfbf5520e0 (diff) | |
download | gitpython-863b386e195bb2b609b25614f732b1b502bc79a4.tar.gz |
Add progress tracking for git-clone.
Diffstat (limited to 'git/util.py')
-rw-r--r-- | git/util.py | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/git/util.py b/git/util.py index 7cbef07f..b3a420b3 100644 --- a/git/util.py +++ b/git/util.py @@ -100,6 +100,40 @@ def get_user_id(): # END get username from login return "%s@%s" % (username, platform.node()) +def _digest_process_messages(fh, progress): + """Read progress messages from file-like object fh, supplying the respective + progress messages to the progress instance. + + :return: list(line, ...) list of lines without linebreaks that did + not contain progress information""" + line_so_far = '' + dropped_lines = list() + while True: + char = fh.read(1) + if not char: + break + + if char in ('\r', '\n'): + dropped_lines.extend(progress._parse_progress_line(line_so_far)) + line_so_far = '' + else: + line_so_far += char + # END process parsed line + # END while file is not done reading + return dropped_lines + +def _finalize_proc(proc): + """Wait for the process (clone, fetch, pull or push) and handle its errors accordingly""" + try: + proc.wait() + except GitCommandError,e: + # if a push has rejected items, the command has non-zero return status + # a return status of 128 indicates a connection error - reraise the previous one + if proc.poll() == 128: + raise + pass + # END exception handling + #} END utilities #{ Classes |