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
=== modified file 'laika.py'
--- laika.py 2010-08-17 19:00:08 +0000
+++ laika.py 2010-10-11 22:45:57 +0000
@@ -11,10 +11,10 @@
11# This program is distributed under the terms of the11# This program is distributed under the terms of the
12# GNU General Public License version 2.12# GNU General Public License version 2.
1313
14import ConfigParser
14import datetime15import datetime
15from optparse import OptionParser16from optparse import OptionParser
16import ConfigParser17import os
17import os, os.path
18import re18import re
19import sys19import sys
2020
@@ -22,7 +22,6 @@
2222
23UTCNOW = datetime.datetime.utcnow()23UTCNOW = datetime.datetime.utcnow()
2424
25
26class Report(object):25class Report(object):
27 '''An activity report for a specified Launchpad user.26 '''An activity report for a specified Launchpad user.
2827
@@ -37,12 +36,13 @@
3736
38 bugs = {}37 bugs = {}
3938
40 def __init__(self, user, window):39 def __init__(self, user, window, ppas):
41 cachedir = os.path.expanduser("~/.launchpadlib/cache")40 cachedir = os.path.expanduser("~/.launchpadlib/cache")
42 self.launchpad = Launchpad.login_with('laika', 'production', cachedir)41 self.launchpad = Launchpad.login_with('laika', 'production', cachedir)
4342
44 self.user = self.launchpad.people[user]43 self.user = self.launchpad.people[user]
45 self.window = window44 self.window = window
45 self.ppas = ppas
4646
47 def print_header(self, header):47 def print_header(self, header):
48 print "==", header, "=="48 print "==", header, "=="
@@ -132,35 +132,91 @@
132 self.print_bugid(t)132 self.print_bugid(t)
133 print133 print
134134
135 def print_ppa_activity(self):
136 if self.ppas == '':
137 return
138
139 # Handle command line case, where user passes in comma-separated list
140 self.ppas = re.sub(",", "\n", self.ppas)
141
142 # Now each PPA is separated by a newline, which is how we might
143 # expect them if they're specified in the config file.
144 ppas = [p for p in self.ppas.split("\n") if p != '']
145
146 self.print_header("PPA Activity")
147 for ppa in ppas:
148 # A PPA seems to always belong to a person (or a team, which
149 # is a person in LP) so assuming "person/PPA" sounds reasonable.
150 person, archive = ppa.split('/')
151 owner = self.launchpad.people[person]
152 archive = owner.getPPAByName(name=archive)
153 sources = archive.getPublishedSources()
154
155 print ppa
156 for s in sources:
157 if s.package_signer != self.user:
158 continue
159
160 # There might be yet-unpublished packages in the PPA, which
161 # would then have NoneType for date_published. Don't check
162 # in_window in that case.
163 if s.date_published:
164 if self.in_window(s.date_published):
165 print "\t", s.display_name
166 print
167 print
168
135 def render(self):169 def render(self):
136 self.print_assignments()170 self.print_assignments()
137 self.print_comments()171 self.print_comments()
138 self.print_reported()172 self.print_reported()
139173 self.print_ppa_activity()
140def get_launchpad_username_from_bazaar():174
141 bazaar_config = ConfigParser.ConfigParser()175def get_config(opts):
142 bazaar_config.read(os.path.expanduser("~/.bazaar/bazaar.conf"))176 config = {}
143 return bazaar_config.get("DEFAULT", "launchpad_username")177 FORMAT = "1.0"
178 laika_config = ConfigParser.ConfigParser()
179 laika_config.read(os.path.expanduser("~/.laikarc"))
180
181 if laika_config.has_section(FORMAT) == False:
182 print "Error: unsupported configuration file format"
183 sys.exit()
184
185 def default_user():
186 return os.getenv("USER")
187 def default_window():
188 return 8
189 def default_ppas():
190 return ''
191
192 for opt in opts:
193 try:
194 config[opt] = laika_config.get(FORMAT, opt)
195 except ConfigParser.NoOptionError:
196 config[opt] = locals()["default_%s" % opt]()
197
198 return config
144199
145def main():200def main():
146 try:201 opts = ['user', 'window', 'ppas']
147 default_user = get_launchpad_username_from_bazaar()202 config = get_config(opts)
148 except ConfigParser.NoOptionError:
149 default_user = os.getenv("USER")
150203
151 parser = OptionParser()204 parser = OptionParser()
152 parser.add_option('-u', '--user', dest='user',205 parser.add_option('-u', '--user', dest='user',
153 default=default_user,206 default=config['user'],
154 help='Specify the Launchpad user id. '207 help='Specify the Launchpad user id. '
155 'Defaults to launchpad username from Bazaar or session username.')208 'Defaults to session username.')
156 parser.add_option('-w', '--window', dest='window', type='int',209 parser.add_option('-w', '--window', dest='window', type='int',
157 default=8,210 default=config['window'],
158 help='Number of days of past activity to look for. '211 help='Number of days of past activity to look for. '
159 'Defaults to 8 days')212 'Defaults to 8 days')
213 parser.add_option('--ppas', dest='ppas',
214 default=config['ppas'],
215 help='Search for activity in specified PPAs')
160216
161 options, arguments = parser.parse_args()217 options, arguments = parser.parse_args()
162218
163 report = Report(options.user, options.window)219 report = Report(options.user, options.window, options.ppas)
164 report.render()220 report.render()
165221
166if __name__ == "__main__":222if __name__ == "__main__":

Subscribers

People subscribed via source and target branches

to all changes: