~jelmer/lptools/lp-attach

« back to all changes in this revision

Viewing changes to lptools/config.py

  • Committer: Jelmer Vernooij
  • Date: 2011-11-03 12:43:17 UTC
  • mfrom: (26.1.1 trunk)
  • Revision ID: jelmer@samba.org-20111103124317-pzuq9mbjo6x2sofn
Merge support for specifying lp instance to use using environment variable.

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
    "get_launchpad",
24
24
    ]
25
25
 
 
26
import os
26
27
import os.path
27
28
 
28
29
from launchpadlib.launchpad import Launchpad
34
35
        os.makedirs(dir)
35
36
 
36
37
 
37
 
def get_launchpad(appname):
 
38
def get_launchpad(appname, instance=None):
38
39
    """Get a login to launchpad for lptools caching in cachedir.
39
40
    
40
41
    Note that caching is not multiple-process safe in launchpadlib,
42
43
 
43
44
    :param appname: The name of the app used to create per-app
44
45
        cachedirs.
 
46
    :param instance: Launchpad instance to use
45
47
    """
46
 
    return Launchpad.login_with("lptools-%s" % appname, "production")
 
48
    if instance is None:
 
49
        instance = os.getenv("LPINSTANCE")
 
50
    if instance is None:
 
51
        instance = "production"
 
52
    return Launchpad.login_with("lptools-%s" % appname, instance)