Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions bdsf/statusbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ def __init__(self, text, pos=0, max=100, color='\033[0m'):

# find number of columns in terminal
def __getsize(self):
tsize = shutil.get_terminal_size(fallback=(0, 0))
columns = tsize.columns
columns = shutil.get_terminal_size().columns

if int(columns) > self.max + 2 + 44 + (len(str(self.max))*2 + 2):
self.columns = self.max
Expand All @@ -54,7 +53,7 @@ def __print(self):
# Update terminal size with each frame rendering
self.__getsize()

sys.stdout.write('\x1b[1G')
sys.stdout.write('\r')

# Handle the case where there are no items to process (prevents from
# dividing by zero later)
Expand All @@ -66,7 +65,6 @@ def __print(self):
# so the progress bar adapts to possible window resizing.
self.comp = int(float(self.pos) / self.max * self.columns)
sys.stdout.write(self.color + self.text + '[' + '=' * self.comp + self.busy_char + '-'*(self.columns - self.comp - 1) + '] ' + str(self.pos) + '/' + str(self.max) + '\033[0m')
sys.stdout.write('\x1b[' + str(self.comp + 2 + 44) + 'G')
Comment thread
gmloose marked this conversation as resolved.
sys.stdout.flush()
return

Expand Down