Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Ecs bugfix #2103

Closed
wants to merge 2 commits into from

3 participants

@DempDemp

Previous commit 39a997f broke the code. Both classes inherit from old-style classes, so can't use super. I reverted the calls back to old-style calls.
Added error handling and an item_lookup method.

@toastdriven

Sorry about that. Thanks!

@toastdriven toastdriven removed their assignment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 26 additions and 5 deletions.
  1. +13 −1 boto/ecs/__init__.py
  2. +13 −4 boto/ecs/item.py
View
14 boto/ecs/__init__.py
@@ -21,6 +21,7 @@
import boto
from boto.connection import AWSQueryConnection, AWSAuthConnection
+from boto.exception import BotoServerError
import time
import urllib
import xml.sax
@@ -67,7 +68,7 @@ def get_response(self, action, params, page=0, itemSet=None):
if response.status != 200:
boto.log.error('%s %s' % (response.status, response.reason))
boto.log.error('%s' % body)
- raise self.ResponseError(response.status, response.reason, body)
+ raise BotoServerError(response.status, response.reason, body)
if itemSet is None:
rs = ItemSet(self, action, params, page)
@@ -75,6 +76,8 @@ def get_response(self, action, params, page=0, itemSet=None):
rs = itemSet
h = handler.XmlHandler(rs, self)
xml.sax.parseString(body, h)
+ if not rs.is_valid:
+ raise BotoServerError(response.status, '{Code}: {Message}'.format(**rs.errors[0]))
return rs
#
@@ -91,3 +94,12 @@ def item_search(self, search_index, **params):
"""
params['SearchIndex'] = search_index
return self.get_response('ItemSearch', params)
+
+ def item_lookup(self, **params):
+ """
+ Returns items that satisfy the lookup query.
+
+ For a full list of parameters, see:
+ http://s3.amazonaws.com/awsdocs/Associates/2011-08-01/prod-adv-api-dg-2011-08-01.pdf
+ """
+ return self.get_response('ItemLookup', params)
View
17 boto/ecs/item.py
@@ -90,14 +90,14 @@ class Item(ResponseGroup):
def __init__(self, connection=None):
"""Initialize this Item"""
- super(Item, self).__init__(connection, "Item")
+ ResponseGroup.__init__(self, connection, "Item")
class ItemSet(ResponseGroup):
"""A special ResponseGroup that has built-in paging, and
only creates new Items on the "Item" tag"""
def __init__(self, connection, action, params, page=0):
- super(ItemSet, self).__init__(connection, "Items")
+ ResponseGroup.__init__(self, connection, "Items")
self.objs = []
self.iter = None
self.page = page
@@ -106,6 +106,8 @@ def __init__(self, connection, action, params, page=0):
self.curItem = None
self.total_results = 0
self.total_pages = 0
+ self.is_valid = False
+ self.errors = []
def startElement(self, name, attrs, connection):
if name == "Item":
@@ -119,7 +121,14 @@ def endElement(self, name, value, connection):
self.total_results = value
elif name == 'TotalPages':
self.total_pages = value
- elif name == "Item":
+ elif name == 'IsValid':
+ if value == 'True':
+ self.is_valid = True
+ elif name == 'Code':
+ self.errors.append({'Code': value, 'Message': None})
+ elif name == 'Message':
+ self.errors[-1]['Message'] = value
+ elif name == 'Item':
self.objs.append(self.curItem)
self._xml.write(self.curItem.to_xml())
self.curItem = None
@@ -150,4 +159,4 @@ def to_xml(self):
"""Override to first fetch everything"""
for item in self:
pass
- return super(ItemSet, self).to_xml()
+ return ResponseGroup.to_xml(self)
Something went wrong with that request. Please try again.