~statik/hydrazine/packaging

« back to all changes in this revision

Viewing changes to capture-bug-counts.py

  • Committer: Martin Pool
  • Date: 2009-11-23 06:05:05 UTC
  • mto: This revision was merged to the branch mainline in revision 6.
  • Revision ID: mbp@sourcefrog.net-20091123060505-ad6v27pfk34sq34u
Start splitting out hydrazine helpers

Show diffs side-by-side

added added

removed removed

Lines of Context:
13
13
    EDGE_SERVICE_ROOT,
14
14
    )
15
15
 
 
16
import hydrazine
 
17
 
16
18
service_root = EDGE_SERVICE_ROOT
 
19
 
17
20
project_name = 'bzr'
18
21
 
19
22
 
 
23
 
20
24
def run_external(args):
21
25
    sys.stderr.write(">> %s\n" % args)
22
 
    rc = subprocess.call(args)
23
 
    if rc != 0:
 
26
    rc = subprocess.call(args)=    if rc != 0:
24
27
        sys.stderr.write("failed %s!" % rc)
25
28
        raise AssertionError()
26
29
 
49
52
## 
50
53
 
51
54
 
52
 
lplib_cachedir = os.path.expanduser("~/.cache/launchpadlib/")
53
 
hydrazine_cachedir = os.path.expanduser("~/.cache/hydrazine/")
54
 
rrd_dir = os.path.expanduser("~/.cache/hydrazine/rrd")
55
 
for d in [lplib_cachedir, hydrazine_cachedir, rrd_dir]:
56
 
    if not os.path.isdir(d):
57
 
        os.makedirs(d, mode=0700)
58
 
 
59
 
def create_session():
60
 
    hydrazine_credentials_filename = os.path.join(hydrazine_cachedir,
61
 
        'credentials')
62
 
    if os.path.exists(hydrazine_credentials_filename):
63
 
        credentials = Credentials()
64
 
        credentials.load(file(
65
 
            os.path.expanduser("~/.cache/hydrazine/credentials"),
66
 
            "r"))
67
 
        trace('loaded existing credentials')
68
 
        return Launchpad(credentials, service_root,
69
 
            lplib_cachedir)
70
 
        # TODO: handle the case of having credentials that have expired etc
71
 
    else:
72
 
        launchpad = Launchpad.get_token_and_login(
73
 
            'Hydrazine',
74
 
            service_root,
75
 
            lplib_cachedir)
76
 
        trace('saving credentials...')
77
 
        launchpad.credentials.save(file(
78
 
            hydrazine_credentials_filename,
79
 
            "w"))
80
 
        return launchpad
81
 
 
82
55
def get_project():
83
56
    sys.stderr.write('getting project... ')
84
57
    project = launchpad.projects[project_name]