From 61173c4caf44f7393d36f1ef3c4e02514aba393c Mon Sep 17 00:00:00 2001 From: JP White Date: Mon, 22 Feb 2021 19:52:32 -0500 Subject: [PATCH] Use subprocess.Popen default buffer size --- gitinspector/basedir.py | 6 +++--- gitinspector/blame.py | 4 ++-- gitinspector/changes.py | 4 ++-- gitinspector/clone.py | 2 +- gitinspector/config.py | 2 +- gitinspector/filtering.py | 2 +- gitinspector/localization.py | 4 ++-- gitinspector/metrics.py | 4 ++-- 8 files changed, 14 insertions(+), 14 deletions(-) diff --git a/gitinspector/basedir.py b/gitinspector/basedir.py index ae3619b..0d42ec9 100644 --- a/gitinspector/basedir.py +++ b/gitinspector/basedir.py @@ -34,7 +34,7 @@ def get_basedir_git(path=None): previous_directory = os.getcwd() os.chdir(path) - bare_command = subprocess.Popen(["git", "rev-parse", "--is-bare-repository"], bufsize=1, + bare_command = subprocess.Popen(["git", "rev-parse", "--is-bare-repository"], stdout=subprocess.PIPE, stderr=open(os.devnull, "w")) isbare = bare_command.stdout.readlines() @@ -47,9 +47,9 @@ def get_basedir_git(path=None): absolute_path = None if isbare: - absolute_path = subprocess.Popen(["git", "rev-parse", "--git-dir"], bufsize=1, stdout=subprocess.PIPE).stdout + absolute_path = subprocess.Popen(["git", "rev-parse", "--git-dir"], stdout=subprocess.PIPE).stdout else: - absolute_path = subprocess.Popen(["git", "rev-parse", "--show-toplevel"], bufsize=1, + absolute_path = subprocess.Popen(["git", "rev-parse", "--show-toplevel"], stdout=subprocess.PIPE).stdout absolute_path = absolute_path.readlines() diff --git a/gitinspector/blame.py b/gitinspector/blame.py index f1a9c66..5286463 100644 --- a/gitinspector/blame.py +++ b/gitinspector/blame.py @@ -91,7 +91,7 @@ class BlameThread(threading.Thread): __blame_lock__.release() # ...to here. def run(self): - git_blame_r = subprocess.Popen(self.blame_command, bufsize=1, stdout=subprocess.PIPE).stdout + git_blame_r = subprocess.Popen(self.blame_command, stdout=subprocess.PIPE).stdout rows = git_blame_r.readlines() git_blame_r.close() @@ -123,7 +123,7 @@ PROGRESS_TEXT = N_("Checking how many rows belong to each author (2 of 2): {0:.0 class Blame(object): def __init__(self, repo, hard, useweeks, changes): self.blames = {} - ls_tree_p = subprocess.Popen(["git", "ls-tree", "--name-only", "-r", interval.get_ref()], bufsize=1, + ls_tree_p = subprocess.Popen(["git", "ls-tree", "--name-only", "-r", interval.get_ref()], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) lines = ls_tree_p.communicate()[0].splitlines() ls_tree_p.stdout.close() diff --git a/gitinspector/changes.py b/gitinspector/changes.py index 9758a9a..2d3bff9 100644 --- a/gitinspector/changes.py +++ b/gitinspector/changes.py @@ -125,7 +125,7 @@ class ChangesThread(threading.Thread): git_log_r = subprocess.Popen([_f for _f in ["git", "log", "--reverse", "--pretty=%ct|%cd|%H|%aN|%aE", "--stat=100000,8192", "--no-merges", "-w", interval.get_since(), interval.get_until(), "--date=short"] + (["-C", "-C", "-M"] if self.hard else []) + - [self.first_hash + self.second_hash] if _f], bufsize=1, stdout=subprocess.PIPE).stdout + [self.first_hash + self.second_hash] if _f], stdout=subprocess.PIPE).stdout lines = git_log_r.readlines() git_log_r.close() @@ -186,7 +186,7 @@ class Changes(object): self.commits = [] interval.set_ref("HEAD"); git_rev_list_p = subprocess.Popen([_f for _f in ["git", "rev-list", "--reverse", "--no-merges", - interval.get_since(), interval.get_until(), "HEAD"] if _f], bufsize=1, + interval.get_since(), interval.get_until(), "HEAD"] if _f], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) lines = git_rev_list_p.communicate()[0].splitlines() git_rev_list_p.stdout.close() diff --git a/gitinspector/clone.py b/gitinspector/clone.py index 18fe8c6..d1d52cb 100644 --- a/gitinspector/clone.py +++ b/gitinspector/clone.py @@ -42,7 +42,7 @@ def create(url): if parsed_url.scheme == "file" or parsed_url.scheme == "git" or parsed_url.scheme == "http" or \ parsed_url.scheme == "https" or parsed_url.scheme == "ssh": path = tempfile.mkdtemp(suffix=".gitinspector") - git_clone = subprocess.Popen(["git", "clone", url, path], bufsize=1, stdout=sys.stderr) + git_clone = subprocess.Popen(["git", "clone", url, path], stdout=sys.stderr) git_clone.wait() if git_clone.returncode != 0: diff --git a/gitinspector/config.py b/gitinspector/config.py index 0d90263..ea23489 100644 --- a/gitinspector/config.py +++ b/gitinspector/config.py @@ -32,7 +32,7 @@ class GitConfig(object): previous_directory = os.getcwd() os.chdir(self.repo) setting = subprocess.Popen([_f for _f in ["git", "config", "--global" if self.global_only else "", - "inspector." + variable] if _f], bufsize=1, stdout=subprocess.PIPE).stdout + "inspector." + variable] if _f], stdout=subprocess.PIPE).stdout os.chdir(previous_directory) try: diff --git a/gitinspector/filtering.py b/gitinspector/filtering.py index 570768a..5fc65ed 100644 --- a/gitinspector/filtering.py +++ b/gitinspector/filtering.py @@ -58,7 +58,7 @@ def has_filtered(): return False def __find_commit_message__(sha): - git_show_r = subprocess.Popen([_f for _f in ["git", "show", "-s", "--pretty=%B", "-w", sha] if _f], bufsize=1, + git_show_r = subprocess.Popen([_f for _f in ["git", "show", "-s", "--pretty=%B", "-w", sha] if _f], stdout=subprocess.PIPE).stdout commit_message = git_show_r.read() diff --git a/gitinspector/localization.py b/gitinspector/localization.py index 2c4a095..33d256c 100644 --- a/gitinspector/localization.py +++ b/gitinspector/localization.py @@ -68,7 +68,7 @@ def init(): __enabled__ = True __installed__ = True - __translation__.install(True) + __translation__.install() def check_compatibility(version): if isinstance(__translation__, gettext.GNUTranslations): @@ -103,4 +103,4 @@ def disable(): __enabled__ = False if __installed__: - gettext.NullTranslations().install(True) + gettext.NullTranslations().install() diff --git a/gitinspector/metrics.py b/gitinspector/metrics.py index 19037c2..dd46023 100644 --- a/gitinspector/metrics.py +++ b/gitinspector/metrics.py @@ -44,7 +44,7 @@ class MetricsLogic(object): self.cyclomatic_complexity = {} self.cyclomatic_complexity_density = {} - ls_tree_p = subprocess.Popen(["git", "ls-tree", "--name-only", "-r", interval.get_ref()], bufsize=1, + ls_tree_p = subprocess.Popen(["git", "ls-tree", "--name-only", "-r", interval.get_ref()], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) lines = ls_tree_p.communicate()[0].splitlines() ls_tree_p.stdout.close() @@ -57,7 +57,7 @@ class MetricsLogic(object): if FileDiff.is_valid_extension(i) and not filtering.set_filtered(FileDiff.get_filename(i)): file_r = subprocess.Popen(["git", "show", interval.get_ref() + ":{0}".format(i.strip())], - bufsize=1, stdout=subprocess.PIPE).stdout.readlines() + stdout=subprocess.PIPE).stdout.readlines() extension = FileDiff.get_extension(i) lines = MetricsLogic.get_eloc(file_r, extension)