Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

went through new modified example posted, call to get_events only returns one object #19

Closed
github-golinux opened this issue Dec 22, 2013 · 4 comments

Comments

@github-golinux
Copy link

[crazybill@centos-xx home]# python2.6 new-code.py
Gonna check status in about 10 seconds
Number of events returned by call to droplet.get_events()
1
73

I modified the code to sleep for 10 seconds before calling:
events = droplet.get_events()

I then print the # of events returned on the get_events() call
and print the percentage.

Gonna look deeper to make sure this is not a weird dependency on python build.
Cheers mate.

@koalalorenzo
Copy link
Owner

Can you explain better what kind of issue you have?
the get_events should return a list of events. I don't understand the problem!

LMK 👍

@github-golinux
Copy link
Author

Hey Thank you for looking into this, yes my issue is the following, when I execute this piece of code:

#Checking the status of the droplet

events = droplet.get_events()

for event in events:
event.load()
#Once it shows 100, droplet is up and running
print event.percentage

**** END CODE

This for loop only executes one time since there is only one event in the list. So the percentage never gets to 100, since it never iterates through any other events. I also checked by calling a sleep function and then calling status and that never changes to active either.

@koalalorenzo
Copy link
Owner

You should do something like this:

events = droplet.get_events()
for event in events:
    while True:
        time.sleep(1)
        event.load()
        if 100 in event.percentage:
            print event.percentage
            break

In that way you should be able to wait until the event is complete.

@github-golinux
Copy link
Author

Ok, that worked after I modified this line by the following:

if '100' in event.percentage:

Great. Thank you for all of the hints, I learned a little more about python, debugging and installing modules.
Many Thanks Lorenzo. Happy Holidays

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants