#30 s3cmd-0.9.9 with python 2.4.4 not working

open-works-for-me
s3cmd (119)
5
2010-03-03
2009-03-26
Anonymous
No

Hello!

I get the following error. I fixed it by adding "import sha" and changing
"return base64.encodestring(hmac.new(self.config.secret_key, h, sha1).digest()).strip()"
to
"return base64.encodestring(hmac.new(self.config.secret_key, h, sha).digest()).strip()"
in S3/S3.py

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
An unexpected error has occurred.
Please report the following lines to:
s3tools-bugs@lists.sourceforge.net
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Problem: AttributeErr: 'builtin_function_or_method' object has no attribute 'new'
S3cmd: 0.9.9
Python: 2.4.4 (#2, Oct 22 2008, 19:52:44) [GCC 4.1.2 20061115 (prerelease) (Debian 4.1.1-21)]

Traceback (most recent call last):
File "/usr/bin/s3cmd", line 1562, in ?
main()
File "/usr/bin/s3cmd", line 1542, in main
cmd_func(args)
File "/usr/bin/s3cmd", line 95, in cmd_buckets_list_all_all
response = s3.list_all_buckets()
File "/usr/lib/python2.4/site-packages/S3/S3.py", line 108, in list_all_buckets
request = self.create_request("LIST_ALL_BUCKETS")
File "/usr/lib/python2.4/site-packages/S3/S3.py", line 340, in create_request
signature = self.sign_headers(method_string, resource, headers)
File "/usr/lib/python2.4/site-packages/S3/S3.py", line 652, in sign_headers
return base64.encodestring(hmac.new(self.config.secret_key, h, sha1).digest()).strip()
File "hmac.py", line 107, in new
return HMAC(key, msg, digestmod)
File "hmac.py", line 42, in __init__
self.outer = digestmod.new()
AttributeError: 'builtin_function_or_method' object has no attribute 'new'

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
An unexpected error has occurred.
Please report the above lines to:
s3tools-bugs@lists.sourceforge.net
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Discussion

  • Michal Ludvig

    Michal Ludvig - 2009-03-27
    • assigned_to: nobody --> ludvigm
    • status: open --> open-works-for-me
     
  • Michal Ludvig

    Michal Ludvig - 2009-03-27

    You must be having some funny version of python I guess.

    The 'sha' module in Python 2.4 should be imported with:
    import sha as sha1
    so referencing to it later as to 'sha1' is all right. I can't reproduce it on my Python 2.4.3 installation.

     
  • Michal Ludvig

    Michal Ludvig - 2009-05-28
    • status: open-works-for-me --> closed-works-for-me
     
  • Comment has been marked as spam. 
    Undo

    You can see all pending comments posted by this user  here

    Anonymous - 2010-03-03
    • status: closed-works-for-me --> open-works-for-me
     
  • Comment has been marked as spam. 
    Undo

    You can see all pending comments posted by this user  here

    Anonymous - 2010-03-03

    I had the same issue, it has to do with the sha1 library. I am not a python developer but I figured a work around, it is like this:
    1) vi /usr/lib/python2.4/site-packages/S3/Utils.py
    2) add: import sha
    3) go to line 290 and replace this:
    signature = base64.encodestring(hmac.new(Config.Config().secret_key, string_to_sign, sha1).digest()).strip()

    with this:
    signature = base64.encodestring(hmac.new(Config.Config().secret_key, string_to_sign, digestmod=sha).digest()).strip()

    4) Save and try again

    I got the idea from here:
    http://code.google.com/p/boto/issues/detail?id=172

     
  • Tom Pollard

    Tom Pollard - 2011-05-13

    I'm having exactly the same problem when I try to run s3cmd on a CentOS 5.5 image with python 2.4.3. I did the following experiment,

    Python 2.4.3 (#1, Nov 11 2010, 13:34:43)
    [GCC 4.1.2 20080704 (Red Hat 4.1.2-48)] on linux2
    Type "help", "copyright", "credits" or "license" for more information.
    >>> from hashlib import md5, sha1
    >>> import sha
    >>> md5.new()
    Traceback (most recent call last):
    File "<stdin>", line 1, in ?
    AttributeError: 'builtin_function_or_method' object has no attribute 'new'
    >>> sha1.new()
    Traceback (most recent call last):
    File "<stdin>", line 1, in ?
    AttributeError: 'builtin_function_or_method' object has no attribute 'new'
    >>> sha.new()
    <sha.SHA object at 0xb7f55640>
    >>>

    The import from hashlib isn't failing, but the version of md5 and sha1 that are imported don't have the new() method that s3cmd require. Adding 'import sha' and replacing the reference to sha1 with sha in S3/Utils.py works around the problem in my hands, too.

     

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks