Merge lp:~achiang/laika/ppa-activity into lp:laika

Proposed by Alex Chiang
Status: Superseded
Proposed branch: lp:~achiang/laika/ppa-activity
Merge into: lp:laika
Diff against target: 144 lines (+73/-17)
1 file modified
laika.py (+73/-17)
To merge this branch: bzr merge lp:~achiang/laika/ppa-activity
Reviewer Review Type Date Requested Status
Paul Hummer (community) code Approve
Review via email: mp+30232@code.launchpad.net

This proposal has been superseded by a proposal from 2010-10-13.

Description of the change

Add support for querying PPA activity.

The code itself is relatively straightforward, but I'm looking for feedback on "taste" here.

Not a fan of growing a command line option. On the other hand, I'm not sure what the best way to ask Launchpad:

"please tell me every package I uploaded to any archive"

This seemed like a good compromise.

Thoughts?

To post a comment you must log in.
Revision history for this message
Paul Hummer (rockstar) wrote :

So, I'm definitely good with this change, but I think a better solution would be trying to check up on all your ppa, regardless of which ppa it is (you can always remove erroneous reporting from your report before you send it off to your manager). Is there an API call that can provide this? If not, you should file a bug against Soyuz and request this be exposed. I'll push it on the people that need to fix it.

review: Approve (code)
Revision history for this message
Paul Hummer (rockstar) wrote :

What's the status of this merge now?

Revision history for this message
Alex Chiang (achiang) wrote :

I haven't landed it yet because I didn't want to introduce a command line option that might go away in the future (aka, once we/I figure out how to query all PPAs for activity).

Reasonable?

Revision history for this message
Paul Hummer (rockstar) wrote :

Sounds fine to me. I was just looking at my +activereviews and saw it and wondered where it was in the process.

lp:~achiang/laika/ppa-activity updated
7. By Alex Chiang

Do not attempt to find published date of un-published packages.

8. By Alex Chiang

Merge from lp:~achiang/laika/configparser

9. By Alex Chiang

Learn how to handle multiple PPAs

We now allow the user to specify multiple PPAs to search for activity.

On the command line, the syntax looks like:

 --ppas=ppa1,ppa2,ppaN

In the config file, the syntax looks like:

 ppas: ppa1,ppa2,ppaN

Or, for readability:

 ppas:
  ppa1
  ppa2
  ppaN

I prefer the second style, as PPA names tend to be long. Breaking them out
onto separate lines helps quite a bit with readability.

Unmerged revisions

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-08-17 19:00:08 +0000
3+++ laika.py 2010-10-11 22:45:57 +0000
4@@ -11,10 +11,10 @@
5 # This program is distributed under the terms of the
6 # GNU General Public License version 2.
7
8+import ConfigParser
9 import datetime
10 from optparse import OptionParser
11-import ConfigParser
12-import os, os.path
13+import os
14 import re
15 import sys
16
17@@ -22,7 +22,6 @@
18
19 UTCNOW = datetime.datetime.utcnow()
20
21-
22 class Report(object):
23 '''An activity report for a specified Launchpad user.
24
25@@ -37,12 +36,13 @@
26
27 bugs = {}
28
29- def __init__(self, user, window):
30+ def __init__(self, user, window, ppas):
31 cachedir = os.path.expanduser("~/.launchpadlib/cache")
32 self.launchpad = Launchpad.login_with('laika', 'production', cachedir)
33
34 self.user = self.launchpad.people[user]
35 self.window = window
36+ self.ppas = ppas
37
38 def print_header(self, header):
39 print "==", header, "=="
40@@ -132,35 +132,91 @@
41 self.print_bugid(t)
42 print
43
44+ def print_ppa_activity(self):
45+ if self.ppas == '':
46+ return
47+
48+ # Handle command line case, where user passes in comma-separated list
49+ self.ppas = re.sub(",", "\n", self.ppas)
50+
51+ # Now each PPA is separated by a newline, which is how we might
52+ # expect them if they're specified in the config file.
53+ ppas = [p for p in self.ppas.split("\n") if p != '']
54+
55+ self.print_header("PPA Activity")
56+ for ppa in ppas:
57+ # A PPA seems to always belong to a person (or a team, which
58+ # is a person in LP) so assuming "person/PPA" sounds reasonable.
59+ person, archive = ppa.split('/')
60+ owner = self.launchpad.people[person]
61+ archive = owner.getPPAByName(name=archive)
62+ sources = archive.getPublishedSources()
63+
64+ print ppa
65+ for s in sources:
66+ if s.package_signer != self.user:
67+ continue
68+
69+ # There might be yet-unpublished packages in the PPA, which
70+ # would then have NoneType for date_published. Don't check
71+ # in_window in that case.
72+ if s.date_published:
73+ if self.in_window(s.date_published):
74+ print "\t", s.display_name
75+ print
76+ print
77+
78 def render(self):
79 self.print_assignments()
80 self.print_comments()
81 self.print_reported()
82-
83-def get_launchpad_username_from_bazaar():
84- bazaar_config = ConfigParser.ConfigParser()
85- bazaar_config.read(os.path.expanduser("~/.bazaar/bazaar.conf"))
86- return bazaar_config.get("DEFAULT", "launchpad_username")
87+ self.print_ppa_activity()
88+
89+def get_config(opts):
90+ config = {}
91+ FORMAT = "1.0"
92+ laika_config = ConfigParser.ConfigParser()
93+ laika_config.read(os.path.expanduser("~/.laikarc"))
94+
95+ if laika_config.has_section(FORMAT) == False:
96+ print "Error: unsupported configuration file format"
97+ sys.exit()
98+
99+ def default_user():
100+ return os.getenv("USER")
101+ def default_window():
102+ return 8
103+ def default_ppas():
104+ return ''
105+
106+ for opt in opts:
107+ try:
108+ config[opt] = laika_config.get(FORMAT, opt)
109+ except ConfigParser.NoOptionError:
110+ config[opt] = locals()["default_%s" % opt]()
111+
112+ return config
113
114 def main():
115- try:
116- default_user = get_launchpad_username_from_bazaar()
117- except ConfigParser.NoOptionError:
118- default_user = os.getenv("USER")
119+ opts = ['user', 'window', 'ppas']
120+ config = get_config(opts)
121
122 parser = OptionParser()
123 parser.add_option('-u', '--user', dest='user',
124- default=default_user,
125+ default=config['user'],
126 help='Specify the Launchpad user id. '
127- 'Defaults to launchpad username from Bazaar or session username.')
128+ 'Defaults to session username.')
129 parser.add_option('-w', '--window', dest='window', type='int',
130- default=8,
131+ default=config['window'],
132 help='Number of days of past activity to look for. '
133 'Defaults to 8 days')
134+ parser.add_option('--ppas', dest='ppas',
135+ default=config['ppas'],
136+ help='Search for activity in specified PPAs')
137
138 options, arguments = parser.parse_args()
139
140- report = Report(options.user, options.window)
141+ report = Report(options.user, options.window, options.ppas)
142 report.render()
143
144 if __name__ == "__main__":

Subscribers

People subscribed via source and target branches

to all changes: