~arand/hydrazine/lp-promote-ppa

« back to all changes in this revision

Viewing changes to hydrazine/__init__.py

  • Committer: Max Bowsher
  • Date: 2010-12-02 00:44:40 UTC
  • mfrom: (83.1.6 trunk)
  • Revision ID: maxb@f2s.com-20101202004440-sgsbwucq3x4p9v57
Miscellaneous tidyups. Includes not creating the redundant ~/.cache/hydrazine/rrd/ .

Show diffs side-by-side

added added

removed removed

Lines of Context:
11
11
    )
12
12
 
13
13
from launchpadlib.uris import (
14
 
    EDGE_SERVICE_ROOT,
15
14
    LPNET_SERVICE_ROOT,
16
 
    STAGING_SERVICE_ROOT,
17
15
    )
18
16
 
19
17
 
29
27
def create_session():
30
28
    lplib_cachedir = os.path.expanduser("~/.cache/launchpadlib/")
31
29
    hydrazine_cachedir = os.path.expanduser("~/.cache/hydrazine/")
32
 
    rrd_dir = os.path.expanduser("~/.cache/hydrazine/rrd")
33
 
    for d in [lplib_cachedir, hydrazine_cachedir, rrd_dir]:
 
30
    for d in [lplib_cachedir, hydrazine_cachedir]:
34
31
        if not os.path.isdir(d):
35
32
            os.makedirs(d, mode=0700)
36
33
 
37
 
 
38
34
    hydrazine_credentials_filename = os.path.join(hydrazine_cachedir,
39
35
        'credentials')
40
36
    if os.path.exists(hydrazine_credentials_filename):
41
37
        credentials = Credentials()
42
 
        credentials.load(file(
43
 
            os.path.expanduser("~/.cache/hydrazine/credentials"),
44
 
            "r"))
 
38
        credentials.load(file(hydrazine_credentials_filename, "r"))
45
39
        trace('loaded existing credentials')
46
40
        trace('connecting to %s' % service_root)
47
 
        return Launchpad(credentials, service_root,
48
 
            lplib_cachedir)
 
41
        return Launchpad(credentials, service_root, lplib_cachedir)
49
42
        # TODO: handle the case of having credentials that have expired etc
50
43
    else:
51
44
        launchpad = Launchpad.get_token_and_login(