NiltonVolpato / python-progressbar

Text progress bar library for Python
Other
412 stars 105 forks source link

How to use adaptiveETA when execution time is unknown? #37

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Hi Guys,

I'm running AWS SDK and call API to create instance. The finish time is unknown 
operation, how can I adjust progressbar to accomodate this?

as soon as progress bar reaches the highest value - it crashes with the 
following code:

Traceback (most recent call last):
  File "D:/Projects/devops/development/experiments-elasticbeanstalk.py", line 124, in <module>
    pbar.update(difference)
  File "C:\Programming\Python275\lib\site-packages\progressbar\progressbar.py", line 252, in update
    raise ValueError('Value out of range')
ValueError: Value out of range

my code:
print "Waiting for prod-web-env to launch | " + status
pbar.start()
while status <> "Green":
    ret = conn.describe_environments(application_name='Web', environment_ids=eid)
    status = ret['DescribeEnvironmentsResponse']['DescribeEnvironmentsResult']['Environments'][0]['Health']
    time.sleep(5)
    later = time.time()
    difference = int(later - now)
    pbar.update(difference)
    # I tried this solution to adjust maxval dynamically and increase it to 10% each time we hit 90% of progress - but that didn't work
    if int((difference/pbar.maxval)*100)>90:
        pbar.maxval = pbar.maxval + int(pbar.maxval*0.1)
    if status=="Terminated":
        break

pbar.finish()
if status=="Terminated":
    print "Major problem running the environment"
    exit(1)

Original issue reported on code.google.com by dmi...@saritasa.com on 2 May 2014 at 11:51