diff --git a/progress.py b/progress.py index f9ac53a1..526ce6c1 100644 --- a/progress.py +++ b/progress.py @@ -15,7 +15,7 @@ import os import sys from time import time -from repo_trace import IsTrace +from repo_trace import IsTraceToStderr _NOT_TTY = not os.isatty(2) @@ -80,7 +80,7 @@ class Progress(object): def update(self, inc=1, msg=''): self._done += inc - if _NOT_TTY or IsTrace(): + if _NOT_TTY or IsTraceToStderr(): return if not self._show: @@ -113,7 +113,7 @@ class Progress(object): sys.stderr.flush() def end(self): - if _NOT_TTY or IsTrace() or not self._show: + if _NOT_TTY or IsTraceToStderr() or not self._show: return duration = duration_str(time() - self._start) diff --git a/repo_trace.py b/repo_trace.py index 86cbfc62..9016cb0c 100644 --- a/repo_trace.py +++ b/repo_trace.py @@ -32,19 +32,14 @@ REPO_TRACE = 'REPO_TRACE' # Temporarily set tracing to always on unless user expicitly sets to 0. _TRACE = os.environ.get(REPO_TRACE) != '0' - _TRACE_TO_STDERR = False - _TRACE_FILE = None - _TRACE_FILE_NAME = 'TRACE_FILE' - _MAX_SIZE = 70 # in mb - _NEW_COMMAND_SEP = '+++++++++++++++NEW COMMAND+++++++++++++++++++' -def IsStraceToStderr(): +def IsTraceToStderr(): return _TRACE_TO_STDERR @@ -90,7 +85,7 @@ class Trace(ContextDecorator): if not IsTrace(): return self - print_msg = f"PID: {os.getpid()} START: {self._time()} :" + self._trace_msg + '\n' + print_msg = f'PID: {os.getpid()} START: {self._time()} :' + self._trace_msg + '\n' with open(_TRACE_FILE, 'a') as f: print(print_msg, file=f) @@ -104,7 +99,7 @@ class Trace(ContextDecorator): if not IsTrace(): return False - print_msg = f"PID: {os.getpid()} END: {self._time()} :" + self._trace_msg + '\n' + print_msg = f'PID: {os.getpid()} END: {self._time()} :' + self._trace_msg + '\n' with open(_TRACE_FILE, 'a') as f: print(print_msg, file=f)