You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi folks, I have this piece of code here where I would like to have only the print statement at the end in the stdout and not the live display with its progress bars.
That way if I assign my command in a bash or powershell terminal, I wont end up with that information in the output since I only need the link that will be printed at the end.
I tried with contextlib to redirect, it does work when I do it with None but then I cannot see the progress anymore at all and with stderr it keeps printing the progress on a new line at every update, basically messing with rich Live() dynamics which beats the whole purpose.
The goal here is to display both the progress and resulting links in the terminal after uploading the images but without having the progress in any output should I redirect that a text file or variable using another shell.
Any help will be appreciated, thanks again.
progress_bar = Progress(
TextColumn("[progress.percentage]{task.percentage:>3.0f}%"),
BarColumn(),
MofNCompleteColumn(),
auto_refresh=False
)
description_progress = Progress(
TextColumn("file: {task.fields[extra]}"),
auto_refresh=False
)
panel = Panel(Group(description_progress, progress_bar), title="Uploading")
fname = ''
with Live(panel):
task1 = progress_bar.add_task('Task 1', total=total)
task2 = description_progress.add_task('Task 2', total=total, extra=fname)
for pic in pics:
fname = os.path.basename(pic)
try:
links = upload_pics(pic)
except requests.exceptions.RequestException:
break
if pic == pics[0]:
sep: str = ''
elif not args.single:
sep = '\n'
for f in args.format:
match f:
case 'b':
bbcode_links += (sep + links[0].get('value'))
case 'd':
direct_links += (sep + links[1].get('value'))
case 'h':
bbthumbs_links += (sep + links[2].get('value'))
case 'i':
imgnm_links += (sep + '[imgnm]' + links[1].get('value') + '[imgnm]')
case 't':
thumbs_links += (sep + links[3].get('value'))
progress_bar.update(task1, advance=1, refresh=True)
description_progress.update(task2, advance=1, refresh=True, extra=fname)
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi folks, I have this piece of code here where I would like to have only the print statement at the end in the stdout and not the live display with its progress bars.
That way if I assign my command in a bash or powershell terminal, I wont end up with that information in the output since I only need the link that will be printed at the end.
I tried with contextlib to redirect, it does work when I do it with None but then I cannot see the progress anymore at all and with stderr it keeps printing the progress on a new line at every update, basically messing with rich Live() dynamics which beats the whole purpose.
The goal here is to display both the progress and resulting links in the terminal after uploading the images but without having the progress in any output should I redirect that a text file or variable using another shell.
Any help will be appreciated, thanks again.
Beta Was this translation helpful? Give feedback.
All reactions