Skip to content

Commit

Permalink
Generic bug fix and improved __check_actions_in_data method.
Browse files Browse the repository at this point in the history
  • Loading branch information
koalalorenzo committed Aug 14, 2014
1 parent d023bea commit aab9c80
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions digitalocean/Droplet.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,13 @@ def __init__(self, *args, **kwargs):
super(Droplet, self).__init__(*args, **kwargs)

def __check_actions_in_data(self, data):
try:
action_id = data['droplet']['action_ids'][0]
except KeyError: # Some actions return a list of action items.
action_id = data['action']['id']
# Prepend the action id to the begining to be consistent with the API.
self.action_ids.insert(0, action_id)
# reloading actions if actions is provided.
if data.has_key(u"actions"):
self.action_ids = []
for action in data[u'actions']:
self.action_ids.append(action[u'id'])

def get_data(*args, **kwargs):
def get_data(self, *args, **kwargs):
"""
Customized version of get_data to perform __check_actions_in_data
"""
Expand Down Expand Up @@ -293,7 +292,7 @@ def get_snapshots(self):
specific droplet.
"""
snapshots = list()
for id in droplet.snapshot_ids:
for id in self.snapshot_ids:
snapshot = Image()
snapshot.id = id
snapshot.token = self.token
Expand Down

0 comments on commit aab9c80

Please sign in to comment.