Merge lp:~jelmer/lptools/specify-instance into lp:lptools

Proposed by Jelmer Vernooij
Status: Merged
Approved by: Jelmer Vernooij
Approved revision: 27
Merged at revision: 31
Proposed branch: lp:~jelmer/lptools/specify-instance
Merge into: lp:lptools
Diff against target: 32 lines (+8/-2)
1 file modified
lptools/config.py (+8/-2)
To merge this branch: bzr merge lp:~jelmer/lptools/specify-instance
Reviewer Review Type Date Requested Status
Martin Pool Approve
Review via email: mp+73682@code.launchpad.net

Description of the change

Support a LPINSTANCE environment variable.

Something similar (UBUNTUTOOLS_LPINSTANCE) was supported by the tools we imported from ubuntu-tools.

To post a comment you must log in.
Revision history for this message
Martin Pool (mbp) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lptools/config.py'
2--- lptools/config.py 2011-08-29 14:21:32 +0000
3+++ lptools/config.py 2011-09-01 15:43:23 +0000
4@@ -23,6 +23,7 @@
5 "get_launchpad",
6 ]
7
8+import os
9 import os.path
10
11 from launchpadlib.launchpad import Launchpad
12@@ -34,7 +35,7 @@
13 os.makedirs(dir)
14
15
16-def get_launchpad(appname):
17+def get_launchpad(appname, instance=None):
18 """Get a login to launchpad for lptools caching in cachedir.
19
20 Note that caching is not multiple-process safe in launchpadlib,
21@@ -42,5 +43,10 @@
22
23 :param appname: The name of the app used to create per-app
24 cachedirs.
25+ :param instance: Launchpad instance to use
26 """
27- return Launchpad.login_with("lptools-%s" % appname, "production")
28+ if instance is None:
29+ instance = os.getenv("LPINSTANCE")
30+ if instance is None:
31+ instance = "production"
32+ return Launchpad.login_with("lptools-%s" % appname, instance)

Subscribers

People subscribed via source and target branches