~james-w/udd/management-commands

« back to all changes in this revision

Viewing changes to udd/lpapi.py

  • Committer: James Westby
  • Date: 2011-12-13 21:09:23 UTC
  • mfrom: (557.1.1 drop_email_failures)
  • Revision ID: james.westby@canonical.com-20111213210923-tfrirlx3xbwmi70u
Merged drop_email_failures into management-commands.

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
from launchpadlib.errors import HTTPError
19
19
from launchpadlib.launchpad import Launchpad
20
20
 
21
 
from udd.paths import paths
22
 
 
23
21
 
24
22
# Launchpadlib has unfortunately varied the semantics of the service root 
25
23
# parameter in a slightly complex way over time (see bug 819910).  bzrlib
27
25
SERVICE_ROOT = LAUNCHPAD_API_URLS['production']
28
26
 
29
27
 
 
28
from udd import iconfig
 
29
conf = iconfig.ImporterStack()
 
30
 
 
31
 
30
32
def get_lp(cache=None):
31
 
 
32
 
    if os.path.exists(paths.lp_creds_file):
 
33
    lp_creds_file = conf.get('pi.lp_creds_file')
 
34
    if os.path.exists(lp_creds_file):
33
35
        credentials = Credentials()
34
 
        credentials.load(file(paths.lp_creds_file, "r"))
 
36
        credentials.load(file(lp_creds_file, "r"))
35
37
        # Additional parameters, without default values, were inserted into the
36
38
        # Launchpad object's __init__ method signature in launchpadlib 1.9.0.
37
39
        # To be compatible with old and new versions of launchpadlib, we must
52
54
        # TODO: If using a launchpadlib new enough to use gnome-keyring,
53
55
        # kwallet, etc. this results in extracting the credentials from the
54
56
        # protected store and writing them to disk!
55
 
        launchpad.credentials.save(file(paths.lp_creds_file, "w"))
 
57
        launchpad.credentials.save(file(lp_creds_file, "w"))
56
58
    preload_root_objects(launchpad)
57
59
    return launchpad
58
60
 
216
218
            # an unknown way. Refresh its representation.
217
219
            operation.resource.lp_refresh()
218
220
        return operation._handle_200_response(url, response, content)
219
 
        
220
 
        
 
221
 
 
222
 
221
223
def preload_root_objects(lp):
222
224
    """Cache our own copies of some important Launchpadlib proxy objects.
223
225