def __init__(self,
              aws_access_key_id=None,
              aws_secret_access_key=None,
              is_secure=True,
              port=None,
              proxy=None,
              proxy_port=None,
              proxy_user=None,
              proxy_pass=None,
              debug=0,
              https_connection_factory=None,
              region=None,
              path='/',
              converter=None):
     if not region:
         region = SDBRegionInfo(self, self.DefaultRegionName,
                                self.DefaultRegionEndpoint)
     self.region = region
     AWSQueryConnection.__init__(self, aws_access_key_id,
                                 aws_secret_access_key, is_secure, port,
                                 proxy, proxy_port, proxy_user, proxy_pass,
                                 self.region.endpoint, debug,
                                 https_connection_factory, path)
     self.box_usage = 0.0
     self.converter = converter
     self.item_cls = Item
Beispiel #2
0
 def __init__(self, aws_access_key_id=None, aws_secret_access_key=None,
              is_secure=True, port=None, proxy=None, proxy_port=None,
              proxy_user=None, proxy_pass=None, host='ecs.amazonaws.com',
              debug=0, https_connection_factory=None, path='/'):
     AWSQueryConnection.__init__(self, aws_access_key_id, aws_secret_access_key,
                                 is_secure, port, proxy, proxy_port, proxy_user, proxy_pass,
                                 host, debug, https_connection_factory, path)
Beispiel #3
0
 def __init__(self, aws_access_key_id=None, aws_secret_access_key=None,
              is_secure=True, host=None, port=None,
              proxy=None, proxy_port=None,
              proxy_user=None, proxy_pass=None, debug=0,
              https_connection_factory=None, region=None, path='/',
              api_version=None, security_token=None,
              validate_certs=True, profile_name=None):
     if not region:
         region = RegionInfo(self, self.DefaultRegionName,
                             self.DefaultRegionEndpoint)
     self.region = region
     AWSQueryConnection.__init__(
         self,
         host=self.region.endpoint,
         aws_access_key_id=aws_access_key_id,
         aws_secret_access_key=aws_secret_access_key,
         is_secure=is_secure,
         port=port,
         proxy=proxy,
         proxy_port=proxy_port,
         proxy_user=proxy_user,
         proxy_pass=proxy_pass,
         debug=debug,
         https_connection_factory=https_connection_factory,
         path=path,
         security_token=security_token,
         validate_certs=validate_certs,
         profile_name=profile_name)
Beispiel #4
0
    def __init__(self,
                 aws_access_key_id=None,
                 aws_secret_access_key=None,
                 is_secure=False,
                 port=None,
                 proxy=None,
                 proxy_port=None,
                 proxy_user=None,
                 proxy_pass=None,
                 debug=0,
                 https_connection_factory=None,
                 region=None,
                 path='/'):
        """
        Init method to create a new connection to EC2 Load Balancing Service.

        .. note:: The region argument is overridden by the region specified in
            the boto configuration file.
        """
        if not region:
            region = RegionInfo(self, self.DefaultRegionName,
                                self.DefaultRegionEndpoint)
        self.region = region
        AWSQueryConnection.__init__(self, aws_access_key_id,
                                    aws_secret_access_key, is_secure, port,
                                    proxy, proxy_port, proxy_user, proxy_pass,
                                    self.region.endpoint, debug,
                                    https_connection_factory, path)
Beispiel #5
0
 def __init__(self, aws_access_key_id=None, aws_secret_access_key=None,
              is_secure=True, host=None, port=None,
              proxy=None, proxy_port=None,
              proxy_user=None, proxy_pass=None, debug=0,
              https_connection_factory=None, region=None, path='/',
              api_version=None, security_token=None,
              validate_certs=True, profile_name=None):
     if not region:
         region = RegionInfo(self, self.DefaultRegionName,
                             self.DefaultRegionEndpoint)
     self.region = region
     AWSQueryConnection.__init__(
         self,
         host=self.region.endpoint,
         aws_access_key_id=aws_access_key_id,
         aws_secret_access_key=aws_secret_access_key,
         is_secure=is_secure,
         port=port,
         proxy=proxy,
         proxy_port=proxy_port,
         proxy_user=proxy_user,
         proxy_pass=proxy_pass,
         debug=debug,
         https_connection_factory=https_connection_factory,
         path=path,
         security_token=security_token,
         validate_certs=validate_certs,
         profile_name=profile_name)
Beispiel #6
0
 def __init__(
     self,
     aws_access_key_id=None,
     aws_secret_access_key=None,
     is_secure=True,
     port=None,
     proxy=None,
     proxy_port=None,
     proxy_user=None,
     proxy_pass=None,
     host="iam.amazonaws.com",
     debug=0,
     https_connection_factory=None,
     path="/",
     security_token=None,
 ):
     AWSQueryConnection.__init__(
         self,
         aws_access_key_id,
         aws_secret_access_key,
         is_secure,
         port,
         proxy,
         proxy_port,
         proxy_user,
         proxy_pass,
         host,
         debug,
         https_connection_factory,
         path,
         security_token,
     )
Beispiel #7
0
 def __init__(
     self,
     aws_access_key_id=None,
     aws_secret_access_key=None,
     is_secure=True,
     port=None,
     proxy=None,
     proxy_port=None,
     proxy_user=None,
     proxy_pass=None,
     debug=0,
     https_connection_factory=None,
     region=None,
     path="/",
 ):
     if not region:
         region = RDSRegionInfo(self, self.DefaultRegionName, self.DefaultRegionEndpoint)
     self.region = region
     AWSQueryConnection.__init__(
         self,
         aws_access_key_id,
         aws_secret_access_key,
         is_secure,
         port,
         proxy,
         proxy_port,
         proxy_user,
         proxy_pass,
         self.region.endpoint,
         debug,
         https_connection_factory,
         path,
     )
Beispiel #8
0
 def __init__(self, aws_access_key_id=None, aws_secret_access_key=None,
              is_secure=True, port=None, proxy=None, proxy_port=None,
              proxy_user=None, proxy_pass=None, debug=0,
              https_connection_factory=None, region=None, path='/',
              security_token=None, validate_certs=True):
     if not region:
         region = RegionInfo(self, self.DefaultRegionName,
                             self.DefaultRegionEndpoint)
     self.region = region
     AWSQueryConnection.__init__(self, aws_access_key_id,
                                 aws_secret_access_key,
                                 is_secure, port, proxy, proxy_port,
                                 proxy_user, proxy_pass,
                                 self.region.endpoint, debug,
                                 https_connection_factory, path,
                                 security_token,
                                 validate_certs=validate_certs)
     # Many of the EMR hostnames are of the form:
     #     <region>.<service_name>.amazonaws.com
     # rather than the more common:
     #     <service_name>.<region>.amazonaws.com
     # so we need to explicitly set the region_name and service_name
     # for the SigV4 signing.
     self.auth_region_name = self.region.name
     self.auth_service_name = 'elasticmapreduce'
Beispiel #9
0
    def __init__(self,
                 aws_access_key_id=None,
                 aws_secret_access_key=None,
                 is_secure=True,
                 port=None,
                 proxy=None,
                 proxy_port=None,
                 proxy_user=None,
                 proxy_pass=None,
                 host=Endpoint,
                 debug=1,
                 https_connection_factory=None,
                 region=None,
                 path='/'):
        """
        Init method to create a new connection to the AutoScaling service.

        B{Note:} The host argument is overridden by the host specified in the
                 boto configuration file.
        """
        AWSQueryConnection.__init__(self,
                                    aws_access_key_id,
                                    aws_secret_access_key,
                                    is_secure,
                                    port,
                                    proxy,
                                    proxy_port,
                                    proxy_user,
                                    proxy_pass,
                                    host,
                                    debug,
                                    https_connection_factory,
                                    path=path)
Beispiel #10
0
 def __init__(self, **kwargs):
     region = kwargs.pop("region", None)
     if not region:
         region = RegionInfo(self, self.DefaultRegionName, self.DefaultRegionEndpoint)
     kwargs["host"] = region.endpoint
     AWSQueryConnection.__init__(self, **kwargs)
     self.region = region
Beispiel #11
0
    def __init__(self, aws_access_key_id=None, aws_secret_access_key=None, aws_sudo_id=None,
                 is_secure=True, port=None, proxy=None, proxy_port=None,
                 proxy_user=None, proxy_pass=None, debug=0,
                 https_connection_factory=None, region=None, path='/',
                 security_token=None, validate_certs=True):
        """
        Init method to create a new connection to EC2 Monitoring Service.

        B{Note:} The host argument is overridden by the host specified in the
        boto configuration file.
        """
        if not region:
            region = RegionInfo(self, self.DefaultRegionName,
                                self.DefaultRegionEndpoint)
        self.region = region

        # Ugly hack to get around both a bug in Python and a
        # misconfigured SSL cert for the eu-west-1 endpoint
        if self.region.name == 'eu-west-1':
            validate_certs = False

        AWSQueryConnection.__init__(self, aws_access_key_id,
                                    aws_secret_access_key,
                                    is_secure, port, proxy, proxy_port,
                                    proxy_user, proxy_pass,
                                    self.region.endpoint, debug,
                                    https_connection_factory, path,
                                    security_token,
                                    validate_certs=validate_certs)
        self.aws_sudo_id = aws_sudo_id
Beispiel #12
0
 def __init__(self, aws_access_key_id=None, aws_secret_access_key=None,
              is_secure=False, port=None, proxy=None, proxy_port=None,
              proxy_user=None, proxy_pass=None, host='mechanicalturk.amazonaws.com', debug=0,
              https_connection_factory=None):
     AWSQueryConnection.__init__(self, aws_access_key_id, aws_secret_access_key,
                                 is_secure, port, proxy, proxy_port, proxy_user, proxy_pass,
                                 host, debug, https_connection_factory)
Beispiel #13
0
 def __init__(self,
              aws_access_key_id=None,
              aws_secret_access_key=None,
              is_secure=True,
              port=None,
              proxy=None,
              proxy_port=None,
              proxy_user=None,
              proxy_pass=None,
              debug=0,
              https_connection_factory=None,
              region=None,
              path='/',
              converter=None):
     if not region:
         region = RegionInfo(self,
                             self.DefaultRegionName,
                             self.DefaultRegionEndpoint,
                             connection_cls=STSConnection)
     self.region = region
     self._mutex = threading.Semaphore()
     AWSQueryConnection.__init__(self, aws_access_key_id,
                                 aws_secret_access_key, is_secure, port,
                                 proxy, proxy_port, proxy_user, proxy_pass,
                                 self.region.endpoint, debug,
                                 https_connection_factory, path)
 def __init__(self,
              aws_access_key_id=None,
              aws_secret_access_key=None,
              is_secure=True,
              host=None,
              port=None,
              proxy=None,
              proxy_port=None,
              proxy_user=None,
              proxy_pass=None,
              debug=0,
              https_connection_factory=None,
              region=None,
              path='/',
              api_version=None,
              security_token=None,
              validate_certs=True):
     self.region = region
     AWSQueryConnection.__init__(self,
                                 aws_access_key_id,
                                 aws_secret_access_key,
                                 is_secure,
                                 port,
                                 proxy,
                                 proxy_port,
                                 proxy_user,
                                 proxy_pass,
                                 self.region.endpoint,
                                 debug,
                                 https_connection_factory,
                                 path,
                                 security_token,
                                 validate_certs=validate_certs)
Beispiel #15
0
class TestListParamsSerialization(unittest.TestCase):
    maxDiff = None

    def setUp(self):
        self.connection = AWSQueryConnection('access_key', 'secret_key')

    def test_complex_list_serialization(self):
        # This example is taken from the doc string of
        # build_complex_list_params.
        params = {}
        self.connection.build_complex_list_params(params,
                                                  [('foo', 'bar', 'baz'),
                                                   ('foo2', 'bar2', 'baz2')],
                                                  'ParamName.member',
                                                  ('One', 'Two', 'Three'))
        self.assertDictEqual(
            {
                'ParamName.member.1.One': 'foo',
                'ParamName.member.1.Two': 'bar',
                'ParamName.member.1.Three': 'baz',
                'ParamName.member.2.One': 'foo2',
                'ParamName.member.2.Two': 'bar2',
                'ParamName.member.2.Three': 'baz2',
            }, params)

    def test_simple_list_serialization(self):
        params = {}
        self.connection.build_list_params(params, ['foo', 'bar', 'baz'],
                                          'ParamName.member')
        self.assertDictEqual(
            {
                'ParamName.member.1': 'foo',
                'ParamName.member.2': 'bar',
                'ParamName.member.3': 'baz',
            }, params)
Beispiel #16
0
    def __init__(self, aws_access_key_id=None, aws_secret_access_key=None, aws_sudo_id=None,
                 is_secure=True, port=None, proxy=None, proxy_port=None,
                 proxy_user=None, proxy_pass=None, debug=0,
                 https_connection_factory=None, region=None, path='/',
                 security_token=None, validate_certs=True):
        """
        Init method to create a new connection to EC2 Monitoring Service.

        B{Note:} The host argument is overridden by the host specified in the
        boto configuration file.
        """
        if not region:
            region = RegionInfo(self, self.DefaultRegionName,
                                self.DefaultRegionEndpoint)
        self.region = region

        # Ugly hack to get around both a bug in Python and a
        # misconfigured SSL cert for the eu-west-1 endpoint
        if self.region.name == 'eu-west-1':
            validate_certs = False

        AWSQueryConnection.__init__(self, aws_access_key_id,
                                    aws_secret_access_key,
                                    is_secure, port, proxy, proxy_port,
                                    proxy_user, proxy_pass,
                                    self.region.endpoint, debug,
                                    https_connection_factory, path,
                                    security_token,
                                    validate_certs=validate_certs)
        self.aws_sudo_id = aws_sudo_id
    def method(self, operation, **kwargs):
        aws_conn = AWSQueryConnection(
            aws_access_key_id=self.aws_access_key_id,
            aws_secret_access_key=self.aws_secret_access_key, is_secure=False,
            host='ecs.amazonaws.com')

        aws_conn.SignatureVersion = '2'
        kwargs.update(dict(
            Service='AWSECommerceService',
            Version=Parser.version,
            SignatureVersion=aws_conn.SignatureVersion,
            AWSAccessKeyId=self.aws_access_key_id,
            AssociateTag=self.aws_associate_tag,
            Timestamp=time.strftime("%Y-%m-%dT%H:%M:%S", time.gmtime()),
            Operation=operation,
        ))
        verb = 'GET'
        path = '/onca/xml'
        qs, signature = aws_conn.get_signature(kwargs, verb, path)
        qs = path + '?' + qs + '&Signature=' + urllib.quote(signature)

        xml_response = StringIO(aws_conn._mexe(verb, qs, None, headers={
            'User-Agent': 'AWSECommerceClient.py',
        }).read())

        try:
            return Parser.parse_file(xml_response)
        except:
            # Log the original response and the exception.
            log.error("Error parsing response:\n"+xml_response.getvalue())
            raise
Beispiel #18
0
    def __init__(
        self,
        aws_access_key_id=None,
        aws_secret_access_key=None,
        is_secure=True,
        port=None,
        proxy=None,
        proxy_port=None,
        proxy_user=None,
        proxy_pass=None,
        host=None,
        debug=0,
        https_connection_factory=None,
    ):
        if not host:
            if config.has_option("MTurk", "sandbox") and config.get("MTurk", "sandbox") == "True":
                host = "mechanicalturk.sandbox.amazonaws.com"
            else:
                host = "mechanicalturk.amazonaws.com"

        AWSQueryConnection.__init__(
            self,
            aws_access_key_id,
            aws_secret_access_key,
            is_secure,
            port,
            proxy,
            proxy_port,
            proxy_user,
            proxy_pass,
            host,
            debug,
            https_connection_factory,
        )
Beispiel #19
0
 def __init__(self, aws_access_key_id=None, aws_secret_access_key=None,
              is_secure=True, port=None, proxy=None, proxy_port=None,
              proxy_user=None, proxy_pass=None, debug=0,
              https_connection_factory=None, region=None, path='/',
              converter=None):
     """
     For any keywords that aren't documented, refer to the parent class,
     :py:class:`boto.connection.AWSAuthConnection`. You can avoid having
     to worry about these keyword arguments by instantiating these objects
     via :py:func:`boto.connect_sdb`.
 
     :type region: :class:`boto.sdb.regioninfo.SDBRegionInfo`
     :keyword region: Explicitly specify a region. Defaults to ``us-east-1`` 
         if not specified.
     """
     if not region:
         region = SDBRegionInfo(self, self.DefaultRegionName,
                                self.DefaultRegionEndpoint)
     self.region = region
     AWSQueryConnection.__init__(self, aws_access_key_id,
                                 aws_secret_access_key,
                                 is_secure, port, proxy,
                                 proxy_port, proxy_user, proxy_pass,
                                 self.region.endpoint, debug,
                                 https_connection_factory, path)
     self.box_usage = 0.0
     self.converter = converter
     self.item_cls = Item
Beispiel #20
0
 def __init__(self, aws_access_key_id=None, aws_secret_access_key=None,
              is_secure=True, port=None, proxy=None, proxy_port=None,
              proxy_user=None, proxy_pass=None, host=DefaultHost, debug=0,
              https_connection_factory=None):
     AWSQueryConnection.__init__(self, aws_access_key_id, aws_secret_access_key,
                                 is_secure, port, proxy, proxy_port, proxy_user, proxy_pass,
                                 host, debug, https_connection_factory)
Beispiel #21
0
 def __init__(self,
              aws_access_key_id=None,
              aws_secret_access_key=None,
              is_secure=True,
              port=None,
              proxy=None,
              proxy_port=None,
              proxy_user=None,
              proxy_pass=None,
              debug=0,
              https_connection_factory=None,
              region=None,
              path='/',
              security_token=None):
     if not region:
         region = SQSRegionInfo(self, self.DefaultRegionName,
                                self.DefaultRegionEndpoint)
     self.region = region
     AWSQueryConnection.__init__(self,
                                 aws_access_key_id,
                                 aws_secret_access_key,
                                 is_secure,
                                 port,
                                 proxy,
                                 proxy_port,
                                 proxy_user,
                                 proxy_pass,
                                 self.region.endpoint,
                                 debug,
                                 https_connection_factory,
                                 path,
                                 security_token=security_token)
Beispiel #22
0
 def __init__(self,
              aws_access_key_id=None,
              aws_secret_access_key=None,
              is_secure=True,
              port=None,
              proxy=None,
              proxy_port=None,
              proxy_user=None,
              proxy_pass=None,
              host='iam.amazonaws.com',
              debug=0,
              https_connection_factory=None,
              path='/',
              security_token=None,
              validate_certs=True):
     AWSQueryConnection.__init__(self,
                                 aws_access_key_id,
                                 aws_secret_access_key,
                                 is_secure,
                                 port,
                                 proxy,
                                 proxy_port,
                                 proxy_user,
                                 proxy_pass,
                                 host,
                                 debug,
                                 https_connection_factory,
                                 path,
                                 security_token,
                                 validate_certs=validate_certs)
Beispiel #23
0
 def __init__(self, aws_access_key_id=None, aws_secret_access_key=None,
              is_secure=True, port=None, proxy=None, proxy_port=None,
              proxy_user=None, proxy_pass=None, host='ecs.amazonaws.com',
              debug=0, https_connection_factory=None, path='/'):
     AWSQueryConnection.__init__(self, aws_access_key_id, aws_secret_access_key,
                                 is_secure, port, proxy, proxy_port, proxy_user, proxy_pass,
                                 host, debug, https_connection_factory, path)
Beispiel #24
0
 def __init__(self, aws_access_key_id=None, aws_secret_access_key=None,
              is_secure=False, port=None, proxy=None, proxy_port=None,
              proxy_user=None, proxy_pass=None, host='mechanicalturk.amazonaws.com', debug=0,
              https_connection_factory=None):
     AWSQueryConnection.__init__(self, aws_access_key_id, aws_secret_access_key,
                                 is_secure, port, proxy, proxy_port, proxy_user, proxy_pass,
                                 host, debug, https_connection_factory)
Beispiel #25
0
    def amz_call(self, call_params):

        AWS_ACCESS_KEY_ID = '1PKXRTEQQV19XXDW3ZG2'
        AWS_ASSOCIATE_TAG = 'whotookmybook-20'

        import time
        from boto.connection import AWSQueryConnection
        aws_conn = AWSQueryConnection(
            aws_access_key_id=AWS_ACCESS_KEY_ID,
            aws_secret_access_key=Amz.AWS_SECRET_ACCESS_KEY, is_secure=False,
            host='ecs.amazonaws.com')
        aws_conn.SignatureVersion = '2'
        base_params = dict(
            Service='AWSECommerceService',
            Version='2008-08-19',
            SignatureVersion=aws_conn.SignatureVersion,
            AWSAccessKeyId=AWS_ACCESS_KEY_ID,
            AssociateTag=AWS_ASSOCIATE_TAG,
            Timestamp=time.strftime("%Y-%m-%dT%H:%M:%S", time.gmtime()))
        #http://stackoverflow.com/questions/38987/how-can-i-merge-two-python-dictionaries-as-a-single-expression
        params = dict(base_params, **call_params)
        verb = 'GET'
        path = '/onca/xml'
        qs, signature = aws_conn.get_signature(params, verb, path)
        qs = path + '?' + qs + '&Signature=' + urllib.quote(signature)
        return aws_conn._mexe(verb, qs, None, headers={})
Beispiel #26
0
    def __init__(self,
                 aws_access_key_id=None,
                 aws_secret_access_key=None,
                 is_secure=True,
                 port=None,
                 proxy=None,
                 proxy_port=None,
                 proxy_user=None,
                 proxy_pass=None,
                 debug=0,
                 https_connection_factory=None,
                 region=None,
                 path='/',
                 security_token=None):
        """
        Init method to create a new connection to EC2 Monitoring Service.

        B{Note:} The host argument is overridden by the host specified in the
        boto configuration file.
        """
        if not region:
            region = RegionInfo(self, self.DefaultRegionName,
                                self.DefaultRegionEndpoint)
        self.region = region

        AWSQueryConnection.__init__(self, aws_access_key_id,
                                    aws_secret_access_key, is_secure, port,
                                    proxy, proxy_port, proxy_user, proxy_pass,
                                    self.region.endpoint, debug,
                                    https_connection_factory, path,
                                    security_token)
Beispiel #27
0
class TestListParamsSerialization(unittest.TestCase):
    maxDiff = None

    def setUp(self):
        self.connection = AWSQueryConnection('access_key', 'secret_key')

    def test_complex_list_serialization(self):
        # This example is taken from the doc string of
        # build_complex_list_params.
        params = {}
        self.connection.build_complex_list_params(
            params, [('foo', 'bar', 'baz'), ('foo2', 'bar2', 'baz2')],
            'ParamName.member', ('One', 'Two', 'Three'))
        self.assertDictEqual({
            'ParamName.member.1.One': 'foo',
            'ParamName.member.1.Two': 'bar',
            'ParamName.member.1.Three': 'baz',
            'ParamName.member.2.One': 'foo2',
            'ParamName.member.2.Two': 'bar2',
            'ParamName.member.2.Three': 'baz2',
        }, params)

    def test_simple_list_serialization(self):
        params = {}
        self.connection.build_list_params(
            params, ['foo', 'bar', 'baz'], 'ParamName.member')
        self.assertDictEqual({
            'ParamName.member.1': 'foo',
            'ParamName.member.2': 'bar',
            'ParamName.member.3': 'baz',
        }, params)
Beispiel #28
0
    def __init__(self,
                 aws_access_key_id=None,
                 aws_secret_access_key=None,
                 is_secure=True,
                 port=None,
                 proxy=None,
                 proxy_port=None,
                 proxy_user=None,
                 proxy_pass=None,
                 debug=0,
                 https_connection_factory=None,
                 region=None,
                 path='/',
                 converter=None,
                 security_token=None,
                 validate_certs=True):
        """
        For any keywords that aren't documented, refer to the parent class,
        :py:class:`boto.connection.AWSAuthConnection`. You can avoid having
        to worry about these keyword arguments by instantiating these objects
        via :py:func:`boto.connect_sdb`.

        :type region: :class:`boto.sdb.regioninfo.SDBRegionInfo`
        :keyword region: Explicitly specify a region. Defaults to ``us-east-1``
            if not specified. You may also specify the region in your ``boto.cfg``:

            .. code-block:: cfg

                [SDB]
                region = eu-west-1

        """
        if not region:
            region_name = boto.config.get('SDB', 'region',
                                          self.DefaultRegionName)
            for reg in boto.sdb.regions():
                if reg.name == region_name:
                    region = reg
                    break

        self.region = region
        AWSQueryConnection.__init__(self,
                                    aws_access_key_id,
                                    aws_secret_access_key,
                                    is_secure,
                                    port,
                                    proxy,
                                    proxy_port,
                                    proxy_user,
                                    proxy_pass,
                                    self.region.endpoint,
                                    debug,
                                    https_connection_factory,
                                    path,
                                    security_token=security_token,
                                    validate_certs=validate_certs)
        self.box_usage = 0.0
        self.converter = converter
        self.item_cls = Item
Beispiel #29
0
 def __init__(self, **kwargs):
     region = kwargs.get('region')
     if not region:
         region = RegionInfo(self, self.DefaultRegionName,
                             self.DefaultRegionEndpoint)
     kwargs['host'] = region.endpoint
     AWSQueryConnection.__init__(self, **kwargs)
     self.region = region
Beispiel #30
0
 def __init__(self, **kwargs):
     region = kwargs.get('region')
     if not region:
         region = RegionInfo(self, self.DefaultRegionName,
                             self.DefaultRegionEndpoint)
     kwargs['host'] = region.endpoint
     AWSQueryConnection.__init__(self, **kwargs)
     self.region = region
Beispiel #31
0
	def __init__(self, aws_access_key_id=None, aws_secret_access_key=None,
						is_secure=True, port=None, proxy=None, proxy_port=None,
						host='fps.sandbox.amazonaws.com', debug=0,
						https_connection_factory=None):
		AWSQueryConnection.__init__(self, aws_access_key_id,
												aws_secret_access_key,
												is_secure, port, proxy, proxy_port,
												host, debug, https_connection_factory)
Beispiel #32
0
 def __init__(self, **kwargs):
     region = kwargs.pop('region', None)
     if not region:
         region = RegionInfo(self, self.DefaultRegionName,
                             self.DefaultRegionEndpoint)
     if 'host' not in kwargs:
         kwargs['host'] = region.endpoint
     AWSQueryConnection.__init__(self, **kwargs)
     self.region = region
Beispiel #33
0
 def __init__(self, aws_access_key_id=None, aws_secret_access_key=None,
              is_secure=True, port=None, proxy=None, proxy_port=None,
              proxy_user=None, proxy_pass=None, host='ec2.amazonaws.com', debug=0,
              https_connection_factory=None):
     if config.has_option('Boto', 'ec2_host'):
         host = config.get('Boto', 'ec2_host')
     AWSQueryConnection.__init__(self, aws_access_key_id, aws_secret_access_key,
                                 is_secure, port, proxy, proxy_port, proxy_user, proxy_pass,
                                 host, debug, https_connection_factory)
Beispiel #34
0
 def __init__(self, **kwargs):
     region = kwargs.pop('region', None)
     if not region:
         region = RegionInfo(self, self.DefaultRegionName,
                             self.DefaultRegionEndpoint)
     if 'host' not in kwargs:
         kwargs['host'] = region.endpoint
     AWSQueryConnection.__init__(self, **kwargs)
     self.region = region
 def __init__(self,
              aws_access_key_id=None,
              aws_secret_access_key=None,
              host=BEANSTALK_DEFAULT_HOST):
     #TODO: allow access key and id to optional, they may come in from config
     self.host = host
     AWSQueryConnection.__init__(self,
                                 aws_access_key_id,
                                 aws_secret_access_key,
                                 host=self.host)
Beispiel #36
0
 def __init__(self, aws_access_key_id=None, aws_secret_access_key=None,
              is_secure=True, port=None, proxy=None, proxy_port=None,
              proxy_user=None, proxy_pass=None,
              host='fps.sandbox.amazonaws.com', debug=0,
              https_connection_factory=None, path="/"):
     AWSQueryConnection.__init__(self, aws_access_key_id, aws_secret_access_key,
                                 is_secure, port, proxy, proxy_port,
                                 proxy_user, proxy_pass, host, debug,
                                 https_connection_factory, path)
     self.cbui_endpoint = 'authorize.payments-sandbox.amazon.com' if 'sandbox' in host else 'authorize.payments.amazon.com'
Beispiel #37
0
    def __init__(self, aws_access_key_id=None, aws_secret_access_key=None,
                 is_secure=False, port=None, proxy=None, proxy_port=None,
                 proxy_user=None, proxy_pass=None, host=Endpoint, debug=0,
                 https_connection_factory=None, path='/'):
        """
        Init method to create a new connection to EC2 Load Balancing Service.

        B{Note:} The host argument is overridden by the host specified in the boto configuration file.
        """
        AWSQueryConnection.__init__(self, aws_access_key_id, aws_secret_access_key,
                                    is_secure, port, proxy, proxy_port, proxy_user, proxy_pass,
                                    host, debug, https_connection_factory, path)
Beispiel #38
0
def get(keywords):
    aws_conn = AWSQueryConnection(
        aws_access_key_id=ACCESS_KEY_ID,
        aws_secret_access_key=SECRET_ACCESS_KEY,
        is_secure=False,
        host="ecs.amazonaws.com")
    aws_conn.SignatureVersion = "2"

    params = dict(
        Service='AWSECommerceService',
        Version='2008-08-19',
        SignatureVersion=aws_conn.SignatureVersion,
        AWSAccessKeyId=ACCESS_KEY_ID,
        AssociateTag=ASSOCIATE_TAG,
        Operation="ItemSearch",
        SearchIndex="All",
        Keywords=keywords,
        ResponseGroup="ItemAttributes",
        Timestamp=time.strftime("%Y-%m-%dT%H:%M:%S", time.gmtime()),
    )

    verb = 'GET'
    path = "/onca/xml"
    qs, signature = aws_conn.get_signature(params, verb, path)
    qs = path + '?' + qs + '&Signature=' + urllib.quote(signature)
    response = aws_conn._mexe(verb, qs, None, headers={})
    content = response.read()

    tree = ET.fromstring(content)
    NS = tree.tag.split("}")[0][1:]

    res = []
    for item in tree.find('{%s}Items' % NS).findall('{%s}Item' % NS):
        item_dic = {}
        attrs = item.find('{%s}ItemAttributes' % NS)
        if attrs is not None:
            isbn = attrs.find('{%s}ISBN' % NS)
            if isbn is not None:
                item_dic['ISBN'] = isbn.text

            title = attrs.find('{%s}Title' % NS)
            if title is not None:
                item_dic['Title'] = title.text

            author = attrs.find('{%s}Author' % NS)
            if author is not None:
                item_dic['Author'] = author.text


            if 'ISBN' in item_dic and 'Title' in item_dic:
                res.append(item_dic)
    return res
Beispiel #39
0
 def __init__(self, aws_access_key_id=None, aws_secret_access_key=None,
              is_secure=True, port=None, proxy=None, proxy_port=None,
              proxy_user=None, proxy_pass=None, debug=0,
              https_connection_factory=None, region=None, path='/', converter=None):
     if not region:
         region = SDBRegionInfo(self, self.DefaultRegionName, self.DefaultRegionEndpoint)
     self.region = region
     AWSQueryConnection.__init__(self, aws_access_key_id, aws_secret_access_key,
                                 is_secure, port, proxy, proxy_port, proxy_user, proxy_pass,
                                 self.region.endpoint, debug, https_connection_factory, path)
     self.box_usage = 0.0
     self.converter = converter
     self.item_cls = Item
Beispiel #40
0
 def __init__(self,
              aws_access_key_id=None,
              aws_secret_access_key=None,
              is_secure=False,
              port=None,
              proxy=None,
              proxy_port=None,
              host=DefaultHost,
              debug=0,
              https_connection_factory=None):
     AWSQueryConnection.__init__(self, aws_access_key_id,
                                 aws_secret_access_key, is_secure, port,
                                 proxy, proxy_port, host, debug,
                                 https_connection_factory)
Beispiel #41
0
 def __init__(self, aws_access_key_id=None, aws_secret_access_key=None,
              is_secure=True, port=None, proxy=None, proxy_port=None,
              proxy_user=None, proxy_pass=None, debug=0,
              https_connection_factory=None, region=None):
     """
     Init method to create a new connection to EC2.
     
     B{Note:} The host argument is overridden by the host specified in the boto configuration file.        
     """
     if not region:
         region = RegionInfo(self, self.DefaultRegionName, self.DefaultRegionEndpoint)
     self.region = region
     AWSQueryConnection.__init__(self, aws_access_key_id, aws_secret_access_key,
                                 is_secure, port, proxy, proxy_port, proxy_user, proxy_pass,
                                 self.region.endpoint, debug, https_connection_factory)
Beispiel #42
0
    def __init__(self, aws_access_key_id=None, aws_secret_access_key=None,
                 is_secure=False, port=None, proxy=None, proxy_port=None,
                 proxy_user=None, proxy_pass=None,
                 host=None, debug=0,
                 https_connection_factory=None):
        if not host:
            if config.has_option('MTurk', 'sandbox') and config.get('MTurk', 'sandbox') == 'True':
                host = 'mechanicalturk.sandbox.amazonaws.com'
            else:
                host = 'mechanicalturk.amazonaws.com'

        AWSQueryConnection.__init__(self, aws_access_key_id,
                                    aws_secret_access_key,
                                    is_secure, port, proxy, proxy_port,
                                    proxy_user, proxy_pass, host, debug,
                                    https_connection_factory)
Beispiel #43
0
 def __init__(self, aws_access_key_id=None, aws_secret_access_key=None,
              is_secure=True, port=None, proxy=None, proxy_port=None,
              proxy_user=None, proxy_pass=None, debug=0,
              https_connection_factory=None, region=None, path='/',
              converter=None, security_token=None):
     if not region:
         region = RegionInfo(self, self.DefaultRegionName,
             self.DefaultRegionEndpoint, CloudFormationConnection)
     self.region = region
     AWSQueryConnection.__init__(self, aws_access_key_id,
                                 aws_secret_access_key,
                                 is_secure, port, proxy, proxy_port,
                                 proxy_user, proxy_pass,
                                 self.region.endpoint, debug,
                                 https_connection_factory, path,
                                 security_token)
Beispiel #44
0
    def __init__(self, aws_access_key_id=None, aws_secret_access_key=None,
                 is_secure=True, host=None, port=None,
                 proxy=None, proxy_port=None,
                 proxy_user=None, proxy_pass=None, debug=0,
                 https_connection_factory=None, region=None, path='/',
                 api_version=None, security_token=None):

        AWSQueryConnection.__init__(self, aws_access_key_id,
                                    aws_secret_access_key,
                                    is_secure, port, proxy, proxy_port,
                                    proxy_user, proxy_pass,
                                    host, debug,
                                    https_connection_factory, path,
                                    security_token)
        if api_version:
            self.APIVersion = api_version
Beispiel #45
0
 def __init__(self, aws_access_key_id=None, aws_secret_access_key=None,
              is_secure=True, host=None, port=None,
              proxy=None, proxy_port=None,
              proxy_user=None, proxy_pass=None, debug=0,
              https_connection_factory=None, region=None, path='/',
              api_version=None, security_token=None,
              validate_certs=True):
     self.region = region
     AWSQueryConnection.__init__(self, aws_access_key_id,
                                 aws_secret_access_key,
                                 is_secure, port, proxy, proxy_port,
                                 proxy_user, proxy_pass,
                                 self.region.endpoint, debug,
                                 https_connection_factory, path,
                                 security_token,
                                 validate_certs=validate_certs)
Beispiel #46
0
 def make_request(self, action, params=None, path='/', verb='GET'):
     if self.aws_sudo_id:
         if params is None:
             params = {}
         params['AWSSudoId'] = self.aws_sudo_id
     return AWSQueryConnection.make_request(self, action, params, path,
                                            verb)
Beispiel #47
0
    def __init__(self, aws_access_key_id=None, aws_secret_access_key=None,
                 is_secure=True, port=None, proxy=None, proxy_port=None,
                 proxy_user=None, proxy_pass=None,
                 host=None, debug=0,
                 https_connection_factory=None):
        if not host:
            if config.has_option('MTurk', 'sandbox') and config.get('MTurk', 'sandbox') == 'True':
                host = 'mechanicalturk.sandbox.amazonaws.com'
            else:
                host = 'mechanicalturk.amazonaws.com'

        AWSQueryConnection.__init__(self, aws_access_key_id,
                                    aws_secret_access_key,
                                    is_secure, port, proxy, proxy_port,
                                    proxy_user, proxy_pass, host, debug,
                                    https_connection_factory)
Beispiel #48
0
 def __init__(self, aws_access_key_id=None, aws_secret_access_key=None,
              is_secure=True, port=None, proxy=None, proxy_port=None,
              proxy_user=None, proxy_pass=None, debug=0,
              https_connection_factory=None, region=None, path='/',
              converter=None, security_token=None, validate_certs=True):
     if not region:
         region = RegionInfo(self, self.DefaultRegionName,
             self.DefaultRegionEndpoint, CloudFormationConnection)
     self.region = region
     AWSQueryConnection.__init__(self, aws_access_key_id,
                                 aws_secret_access_key,
                                 is_secure, port, proxy, proxy_port,
                                 proxy_user, proxy_pass,
                                 self.region.endpoint, debug,
                                 https_connection_factory, path,
                                 security_token,
                                 validate_certs=validate_certs)
Beispiel #49
0
 def __init__(self, aws_access_key_id=None, aws_secret_access_key=None,
              is_secure=True, port=None, proxy=None, proxy_port=None,
              proxy_user=None, proxy_pass=None, debug=0,
              https_connection_factory=None, region=None, path='/',
              converter=None):
     if not region:
         region = RegionInfo(self, self.DefaultRegionName,
                             self.DefaultRegionEndpoint,
                             connection_cls=STSConnection)
     self.region = region
     self._mutex = threading.Semaphore()
     AWSQueryConnection.__init__(self, aws_access_key_id,
                                 aws_secret_access_key,
                                 is_secure, port, proxy, proxy_port,
                                 proxy_user, proxy_pass,
                                 self.region.endpoint, debug,
                                 https_connection_factory, path)
Beispiel #50
0
 def __init__(self, aws_access_key_id=None, aws_secret_access_key=None,
              is_secure=True, port=None, proxy=None, proxy_port=None,
              proxy_user=None, proxy_pass=None, debug=0,
              https_connection_factory=None, region=None, path='/',
              security_token=None, validate_certs=True):
     if not region:
         region = SQSRegionInfo(self, self.DefaultRegionName,
                                self.DefaultRegionEndpoint)
     self.region = region
     AWSQueryConnection.__init__(self, aws_access_key_id,
                                 aws_secret_access_key,
                                 is_secure, port,
                                 proxy, proxy_port,
                                 proxy_user, proxy_pass,
                                 self.region.endpoint, debug,
                                 https_connection_factory, path,
                                 security_token=security_token,
                                 validate_certs=validate_certs)
     self.auth_region_name = self.region.name
Beispiel #51
0
   def _make_request(self, params, debug=False):
       self._cleanupParsedProperties()
       conn = AWSQueryConnection(host=self.DEFAULT_HOST,
                                 aws_access_key_id=self.auth_accesskey,
                                 aws_secret_access_key=self.auth_secretkey)
 
       conn.APIVersion = self.API_VERSION
 
       response = conn.make_request(self.action, params=params)
       body = response.read()
 
       if debug:
           print body
 
       if not response.status == 200:
           raise self.ResponseError(response.status, response.reason, body)
 
       h = handler.XmlHandler(self, self)
       xml.sax.parseString(body, h)
Beispiel #52
0
    def _make_request(self, params, debug=False):
        self._cleanupParsedProperties()
        conn = AWSQueryConnection(host=self.DEFAULT_HOST,
                                  aws_access_key_id=self.auth_accesskey,
                                  aws_secret_access_key=self.auth_secretkey)

        conn.APIVersion = self.API_VERSION

        response = conn.make_request(self.action, params=params)
        body = response.read()

        if debug:
            print body

        if not response.status == 200:
            raise self.ResponseError(response.status, response.reason, body)

        h = handler.XmlHandler(self, self)
        xml.sax.parseString(body, h)
Beispiel #53
0
 def __init__(self,
              aws_access_key_id=None,
              aws_secret_access_key=None,
              is_secure=True,
              port=None,
              proxy=None,
              proxy_port=None,
              proxy_user=None,
              proxy_pass=None,
              debug=0,
              https_connection_factory=None,
              region=None,
              path='/',
              security_token=None,
              validate_certs=True):
     if not region:
         region = RegionInfo(self, self.DefaultRegionName,
                             self.DefaultRegionEndpoint)
     self.region = region
     AWSQueryConnection.__init__(self,
                                 aws_access_key_id,
                                 aws_secret_access_key,
                                 is_secure,
                                 port,
                                 proxy,
                                 proxy_port,
                                 proxy_user,
                                 proxy_pass,
                                 self.region.endpoint,
                                 debug,
                                 https_connection_factory,
                                 path,
                                 security_token,
                                 validate_certs=validate_certs)
     # Many of the EMR hostnames are of the form:
     #     <region>.<service_name>.amazonaws.com
     # rather than the more common:
     #     <service_name>.<region>.amazonaws.com
     # so we need to explicitly set the region_name and service_name
     # for the SigV4 signing.
     self.auth_region_name = self.region.name
     self.auth_service_name = 'elasticmapreduce'
Beispiel #54
0
    def __init__(self,
                 aws_access_key_id=None,
                 aws_secret_access_key=None,
                 is_secure=True,
                 port=None,
                 proxy=None,
                 proxy_port=None,
                 proxy_user=None,
                 proxy_pass=None,
                 debug=1,
                 https_connection_factory=None,
                 region=None,
                 path='/'):
        """
        Init method to create a new connection to the AutoScaling service.

        B{Note:} The host argument is overridden by the host specified in the
                 boto configuration file.
        """
        if not region:
            region = RegionInfo(self, self.DefaultRegionName,
                                self.DefaultRegionEndpoint,
                                AutoScaleConnection)
        self.region = region
        AWSQueryConnection.__init__(self,
                                    aws_access_key_id,
                                    aws_secret_access_key,
                                    is_secure,
                                    port,
                                    proxy,
                                    proxy_port,
                                    proxy_user,
                                    proxy_pass,
                                    "autoscaling.%s.amazonaws.com" %
                                    region.name,
                                    debug,
                                    https_connection_factory,
                                    path=path)
Beispiel #55
0
 def __init__(self,
              aws_access_key_id=None,
              aws_secret_access_key=None,
              is_secure=True,
              port=None,
              proxy=None,
              proxy_port=None,
              proxy_user=None,
              proxy_pass=None,
              debug=0,
              https_connection_factory=None,
              region=None,
              path='/',
              converter=None):
     """
     For any keywords that aren't documented, refer to the parent class,
     :py:class:`boto.connection.AWSAuthConnection`. You can avoid having
     to worry about these keyword arguments by instantiating these objects
     via :py:func:`boto.connect_sdb`.
 
     :type region: :class:`boto.sdb.regioninfo.SDBRegionInfo`
     :keyword region: Explicitly specify a region. Defaults to ``us-east-1`` 
         if not specified.
     """
     if not region:
         region = SDBRegionInfo(self, self.DefaultRegionName,
                                self.DefaultRegionEndpoint)
     self.region = region
     AWSQueryConnection.__init__(self, aws_access_key_id,
                                 aws_secret_access_key, is_secure, port,
                                 proxy, proxy_port, proxy_user, proxy_pass,
                                 self.region.endpoint, debug,
                                 https_connection_factory, path)
     self.box_usage = 0.0
     self.converter = converter
     self.item_cls = Item
Beispiel #56
0
def get_ecs_response(params):
    """Call Amazon ECS with the given parameters and return the raw XML response"""
    try:
        aws_conn = AWSQueryConnection(
            aws_access_key_id=settings.AWS_ACCESS_KEY_ID,
            aws_secret_access_key=settings.AWS_SECRET_ACCESS_KEY,
            is_secure=False,
            host='ecs.amazonaws.com',
        )
        aws_conn.SignatureVersion = '2'
        base_params = dict(
            Service='AWSECommerceService',
            Version='2008-08-19',
            SignatureVersion=aws_conn.SignatureVersion,
            AWSAccessKeyId=settings.AWS_ACCESS_KEY_ID,
            AssociateTag=settings.AWS_ASSOCIATE_TAG,
            Operation='ItemSearch',
            IdType='ASIN',
            ResponseGroup='Small',
            Timestamp=time.strftime("%Y-%m-%dT%H:%M:%S", time.gmtime())
        )
        if params:
            base_params.update(params)
        verb = 'GET'
        path = '/onca/xml'
        qs, signature = aws_conn.get_signature(base_params, verb, path)
        qs = path + '?' + qs + '&Signature=' + urllib.quote(signature)
        time.sleep(0.5) # throttle
        response = aws_conn._mexe(verb, qs, None, headers={})
        resp = response.read()
        _log.debug("ECS Response: %s", resp)
        return resp
    except Exception, e:
        _log.debug("AWS ASIN call failed for params: %s", params)
        _log.debug(e)
        return u''
Beispiel #57
0
 def __init__(self, *args, **kw):
     self.currencycode = kw.pop('CurrencyCode', self.currencycode)
     kw.setdefault('host', 'fps.sandbox.amazonaws.com')
     AWSQueryConnection.__init__(self, *args, **kw)
Beispiel #58
0
 def setUp(self):
     self.connection = AWSQueryConnection('access_key', 'secret_key')
Beispiel #59
0
    def create_amazon_book_by_asin(self, asin):

        AWS_ACCESS_KEY_ID = settings.AWS_ACCESS_KEY_ID
        AWS_ASSOCIATE_TAG = settings.AWS_ASSOCIATE_TAG
        AWS_SECRET_ACCESS_KEY = settings.AWS_SECRET_ACCESS_KEY
                
        search_index = 'Book'
        aws_conn = AWSQueryConnection(
            aws_access_key_id=AWS_ACCESS_KEY_ID,
            aws_secret_access_key=AWS_SECRET_ACCESS_KEY, is_secure=False,
            host='ecs.amazonaws.com')
        aws_conn.SignatureVersion = '2'
        params = dict(
            Service='AWSECommerceService',
            Version='2008-08-19',
            SignatureVersion=aws_conn.SignatureVersion,
            AWSAccessKeyId=AWS_ACCESS_KEY_ID,
            AssociateTag=AWS_ASSOCIATE_TAG,
            Operation='ItemLookup',
            ItemId=asin,
            ResponseGroup='ItemAttributes,Large, Images,Reviews',
            Timestamp=time.strftime("%Y-%m-%dT%H:%M:%S", time.gmtime()))
        verb = 'GET'
        path = '/onca/xml'
        qs, signature = aws_conn.get_signature(params, verb, path)
        qs = path + '?' + qs + '&Signature=' + urllib.quote(signature)
        #print "verb:", verb, "qs:", qs
        response = aws_conn._mexe(verb, qs, None, headers={})
        returned_xml = self.raw_xml = myxml = str(response.read())
        
        returned_xml = returned_xml.replace(" xmlns=\"http://webservices.amazon.com/AWSECommerceService/2008-08-19\"", '')
        
        doc = ElementTree.fromstring(returned_xml)
        

        try:
            self.title = doc.find('Items/Item/ItemAttributes/Title').text
        except:
            self.title = ""
            
        #self.author = doc.find('Items/Item/ItemAttributes/Author').text
        author_list = doc.findall('Items/Item/ItemAttributes/Author')
        for a in author_list:
            self.authors.append(a.text)
        try:
            self.edition = doc.find('Items/Item/ItemAttributes/Edition').text
        except:
            self.edition = ""
        try:
            self.list_price = doc.find('Items/Item/ItemAttributes/ListPrice/FormattedPrice').text
        except AttributeError:
            self.list_price = ""
        try:
            self.sale_price = doc.find('Items/Item/Offers/Offer/OfferListing/Price/FormattedPrice').text
        except AttributeError:
            self.sale_price = ""
        try:
            self.amount_saved = doc.find('Items/Item/Offers/Offer/OfferListing/AmountSaved/FormattedPrice').text
        except AttributeError:
            self.amount_saved = ""
        try:
            self.percentage_saved = doc.find('Items/Item/Offers/Offer/OfferListing/PercentageSaved').text
        except AttributeError:
            self.percentage_saved = ""
        try:
            self.ISBN = doc.find('Items/Item/ItemAttributes/ISBN').text
        except AttributeError:
            self.ISBN = ""
        try:
            self.ASIN = doc.find('Items/Item/ASIN').text
        except:
            self.ASIN = ""
        try:
            self.binding = doc.find('Items/Item/ItemAttributes/Binding').text
        except:
            self.binding = ""
            
        try:
            self.detail_url = doc.find('Items/Item/DetailPageURL').text
        except:
            self.detail_url = ""
            
        try:
            temp_date = doc.find('Items/Item/ItemAttributes/PublicationDate').text
        except:
            self.date = ""
        try:
            # convert to struct_time, then to datetime obj
            c = time.strptime(temp_date,"%Y-%m-%d")
            d = datetime.datetime(*c[:6])
            self.publication_date = d
        except:
            self.publication_date = ""

        try:
            self.publisher = doc.find('Items/Item/ItemAttributes/Publisher').text   # this should be a tag so it becomes a link to view more books by publisher
        except:
            self.publisher = ""
        try:
            self.pages = doc.find('Items/Item/ItemAttributes/NumberOfPages').text
        except AttributeError:
            self.page= ""
        try:
            self.lrg_image = doc.find('Items/Item/LargeImage/URL').text
        except AttributeError:
            self.lrg_img = ""
            
        try:
            self.med_image = doc.find('Items/Item/MediumImage/URL').text
        except AttributeError:
            self.med_image= ""
            
        try: 
            self.tiny_image = doc.find('Items/Item/ImageSets/ImageSet/TinyImage/URL').text
        except AttributeError:
            self.tiny_image = ""
        editorials = doc.findall('Items/Item/EditorialReviews/EditorialReview')
        for reviews in editorials:
            if reviews.find('Source').text == "Product Description":
                self.description = reviews.find('Content').text
            else:
                ed = AmazonEditorial()
                ed.source = reviews.find('Source').text
                ed.content = reviews.find('Content').text
                self.editorial_reviews.append(ed)
                
            
        creators = doc.findall('Items/Item/ItemAttributes/Creator')
        
        for creator in creators:
            cr = AmazonBookCreator()
            cr.name = creator.text
            cr.role = creator.attrib['Role']
            self.creators.append(cr)