JS files are not recognized #1089

Closed
okossuth opened this Issue Oct 29, 2012 · 3 comments

Comments

Projects
None yet
2 participants

Hi guys

I'm getting this error while trying to compute the md5 checksum of a JS file
stored on an s3 bucket:

Traceback (most recent call last):
File "./s3aws-static.py", line 252, in
p.dispatch()
File "/usr/lib/python2.7/site-packages/argh/helpers.py", line 307, in dispatch
return dispatch(self, _args, *_kwargs)
File "/usr/lib/python2.7/site-packages/argh/helpers.py", line 202, in dispatch
for line in lines:
File "/usr/lib/python2.7/site-packages/argh/helpers.py", line 284, in _execute_command
for line in result:
File "/usr/lib/python2.7/site-packages/argh/helpers.py", line 267, in _call
result = args.function(args)
File "./s3aws-static.py", line 231, in putonly
print k.etag
AttributeError: 'NoneType' object has no attribute 'etag'

the code:

k = bucket.get_key(z)
print k.etag
etag = k.etag[1:-1]

it works fine with other files like html, php, jpg, etc but not for js files.
i think its related to this issue:
https://groups.google.com/forum/?fromgroups=#!topic/boto-users/XZfEtlr8jcI

Is there a workaround for this?
thanks

Owner

garnaat commented Oct 30, 2012

I'm not able to reproduce this error. I created a file called "foo.js" and stored it in an S3 bucket. Then, I did this:

>>> import boto
>>> c = boto.connect_s3()
>>> bucket = c.lookup('test-1351036825')
>>> k = b.get_key('foo.js')
>>> k
<Key: test-1351036825,foo.js>
>>> k.etag
'"09cba091df696af91549de27b8e7d0f6"'

From the error you are getting, it looks like the call to bucket.get_key(z) is returning a value of None and then you are trying to access the etag attribute of the None value which raises the AttributeError.

Hmm its weird, here is the complete log of my script(it uploads a file in case its new or has been modified), you will see there that it only fails with the JS file:

[oskar@localhost Ovivo]$ ./s3aws-static.py putonly --bucket=xxxxxx --path=default_server
the fullpath is /home/oskar/Documents/Projects/xxxx/default_server
bucket exists!
Subdirectories disabled...
"09c446602b01932470bec4bf8e568bb2"
File /home/oskar/Documents/Projects/xxxx/default_server/index.html is not new, canceling uploading!
Subdirectories disabled...
"631bdc87d37e156362f42d875c605e28"
File /home/oskar/Documents/Projects/xxxx/default_server/favicon.ico is not new, canceling uploading!
Subdirectories disabled...
"7bfb550966504c74e1d08efa3d811867"
File /home/oskar/Documents/Projects/xxxx/default_server/logo.png is not new, canceling uploading!
Subdirectories disabled...
"394b33598795ef3f9f1873e7cb1a09b9"
File /home/oskar/Documents/Projects/xxxx/default_server/default-server.xml is not new, canceling uploading!
Subdirectories disabled...
Traceback (most recent call last):
File "./s3aws-static.py", line 252, in
p.dispatch()
File "/usr/lib/python2.7/site-packages/argh/helpers.py", line 307, in dispatch
return dispatch(self, _args, *_kwargs)
File "/usr/lib/python2.7/site-packages/argh/helpers.py", line 202, in dispatch
for line in lines:
File "/usr/lib/python2.7/site-packages/argh/helpers.py", line 284, in _execute_command
for line in result:
File "/usr/lib/python2.7/site-packages/argh/helpers.py", line 267, in _call
result = args.function(args)
File "./s3aws-static.py", line 231, in putonly
print k.etag
AttributeError: 'NoneType' object has no attribute 'etag'

I will re-check the code and be back to you
thanks!

I found the error:

/default_server/index.html~
None
Traceback (most recent call last):
File "./s3aws-static.py", line 253, in
p.dispatch()
File "/usr/lib/python2.7/site-packages/argh/helpers.py", line 307, in dispatch
return dispatch(self, _args, *_kwargs)
File "/usr/lib/python2.7/site-packages/argh/helpers.py", line 202, in dispatch
for line in lines:
File "/usr/lib/python2.7/site-packages/argh/helpers.py", line 284, in _execute_command
for line in result:
File "/usr/lib/python2.7/site-packages/argh/helpers.py", line 267, in _call
result = args.function(args)
File "./s3aws-static.py", line 233, in putonly
etag = k.etag[1:-1]
AttributeError: 'NoneType' object has no attribute 'etag'

the local file /default_server/index.html~ doesnt exist on the bucket that's why i get a None type and
consequently the error with the JS file ( i had a server.js~ file that wasnt on the bucket too)
i will add some logic to deal with these kind of files :)
Thanks for your help!

@garnaat garnaat closed this Oct 30, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment