1. Problem
  2. Solution

Problem might, from time to time, and hopefully not that often, send emails that look similar to this one:

Traceback (most recent call last):
 File "/srv/",
line 46, in <module>
   linaro = lp.people['linaro']
 File "/usr/lib/pymodules/python2.6/lazr/restfulclient/",
line 912, in __getitem__
 File "/usr/lib/pymodules/python2.6/lazr/restfulclient/",
line 316, in get
   response, content = self._request(url, extra_headers=headers)
 File "/usr/lib/pymodules/python2.6/lazr/restfulclient/",
line 306, in _request
   raise HTTPError(response, content)
lazr.restfulclient.errors.HTTPError: HTTP Error 401: Unauthorized
Response headers:
content-length: 37
content-type: text/plain
date: Thu, 17 May 2012 03:03:02 GMT
server: zope.server.http (HTTP)
status: 401
vary: Accept-Encoding
via: 1.1
x-powered-by: Zope (, Python (
Response body:
Expired token (hm7kZRmcQRqmjvB3XZPP).

The problem is tied to the Launchpad OAuth token used by a cron job (specifically the cron job that runs located in apps/patchmetrics/bin).


In order to fix this problem, it is necessary to create a new OAuth token, and send the credentials to Canonical IS.

To create a new token, that must be confirmed using a web browser, better using the linaro-patches Launchpad account (if you do not have the login credentials, please ask the Infrastructure Team), it is possible to use the following script:

   1 from launchpadlib.launchpad import Launchpad
   2 import launchpadlib.uris
   3 lp = Launchpad.get_token_and_login('linaro-patches', 
   4                                    service_root=
   5                                    launchpadlib.uris.LPNET_SERVICE_ROOT)
   6 lp.credentials.save_to_path('/tmp/patchwork-linaro-lplib.credentials')

After the Launchpad.get_token_and_login() istruction, python should show the Launchpad link for confirming the new token (and also a new window in your browser should be opened). At this time it would be better to use the credentials of the linaro-patches account to login into Launchpad and approve the request.

The newly created token, once save to file, has to be placed at this path on the server:

  • /var/local/patchwork-linaro-lplib.credentials

Platform/Systems/PatchmetricsTokenExpiration (last modified 2014-06-24 17:47:30)