Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
FSL
conda
installer
Commits
0f83f45b
Commit
0f83f45b
authored
Jul 01, 2021
by
Paul McCarthy
🚵
Browse files
RF: Handle overflow in progress bar
parent
fd78c0a5
Changes
1
Show whitespace changes
Inline
Side-by-side
fslinstaller.py
View file @
0f83f45b
...
...
@@ -543,24 +543,33 @@ class Progress(object):
def
progress
(
self
,
value
,
total
):
fvalue
=
self
.
fmt
(
value
)
ftotal
=
self
.
fmt
(
total
)
suffix
=
'{} / {} {}'
.
format
(
fvalue
,
ftotal
,
self
.
label
).
rstrip
()
overflow
=
value
>
total
value
=
min
(
value
,
total
)
# arbitrary fallback of 50 columns if
# terminal width cannot be determined
if
self
.
width
is
None
:
width
=
Progress
.
get_terminal_width
(
50
)
else
:
width
=
self
.
width
width
=
width
-
(
len
(
suffix
)
+
3
)
fvalue
=
self
.
fmt
(
value
)
ftotal
=
self
.
fmt
(
total
)
suffix
=
'{} / {} {}'
.
format
(
fvalue
,
ftotal
,
self
.
label
).
rstrip
()
# +5: - square brackets around bar
# - space between bar and tally
# - space+spin in case of overflow
width
=
width
-
(
len
(
suffix
)
+
5
)
completed
=
int
(
round
(
width
*
(
value
/
total
)))
remaining
=
width
-
completed
line
=
'[{}{}] {}'
.
format
(
'#'
*
completed
,
progress
=
'[{}{}] {}'
.
format
(
'#'
*
completed
,
' '
*
remaining
,
suffix
)
printmsg
(
line
,
end
=
'
\r
'
)
printmsg
(
progress
,
end
=
''
)
if
overflow
:
printmsg
(
' '
,
end
=
''
)
self
.
spin
()
printmsg
(
end
=
'
\r
'
)
@
staticmethod
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment