Merge lp:~fboucault/laika/improved_lp_username_detection into lp:laika

Proposed by Florian Boucault
Status: Merged
Merged at revision: 6
Proposed branch: lp:~fboucault/laika/improved_lp_username_detection
Merge into: lp:laika
Diff against target: 51 lines (+14/-5)
1 file modified
laika.py (+14/-5)
To merge this branch: bzr merge lp:~fboucault/laika/improved_lp_username_detection
Reviewer Review Type Date Requested Status
Alex Chiang Pending
Review via email: mp+32914@code.launchpad.net
To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'laika.py'
2--- laika.py 2010-07-17 15:17:34 +0000
3+++ laika.py 2010-08-17 19:02:38 +0000
4@@ -13,7 +13,8 @@
5
6 import datetime
7 from optparse import OptionParser
8-import os
9+import ConfigParser
10+import os, os.path
11 import re
12 import sys
13
14@@ -37,7 +38,7 @@
15 bugs = {}
16
17 def __init__(self, user, window):
18- cachedir = "/home/" + user + "/.launchpadlib/cache/"
19+ cachedir = os.path.expanduser("~/.launchpadlib/cache")
20 self.launchpad = Launchpad.login_with('laika', 'production', cachedir)
21
22 self.user = self.launchpad.people[user]
23@@ -136,17 +137,25 @@
24 self.print_comments()
25 self.print_reported()
26
27+def get_launchpad_username_from_bazaar():
28+ bazaar_config = ConfigParser.ConfigParser()
29+ bazaar_config.read(os.path.expanduser("~/.bazaar/bazaar.conf"))
30+ return bazaar_config.get("DEFAULT", "launchpad_username")
31
32 def main():
33+ try:
34+ default_user = get_launchpad_username_from_bazaar()
35+ except ConfigParser.NoOptionError:
36+ default_user = os.getenv("USER")
37
38 parser = OptionParser()
39 parser.add_option('-u', '--user', dest='user',
40- default=os.getenv('USER'),
41+ default=default_user,
42 help='Specify the Launchpad user id. '
43- 'Defaults to authenticated token owner.')
44+ 'Defaults to launchpad username from Bazaar or session username.')
45 parser.add_option('-w', '--window', dest='window', type='int',
46 default=8,
47- help='Number af days of past activity to look for. '
48+ help='Number of days of past activity to look for. '
49 'Defaults to 8 days')
50
51 options, arguments = parser.parse_args()

Subscribers

People subscribed via source and target branches