echonest / pyechonest

Python client for the Echo Nest API
http://echonest.github.com/pyechonest/
BSD 3-Clause "New" or "Revised" License
668 stars 877 forks source link

HTTP/SOCKS Proxy upload file #6

Open avono opened 12 years ago

avono commented 12 years ago

So I have an issue uploading a music file through the http proxy I am behind this query works

>>> song.search(artist="radiohead",title="Creep")

[<song - Creep>, <song - CREEP (LYRICS!)>, <song - Creep (Acoustic)>, <song - Creep (Radio Edit)>, <song - CREEP (Live)/(LYRICS!)>, <song - Creep (BBC Radio 1 Evening Session)>]

however doing this returns ...

>>> track.track_from_filename(filename)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "build/bdist.macosx-10.6-intel/egg/pyechonest/track.py", line 217, in track_from_filename
  File "build/bdist.macosx-10.6-intel/egg/pyechonest/track.py", line 196, in track_from_file
  File "build/bdist.macosx-10.6-intel/egg/pyechonest/track.py", line 174, in _track_from_string
  File "build/bdist.macosx-10.6-intel/egg/pyechonest/track.py", line 152, in _upload
  File "build/bdist.macosx-10.6-intel/egg/pyechonest/util.py", line 202, in callm
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 958, in request
    self._send_request(method, url, body, headers)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 992, in _send_request
    self.endheaders(body)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 954, in endheaders
    self._send_output(message_body)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 814, in _send_output
    self.send(msg)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 776, in send
    self.connect()
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 757, in connect
    self.timeout, self.source_address)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/socket.py", line 571, in create_connection
    raise err
socket.error: [Errno 60] Operation timed out

I have tried to "socksipy" (http://socksipy.sourceforge.net) to force the sockets to use the proxy like this:

>>> socks.setdefaultproxy(socks.PROXY_TYPE_SOCKS5,"socks.example.com")
>>> socket.socket = socks.socksocket

but to no avail.

I think that problems lies in the function util.callm or in httplib.HTTPConnection therefore I have also tried.

>>> track.util.opener = urllib2.build_opener(urllib2.ProxyHandler(),track.util.MyBaseHandler(), track.util.MyErrorProcessor())
stowell commented 12 years ago

Have you successfully connected to other sites through the proxy using urllib2?