Skip to content

Timer and AdaptiveETA, possibly other time widgets print incorrect output when used with format kwarg #271

@FinnE145

Description

@FinnE145

Description

Using formatting with Timer(), AdaptiveETA(), and possibly other time widgets causes all formatting to stop working, and instead print this to the terminal over and over again, followed by the marker given.

Time:  0:00:05Time passed: {'max_value': 100, 'start_time': datetime.datetime(2022, 8, 28, 22, 9, 45, 398765), 'last_update_time': datetime.datetime(2022, 8, 28, 22, 9, 51, 243406), 'end_time': datetime.datetime(2022, 8, 28, 22, 9, 51, 243406), 'value': 100, 'previous_value': 6, 'updates': 7, 'total_seconds_elapsed': 5.844641, 'seconds_elapsed': 5.844641, 'minutes_elapsed': 0.08333333333333333, 'hours_elapsed': 0.001388888888888889, 'days_elapsed': 5.787037037037037e-05, 'time_elapsed': datetime.timedelta(seconds=5, microseconds=844641), 'percentage': 100.0, 'variables': {}, 'dynamic_messages': {}, 'eta_seconds': 0.0, 'eta': None, 'finished': datetime.datetime(2022, 8, 28, 22, 9, 51, 243406), 'last_update': datetime.datetime(2022, 8, 28, 22, 9, 51, 243406), 'max': 100, 'seconds': 5.844641, 'start': datetime.datetime(2022, 8, 28, 22, 9, 45, 398765), 'elapsed': '0:00:05'}||

Using the widgets without a format specified as an argument works as expected. For example, the code below works as normal.

import progressbar as pb
import time

widgets = [
    pb.AdaptiveETA(),
    pb.Timer(),
    pb.Bar()
]

progBar = pb.ProgressBar(widgets=widgets, max_value=100).start()

for i in range(1, 101):
    progBar.update(i)
    time.sleep(0.1)

...But the code below prints the output shown above.

import progressbar as pb
import time

widgets = [
    pb.AdaptiveETA(format="Time left: %s"),
    pb.Timer(),
    pb.Bar()
]

progBar = pb.ProgressBar(widgets=widgets, max_value=100).start()

for i in range(1, 101):
    progBar.update(i)
    time.sleep(0.1)

This issue only started happening when I used pip install progressbar2. Before I had only used pip install progressbar, and everything worked as expected.

Code

See above.

As mentioned, this code reproduces the issue:

import progressbar as pb
import time

widgets = [
    pb.AdaptiveETA(format="Time left: %s"),
    pb.Timer(format="Time passed: %s"),
    pb.Bar()
]

progBar = pb.ProgressBar(widgets=widgets, max_value=100).start()

for i in range(1, 101):
    progBar.update(i)
    time.sleep(0.1)

Versions

  • Python version: 3.10.6 (tags/v3.10.6:9c7b4bd, Aug 1 2022, 21:53:49) [MSC v.1932 64 bit (AMD64)]
  • Python distribution/environment: Python 3.10 running in a powershell terminal.
  • Operating System: Windows 11
  • Package version: 4.0.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions