You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@libcloud.apache.org by Simon Smith <sg...@arcode.com> on 2011/10/11 19:19:04 UTC

httplib error when using Rackspace cloudfiles driver

I'm getting an httplib.py error when trying to upload a file, see python 
session below.  Note that 'test2' is a previously-created container.   I 
looked at the code and it isn't obvious what is going on.  I can go add 
debugging code but first wanted to see if anyone else had run into 
this.  (Note: I have not had any problems using libcloud to create new 
Rackspace computing nodes).

Thanks - Simon

 >>> from libcloud.storage.types import Provider
 >>> from libcloud.storage.providers import get_driver
 >>> CloudFiles = get_driver(Provider.CLOUDFILES_US)
 >>> driver = CloudFiles('<redacted>','<redacted>')
/var/www/html/ops/resources/python/libcloud/httplib_ssl.pyc/qqPIGI8-vn-gxQ_YSAuiF22D8YyOdnxVQ8LYN4UQEbk:55: 
UserWarning: SSL certificate verification is disabled, this can pose a 
security risk. For more information how to enable the SSL certificate 
verification, please visit the libcloud documentation.
 >>> cont = driver.get_container('test2')
 >>> driver.upload_object('file.txt',cont,'testfile2')
Traceback (most recent call last):
   File "<stdin>", line 1, in <module>
   File "python/libcloud/storage/drivers/cloudfiles.py", line 304, in 
upload_object
   File "python/libcloud/storage/drivers/cloudfiles.py", line 398, in 
_put_object
   File "python/libcloud/storage/base.py", line 534, in _upload_object
   File "python/libcloud/storage/drivers/cloudfiles.py", line 123, in 
request
   File "python/libcloud/common/base.py", line 385, in request
   File "/home/arcmgr/lib/python2.7/httplib.py", line 924, in putheader
     str = '%s: %s' % (header, '\r\n\t'.join(values))
TypeError: sequence item 0: expected string, long found





Re: httplib error when using Rackspace cloudfiles driver

Posted by Simon Smith <sg...@arcode.com>.
On 10/11/11 1:40 PM, Tomaž Muraus wrote:
> Hi,
>
> Which version of libcloud are you using (0.5.2, trunk?).
>
> It would also be very useful if you can run your script with
> LIBCLOUD_DEBUG=/dev/stdout environment variable set -
> LIBCLOUD_DEBUG=/dev/stdout python my_script.py.
>
> This should log all the requests and hopefully the offending header which is
> making it fail.
>
> P.S. I think calling str() on the 'value' in common/base.py:L385 would fix
> it, but I'm still interested where the 'long' value is coming from (probably
> it's a content-length or something like that).
>
> Thanks,
> Tomaz
>
>
>


I'm using 0.5.2 - see below for the same commands, this time with the 
debug env var set:

 >>> from libcloud.storage.types import Provider
 >>> from libcloud.storage.providers import get_driver
 >>> CloudFiles = get_driver(Provider.CLOUDFILES_US)
 >>> driver = CloudFiles('<redacted>','<redacted>')
/var/www/html/ops/resources/python/libcloud/httplib_ssl.pyc/qqPIGI8-vn-gxQ_YSAuiF22D8YyOdnxVQ8LYN4UQEbk:55: 
UserWarning: SSL certificate verification is disabled, this can pose a 
security risk. For more information how to enable the SSL certificate 
verification, please visit the libcloud documentation.
# -------- begin 154344460 request ----------
curl -i -X GET -H 'X-Auth-Key: <redacted>' -H 'X-Auth-User: <redacted>' 
-H 'X-LC-Request-ID: 154344460' https://auth.api.rackspacecloud.com:443/v1.0
# -------- begin 154344460:154344492 response ----------
HTTP/1.1 204 No Content
Content-Length: 0
X-Server-Management-Url: https://servers.api.rackspacecloud.com/v1.0/428629
X-Storage-Token: 46d0734d-58b0-4242-8cdc-67473a806999
Vary: X-Auth-Token,X-Auth-Key,X-Storage-User,X-Storage-Pass
X-Cdn-Management-Url: 
https://cdn1.clouddrive.com/v1/MossoCloudFS_aaa74b2b-aa31-4be1-9c79-fd3b9b93ef9b
Server: Apache/2.2.13 (Red Hat)
Connection: Keep-Alive
Cache-Control: s-maxage=67294
Date: Tue, 11 Oct 2011 17:50:46 GMT
X-Storage-Url: 
https://storage101.dfw1.clouddrive.com/v1/MossoCloudFS_aaa74b2b-aa31-4be1-9c79-fd3b9b93ef9b
X-Auth-Token: <redacted>
Content-Type: application/octet-stream


# -------- end 154344460:154344492 response ----------

 >>> cont = driver.get_container('test2')
# -------- begin 154344236 request ----------
curl -i -X HEAD -H 'Host: storage101.dfw1.clouddrive.com' -H 
'X-LC-Request-ID: 154344236' -H 'X-Auth-Token: <redacted>' -H 
'Content-Length: 0' -H 'Accept: application/json' -H 'User-Agent: 
libcloud/0.5.2 (CloudFiles (US))' 
'https://storage101.dfw1.clouddrive.com:443/v1/MossoCloudFS_aaa74b2b-aa31-4be1-9c79-fd3b9b93ef9b/test2?format=json'
# -------- begin 154344236:153603084 response ----------
HTTP/1.1 204 No Content
Content-Length: 0
X-Container-Object-Count: 0
Accept-Ranges: bytes
Date: Tue, 11 Oct 2011 17:51:20 GMT
X-Trans-Id: tx3f3c8cf00c0e4c2ebc3a6e484c05bb71
X-Container-Bytes-Used: 0


# -------- end 154344236:153603084 response ----------

 >>> driver.upload_object('file.txt',cont,'testfile2')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "python/libcloud/storage/drivers/cloudfiles.py", line 304, in 
upload_object
File "python/libcloud/storage/drivers/cloudfiles.py", line 398, in 
_put_object
File "python/libcloud/storage/base.py", line 534, in _upload_object
File "python/libcloud/storage/drivers/cloudfiles.py", line 123, in request
File "python/libcloud/common/base.py", line 385, in request
File "/home/arcmgr/lib/python2.7/httplib.py", line 924, in putheader
str = '%s: %s' % (header, '\r\n\t'.join(values))
TypeError: sequence item 0: expected string, long found
 >>>




Re: httplib error when using Rackspace cloudfiles driver

Posted by Simon Smith <sg...@arcode.com>.
Thanks!  I'm using what is probably an early 2.7 version, and we might 
be using an old httplib as well.  I will check out all three upgrade 
avenues.  I really appreciate your time and help!!!

  On 10/11/11 1:59 PM, Tomaž Muraus wrote:
> Actually, I just checked the trunk version and we already call str() on the
> header value there - please try your script with the trunk version.
>
> Also out of curiosity which exact Python version are you using? I tested it
> with 2.7.2 and it looks like httplib.py there already calls str() on the
> value internally.
>
>      def putheader(self, header, *values):
>>          """Send a request header line to the server.
>>          For example: h.putheader('Accept', 'text/html')
>>          """
>>          if self.__state != _CS_REQ_STARTED:
>>              raise CannotSendHeader()
>>          hdr = '%s: %s' % (header, '\r\n\t'.join([str(v) for v in values]))
>
>
> Looking at your stacktrace that is not the case for the version you are
> using :)
>
> Thanks,
> Tomaz
>
> 2011/10/11 Tomaž Muraus<to...@apache.org>
>
>> Hi,
>>
>> Which version of libcloud are you using (0.5.2, trunk?).
>>
>> It would also be very useful if you can run your script with
>> LIBCLOUD_DEBUG=/dev/stdout environment variable set -
>> LIBCLOUD_DEBUG=/dev/stdout python my_script.py.
>>
>> This should log all the requests and hopefully the offending header which
>> is making it fail.
>>
>> P.S. I think calling str() on the 'value' in common/base.py:L385 would fix
>> it, but I'm still interested where the 'long' value is coming from (probably
>> it's a content-length or something like that).
>>
>> Thanks,
>> Tomaz
>>
>> On Tue, Oct 11, 2011 at 7:19 PM, Simon Smith<sg...@arcode.com>  wrote:
>>
>>> I'm getting an httplib.py error when trying to upload a file, see python
>>> session below.  Note that 'test2' is a previously-created container.   I
>>> looked at the code and it isn't obvious what is going on.  I can go add
>>> debugging code but first wanted to see if anyone else had run into this.
>>>   (Note: I have not had any problems using libcloud to create new Rackspace
>>> computing nodes).
>>>
>>> Thanks - Simon
>>>
>>>>>> from libcloud.storage.types import Provider
>>>>>> from libcloud.storage.providers import get_driver
>>>>>> CloudFiles = get_driver(Provider.**CLOUDFILES_US)
>>>>>> driver = CloudFiles('<redacted>','<**redacted>')
>>> /var/www/html/ops/resources/**python/libcloud/httplib_ssl.**
>>> pyc/qqPIGI8-vn-gxQ_**YSAuiF22D8YyOdnxVQ8LYN4UQEbk:**55: UserWarning: SSL
>>> certificate verification is disabled, this can pose a security risk. For
>>> more information how to enable the SSL certificate verification, please
>>> visit the libcloud documentation.
>>>>>> cont = driver.get_container('test2')
>>>>>> driver.upload_object('file.**txt',cont,'testfile2')
>>> Traceback (most recent call last):
>>>   File "<stdin>", line 1, in<module>
>>>   File "python/libcloud/storage/**drivers/cloudfiles.py", line 304, in
>>> upload_object
>>>   File "python/libcloud/storage/**drivers/cloudfiles.py", line 398, in
>>> _put_object
>>>   File "python/libcloud/storage/base.**py", line 534, in _upload_object
>>>   File "python/libcloud/storage/**drivers/cloudfiles.py", line 123, in
>>> request
>>>   File "python/libcloud/common/base.**py", line 385, in request
>>>   File "/home/arcmgr/lib/python2.7/**httplib.py", line 924, in putheader
>>>     str = '%s: %s' % (header, '\r\n\t'.join(values))
>>> TypeError: sequence item 0: expected string, long found
>>>
>>>
>>>
>>>
>>>


Re: httplib error when using Rackspace cloudfiles driver

Posted by Tomaž Muraus <to...@tomaz.me>.
Actually, I just checked the trunk version and we already call str() on the
header value there - please try your script with the trunk version.

Also out of curiosity which exact Python version are you using? I tested it
with 2.7.2 and it looks like httplib.py there already calls str() on the
value internally.

    def putheader(self, header, *values):
>         """Send a request header line to the server.
>         For example: h.putheader('Accept', 'text/html')
>         """
>         if self.__state != _CS_REQ_STARTED:
>             raise CannotSendHeader()
>         hdr = '%s: %s' % (header, '\r\n\t'.join([str(v) for v in values]))



Looking at your stacktrace that is not the case for the version you are
using :)

Thanks,
Tomaz

2011/10/11 Tomaž Muraus <to...@apache.org>

> Hi,
>
> Which version of libcloud are you using (0.5.2, trunk?).
>
> It would also be very useful if you can run your script with
> LIBCLOUD_DEBUG=/dev/stdout environment variable set -
> LIBCLOUD_DEBUG=/dev/stdout python my_script.py.
>
> This should log all the requests and hopefully the offending header which
> is making it fail.
>
> P.S. I think calling str() on the 'value' in common/base.py:L385 would fix
> it, but I'm still interested where the 'long' value is coming from (probably
> it's a content-length or something like that).
>
> Thanks,
> Tomaz
>
> On Tue, Oct 11, 2011 at 7:19 PM, Simon Smith <sg...@arcode.com> wrote:
>
>> I'm getting an httplib.py error when trying to upload a file, see python
>> session below.  Note that 'test2' is a previously-created container.   I
>> looked at the code and it isn't obvious what is going on.  I can go add
>> debugging code but first wanted to see if anyone else had run into this.
>>  (Note: I have not had any problems using libcloud to create new Rackspace
>> computing nodes).
>>
>> Thanks - Simon
>>
>> >>> from libcloud.storage.types import Provider
>> >>> from libcloud.storage.providers import get_driver
>> >>> CloudFiles = get_driver(Provider.**CLOUDFILES_US)
>> >>> driver = CloudFiles('<redacted>','<**redacted>')
>> /var/www/html/ops/resources/**python/libcloud/httplib_ssl.**
>> pyc/qqPIGI8-vn-gxQ_**YSAuiF22D8YyOdnxVQ8LYN4UQEbk:**55: UserWarning: SSL
>> certificate verification is disabled, this can pose a security risk. For
>> more information how to enable the SSL certificate verification, please
>> visit the libcloud documentation.
>> >>> cont = driver.get_container('test2')
>> >>> driver.upload_object('file.**txt',cont,'testfile2')
>> Traceback (most recent call last):
>>  File "<stdin>", line 1, in <module>
>>  File "python/libcloud/storage/**drivers/cloudfiles.py", line 304, in
>> upload_object
>>  File "python/libcloud/storage/**drivers/cloudfiles.py", line 398, in
>> _put_object
>>  File "python/libcloud/storage/base.**py", line 534, in _upload_object
>>  File "python/libcloud/storage/**drivers/cloudfiles.py", line 123, in
>> request
>>  File "python/libcloud/common/base.**py", line 385, in request
>>  File "/home/arcmgr/lib/python2.7/**httplib.py", line 924, in putheader
>>    str = '%s: %s' % (header, '\r\n\t'.join(values))
>> TypeError: sequence item 0: expected string, long found
>>
>>
>>
>>
>>
>

Re: httplib error when using Rackspace cloudfiles driver

Posted by Tomaž Muraus <to...@apache.org>.
Hi,

Which version of libcloud are you using (0.5.2, trunk?).

It would also be very useful if you can run your script with
LIBCLOUD_DEBUG=/dev/stdout environment variable set -
LIBCLOUD_DEBUG=/dev/stdout python my_script.py.

This should log all the requests and hopefully the offending header which is
making it fail.

P.S. I think calling str() on the 'value' in common/base.py:L385 would fix
it, but I'm still interested where the 'long' value is coming from (probably
it's a content-length or something like that).

Thanks,
Tomaz

On Tue, Oct 11, 2011 at 7:19 PM, Simon Smith <sg...@arcode.com> wrote:

> I'm getting an httplib.py error when trying to upload a file, see python
> session below.  Note that 'test2' is a previously-created container.   I
> looked at the code and it isn't obvious what is going on.  I can go add
> debugging code but first wanted to see if anyone else had run into this.
>  (Note: I have not had any problems using libcloud to create new Rackspace
> computing nodes).
>
> Thanks - Simon
>
> >>> from libcloud.storage.types import Provider
> >>> from libcloud.storage.providers import get_driver
> >>> CloudFiles = get_driver(Provider.**CLOUDFILES_US)
> >>> driver = CloudFiles('<redacted>','<**redacted>')
> /var/www/html/ops/resources/**python/libcloud/httplib_ssl.**
> pyc/qqPIGI8-vn-gxQ_**YSAuiF22D8YyOdnxVQ8LYN4UQEbk:**55: UserWarning: SSL
> certificate verification is disabled, this can pose a security risk. For
> more information how to enable the SSL certificate verification, please
> visit the libcloud documentation.
> >>> cont = driver.get_container('test2')
> >>> driver.upload_object('file.**txt',cont,'testfile2')
> Traceback (most recent call last):
>  File "<stdin>", line 1, in <module>
>  File "python/libcloud/storage/**drivers/cloudfiles.py", line 304, in
> upload_object
>  File "python/libcloud/storage/**drivers/cloudfiles.py", line 398, in
> _put_object
>  File "python/libcloud/storage/base.**py", line 534, in _upload_object
>  File "python/libcloud/storage/**drivers/cloudfiles.py", line 123, in
> request
>  File "python/libcloud/common/base.**py", line 385, in request
>  File "/home/arcmgr/lib/python2.7/**httplib.py", line 924, in putheader
>    str = '%s: %s' % (header, '\r\n\t'.join(values))
> TypeError: sequence item 0: expected string, long found
>
>
>
>
>