launchpadlib doesn't support system proxy

Bug #938542 reported by Didier Roche-Tolomelli
38
This bug affects 8 people
Affects Status Importance Assigned to Milestone
launchpadlib
Fix Released
Low
Unassigned

Bug Description

Hi,
May I know what steps are needed to have "quickly release" work behind a proxy server:
I get the following message when executing quickly release
Get Launchpad Settings
Traceback (most recent call last):
  File "/usr/share/quickly/templates/ubuntu-application/release.py", line 116, in <module>
    launchpad = launchpadaccess.initialize_lpi()
  File "/usr/lib/python2.7/dist-packages/quickly/launchpadaccess.py", line 91, in initialize_lpi
    allow_access_levels=["WRITE_PRIVATE"])
  File "/usr/lib/python2.7/dist-packages/launchpadlib/launchpad.py", line 539, in login_with
    credential_save_failed, version)
  File "/usr/lib/python2.7/dist-packages/launchpadlib/launchpad.py", line 346, in _authorize_token_and_login
    credentials = authorization_engine(credentials, credential_store)
  File "/usr/lib/python2.7/dist-packages/launchpadlib/credentials.py", line 488, in __call__
    request_token_string = self.get_request_token(credentials)
  File "/usr/lib/python2.7/dist-packages/launchpadlib/credentials.py", line 505, in get_request_token
    token_format=Credentials.DICT_TOKEN_FORMAT)
  File "/usr/lib/python2.7/dist-packages/launchpadlib/credentials.py", line 135, in get_request_token
    url, method='POST', headers=headers, body=urlencode(params))
  File "/usr/lib/python2.7/dist-packages/httplib2/__init__.py", line 1436, in request
    (response, content) = self._request(conn, authority, uri, request_uri, method, body, headers, redirections, cachekey)
  File "/usr/lib/python2.7/dist-packages/httplib2/__init__.py", line 1188, in _request
    (response, content) = self._conn_request(conn, request_uri, method, body, headers)
  File "/usr/lib/python2.7/dist-packages/httplib2/__init__.py", line 1162, in _conn_request
    conn.connect()
  File "/usr/lib/python2.7/dist-packages/httplib2/__init__.py", line 925, in connect
    raise socket.error, msg
socket.error: [Errno 113] No route to host
ERROR: release command failed
Aborting

I am able to manually push the source onto launchpad using bzr (had to configure ssh to use corkscrew for this)

affects: quickly → launchpadlib
Changed in launchpadlib:
status: New → Triaged
Changed in launchpadlib:
importance: Undecided → High
Revision history for this message
Aaron Bentley (abentley) wrote :

AFAICT, Launchpadlib supports proxies, but it does not automatically use the system proxy.

Revision history for this message
Robert Collins (lifeless) wrote :

https proxy support in python required special handling in bzr; I suspect that it will here too.

Changed in launchpadlib:
importance: High → Low
Revision history for this message
Kenneth Chia (kennethchia-kh) wrote :

thanks all,
So is there a workaround or configuration I will need to modify for this to get it working with a proxy server? I'm using the same proxy server for http and https.

Revision history for this message
Britt Houser (britthouser) wrote :

We have had success using tsocks to make launchpadlib work behind a proxy.

I just did an 'apt-get install tsocks', and then edited /etc/tsocks.conf to point to our server and list address blocks which don't require proxy (hint, but sure to include the subnet the proxy is on in this list). Then just prepend your script with '/usr/bin/tsocks' and see if that works for you.

Revision history for this message
Dimitri John Ledkov (xnox) wrote :

This is ugly, how can I fix this properly?

Revision history for this message
Andreas Fester (andreas-fester) wrote :

This affected me while using Ubuntu's "backportpackage" script (not able to login_anonymously through a proxy). A simple fix which worked is to add the following code into Launchpad.__init__, before calling its super() method, to read proxy information from the http_proxy environment variable:

       if proxy_info is None:
           httpProxy = os.environ.get('http_proxy')
           if httpProxy is not None:
               o = urlparse.urlparse(httpProxy)
               proxy_info = httplib2.ProxyInfo(socks.PROXY_TYPE_HTTP, o.hostname, o.port)

If this is useful, I can also provide a real patch - any feedback welcome, in any case.

Revision history for this message
Dimitri John Ledkov (xnox) wrote :

This is fix released by mean of lazr.restfulclient 0.13.4

Changed in launchpadlib:
status: Triaged → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.