Merge lp:~lifeless/python-oops-datedir-repo/bug-1003627 into lp:python-oops-datedir-repo

Proposed by Robert Collins on 2012-09-26
Status: Merged
Merged at revision: 43
Proposed branch: lp:~lifeless/python-oops-datedir-repo/bug-1003627
Merge into: lp:python-oops-datedir-repo
Diff against target: 86 lines (+24/-9)
2 files modified
NEWS (+5/-0)
oops_datedir_repo/prune.py (+19/-9)
To merge this branch: bzr merge lp:~lifeless/python-oops-datedir-repo/bug-1003627
Reviewer Review Type Date Requested Status
Steve Kowalik (community) code 2012-09-26 Approve on 2012-09-26
Review via email: mp+126392@code.launchpad.net

Description of the Change

Implement a feature request around pruning - support pruning multiple projects or project groups at once. The core already handled this mostly, so it was trivial. I haven't reduced test coverage at all.

To post a comment you must log in.
Steve Kowalik (stevenk) :
review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'NEWS'
2--- NEWS 2012-09-26 06:35:34 +0000
3+++ NEWS 2012-09-26 06:59:20 +0000
4@@ -6,6 +6,11 @@
5 NEXT
6 ----
7
8+* prune now supports passing multiple projects and or project groups
9+ in one invocation. For API compatibility, the parameters are type inspected,
10+ in a future release passing strings will be deprecated or removed.
11+ (Robert Collins, #1003627)
12+
13 * The legacy uniquefileallocator code path has been dropped, fixing
14 the bugs associated with its flawed design. As a result the
15 instance_id parameter to DateDirRepo.__init__ has been dropped.
16
17=== modified file 'oops_datedir_repo/prune.py'
18--- oops_datedir_repo/prune.py 2012-09-18 07:40:15 +0000
19+++ oops_datedir_repo/prune.py 2012-09-26 06:59:20 +0000
20@@ -47,12 +47,23 @@
21
22 def find_oops_references(self, start_time, end_time, project=None,
23 projectgroup=None):
24+ """Find oops references from start_time to end_time.
25+
26+ :param project: Either None or a project name, or a list of projects.
27+ :param projectgroup: Either None or a project group name or a list
28+ of project group names.
29+ """
30 projects = set([])
31 if project is not None:
32- projects.add(project)
33+ if type(project) is not list:
34+ project = [project]
35+ projects.update(project)
36 if projectgroup is not None:
37- [projects.add(lp_proj.name)
38- for lp_proj in self.lp.project_groups[projectgroup].projects]
39+ if type(projectgroup) is not list:
40+ projectgroup = [projectgroup]
41+ for group in projectgroup:
42+ [projects.add(lp_proj.name)
43+ for lp_proj in self.lp.project_groups[group].projects]
44 result = set()
45 lp_projects = self.lp.projects
46 one_week = datetime.timedelta(weeks=1)
47@@ -82,7 +93,7 @@
48 The following options must be supplied:
49 --repo
50
51- And either
52+ And at least one of either
53 --project
54 or
55 --projectgroup
56@@ -92,6 +103,8 @@
57
58 Will process every member project of launchpad-project.
59
60+ --project and --projectgroup can be supplied multiple times.
61+
62 When run this program will ask Launchpad for OOPS references made since
63 the last date it pruned up to, with an upper limit of one week from
64 today. It then looks in the repository for all oopses created during
65@@ -103,9 +116,9 @@
66 "Delete OOPS reports that are not referenced in a bug tracker."
67 parser = optparse.OptionParser(
68 description=description, usage=usage)
69- parser.add_option('--project',
70+ parser.add_option('--project', action="append",
71 help="Launchpad project to find references in.")
72- parser.add_option('--projectgroup',
73+ parser.add_option('--projectgroup', action="append",
74 help="Launchpad project group to find references in.")
75 parser.add_option('--repo', help="Path to the repository to read from.")
76 parser.add_option(
77@@ -122,9 +135,6 @@
78 else:
79 raise ValueError(
80 'One of options %s must be supplied' % (optnames,))
81- elif len(present) != 1:
82- raise ValueError(
83- 'Only one of options %s can be supplied' % (optnames,))
84 needed('repo')
85 needed('project', 'projectgroup')
86 logging.basicConfig(

Subscribers

People subscribed via source and target branches

to all changes: