From d30715cc849afe831848251ffe861ea62c18306b Mon Sep 17 00:00:00 2001 From: Adam Waldenberg Date: Thu, 29 Oct 2015 03:36:04 +0100 Subject: [PATCH] The changes module now also outputs the progress when in text mode. Furthermore, the output also shows the pass currently running. This is important, as the progress goes from 0 to 100%, twice. --- gitinspector/blame.py | 2 +- gitinspector/changes.py | 8 +++++++- gitinspector/output/changesoutput.py | 4 ++++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/gitinspector/blame.py b/gitinspector/blame.py index 6079ae2..f049167 100644 --- a/gitinspector/blame.py +++ b/gitinspector/blame.py @@ -119,7 +119,7 @@ class BlameThread(threading.Thread): __thread_lock__.release() # Lock controlling the number of threads running -PROGRESS_TEXT = N_("Checking how many rows belong to each author (Progress): {0:.0f}%") +PROGRESS_TEXT = N_("Checking how many rows belong to each author (2 of 2): {0:.0f}%") class Blame(object): def __init__(self, hard, useweeks, changes): diff --git a/gitinspector/changes.py b/gitinspector/changes.py index 408d5a7..0f7041f 100644 --- a/gitinspector/changes.py +++ b/gitinspector/changes.py @@ -23,7 +23,8 @@ import multiprocessing import os import subprocess import threading -from . import extensions, filtering, interval +from .localization import N_ +from . import extensions, filtering, format, interval, terminal CHANGES_PER_THREAD = 200 NUM_THREADS = multiprocessing.cpu_count() @@ -167,6 +168,8 @@ class ChangesThread(threading.Thread): __changes_lock__.release() # ...to here. __thread_lock__.release() # Lock controlling the number of threads running +PROGRESS_TEXT = N_("Fetching and calculating primary statistics (1 of 2): {0:.0f}%") + class Changes(object): authors = {} authors_dateinfo = {} @@ -191,6 +194,9 @@ class Changes(object): second_hash = entry ChangesThread.create(hard, self, first_hash, second_hash, i) first_hash = entry + ".." + + if format.is_interactive_format(): + terminal.output_progress(_(PROGRESS_TEXT), i, len(lines)) else: entry = entry.decode("utf-8", "replace").strip() second_hash = entry diff --git a/gitinspector/output/changesoutput.py b/gitinspector/output/changesoutput.py index 50f87cc..b982e8e 100644 --- a/gitinspector/output/changesoutput.py +++ b/gitinspector/output/changesoutput.py @@ -20,6 +20,7 @@ from __future__ import print_function from __future__ import unicode_literals import json +import sys import textwrap from ..localization import N_ from .. import format, gravatar, terminal @@ -128,6 +129,9 @@ class ChangesOutput(Outputable): print("\t\t\"exception\": \"" + _(NO_COMMITED_FILES_TEXT) + "\"") def output_text(self): + if sys.stdout.isatty() and format.is_interactive_format(): + terminal.clear_row() + authorinfo_list = self.changes.get_authorinfo_list() total_changes = 0.0