O'Reilly Forums: Trouble Accessing With Paws Python Code - O'Reilly Forums

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Trouble Accessing With Paws Python Code

#1 User is offline   Allan 

  • New Member
  • Pip
  • Group: Members
  • Posts: 1
  • Joined: 11-June 08

Posted 11 June 2008 - 08:07 AM

I'm running Python 2.5.2 with the latest version of lxml.

When I try to connect to AWS with the python PAWS code, I receive the following error. Any idea what I'm doing wrong? I have environment variables set for AWS_ACCESS_KEY and AWS_SECRET_KEY.

Thanks in advance for any assistance...


>>> import S3
>>> svc = S3.S3()
>>> svc.list_buckets()
Body:
<ListAllMyBucketsResult xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
<Owner>
<ID>[snipped]</ID>
<DisplayName>allan</DisplayName>
</Owner>
<Buckets/>
</ListAllMyBucketsResult>


Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "S3.py", line 95, in list_buckets
for node in self.xpath_list('//ns:Buckets/ns:Bucket', xmldoc):
File "AWS.py", line 448, in xpath_list
return xml_object.xpath(query, {'ns':self.XML_NAMESPACE})
TypeError: function takes at most 1 positional arguments (2 given)

0

#2 User is offline   JamesMurty 

  • Active Member
  • PipPip
  • Group: Members
  • Posts: 21
  • Joined: 20-March 08

Posted 12 June 2008 - 03:57 AM

This error seems to be caused by a change introduced in the lxml library in version 2 (the original code was developed against version 1.3.6).

After updating to latest version of lxml I got the same problem but the fix is fairly simple, you just need to explicitly tell the xpath() method that the second argument is a hash of "namespaces".

In the AWS.py file, edit the xpath_list() function from the original:
CODE
def xpath_list(self, query, xml_object):
    return xml_object.xpath(query, {'ns':self.XML_NAMESPACE})


and add "namespaces=" before the second argument like so:
CODE
def xpath_list(self, query, xml_object):
    return xml_object.xpath(query, namespaces={'ns':self.XML_NAMESPACE})


Hope this helps,
James
0

#3 User is offline   NickJohnson 

  • Active Member
  • PipPip
  • Group: Members
  • Posts: 15
  • Joined: 24-September 12
  • Gender:Male

Posted 16 November 2012 - 11:22 PM

U should consult with an expert... Your problem seems to be tricky....
http://www.expertsfromindia.com/html5-designer.htm
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users