Merge lp:~milo/launchpad-work-items-tracker/bug1017878 into lp:~linaro-automation/launchpad-work-items-tracker/linaro

Proposed by Данило Шеган
Status: Merged
Approved by: Данило Шеган
Approved revision: 336
Merged at revision: 336
Proposed branch: lp:~milo/launchpad-work-items-tracker/bug1017878
Merge into: lp:~linaro-automation/launchpad-work-items-tracker/linaro
Diff against target: 213 lines (+43/-29)
2 files modified
collect (+32/-14)
lpworkitems/collect.py (+11/-15)
To merge this branch: bzr merge lp:~milo/launchpad-work-items-tracker/bug1017878
Reviewer Review Type Date Requested Status
Данило Шеган (community) Approve
Review via email: mp+112805@code.launchpad.net

Description of the change

Paraphrasing Milo from https://code.launchpad.net/~milo/launchpad-work-items-tracker/bug1017878/+merge/112784

"Hi,

the following branch should fix bug 1017878. I basically applied an old Danilo patch: what we are doing now is storing in the DB the new milestone, if it is not there already.

I fixed also some PEP8 warnings, but definitely not all."

To post a comment you must log in.
Revision history for this message
Данило Шеган (danilo) wrote :

Thanks for all the pep8 fixes as well, looks good!

review: Approve
Revision history for this message
Milo Casagrande (milo) wrote :

Hey Danilo, thanks for moving this MP here!

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'collect'
2--- collect 2012-03-26 11:42:08 +0000
3+++ collect 2012-06-29 16:13:29 +0000
4@@ -6,13 +6,25 @@
5 # Copyright (C) 2010, 2011 Canonical Ltd.
6 # License: GPL-3
7
8-import urllib, re, sys, optparse, smtplib, pwd, os, urlparse
9+import urllib
10+import re
11+import sys
12+import optparse
13+import smtplib
14+import pwd
15+import os
16+import urlparse
17 import logging
18 from email.mime.text import MIMEText
19
20 from launchpadlib.launchpad import Launchpad, EDGE_SERVICE_ROOT
21
22-from lpworkitems.collect import CollectorStore, PersonCache, WorkitemParser, bug_wi_states
23+from lpworkitems.collect import (
24+ CollectorStore,
25+ PersonCache,
26+ WorkitemParser,
27+ bug_wi_states
28+)
29 from lpworkitems.database import get_store
30 from lpworkitems.error_collector import (
31 BlueprintURLError,
32@@ -65,6 +77,8 @@
33
34 import simplejson
35 _orig_loads = simplejson.loads
36+
37+
38 def loads(something):
39 return _orig_loads(unicode_or_None(something))
40 simplejson.loads = loads
41@@ -119,9 +133,9 @@
42 add_dependencies(collector, model_group.name, deps)
43 return model_group
44
45+
46 def parse_meta_item(collector, line, bp_name):
47 '''Parse a meta information line from a blueprint
48-
49 '''
50
51 line = line.strip()
52@@ -130,13 +144,13 @@
53
54 try:
55 (key, value) = line.rsplit(':', 1)
56- key = key.strip()
57+ key = key.strip()
58 value = value.strip()
59 except ValueError:
60 dbg("\tMeta line '%s' can not be parsed" % line)
61 return
62
63- dbg( "\t\tMeta for %s: key='%s' value='%s'" % (bp_name, key, value) )
64+ dbg("\t\tMeta for %s: key='%s' value='%s'" % (bp_name, key, value))
65 collector.store_meta(key, value, bp_name)
66
67
68@@ -149,9 +163,9 @@
69
70 dbg("\tParsing complexity line '%s'" % line)
71
72- num = None
73- milestone = None
74- assignee = None
75+ num = None
76+ milestone = None
77+ assignee = None
78
79 try:
80 complexity_list = line.split()
81@@ -181,6 +195,7 @@
82 return word
83 return None
84
85+
86 def lp_import_blueprint_workitems(collector, bp, distro_release, people_cache=None, projects=None):
87 '''Collect work items from a Launchpad blueprint.
88
89@@ -489,7 +504,6 @@
90 deps[possible_dep] = possible_deps[possible_dep]
91 if deps:
92 lp_import_spec_group(collector, spec_group, area, deps)
93-
94 lp_import_bug_workitems(lp_project, collector, cfg)
95
96
97@@ -537,7 +551,8 @@
98 if in_section:
99 result.append([name, status, section])
100 fields = line.strip().split(u'==')
101- assert not fields[0] # should be empty
102+ # should be empty
103+ assert not fields[0]
104 name = fields[1].strip()
105 section = []
106 collect = 1
107@@ -547,7 +562,8 @@
108 in_section = True
109 collect = 0
110 fields = line.strip().split(u'||')
111- assert not fields[0] # should be empty
112+ # should be empty
113+ assert not fields[0]
114 assignee = default_assignee
115 istatus = u'todo'
116 milestone = None
117@@ -559,7 +575,7 @@
118 desc = fields[which].strip()
119 if u'status' in field_off:
120 which = field_off[u'status']
121- status_search = [ fields[which] ]
122+ status_search = [fields[which]]
123 else:
124 status_search = fields[2:]
125 for f in status_search:
126@@ -676,10 +692,11 @@
127
128 return opts, args
129
130+
131 def send_error_mails(cfg):
132 '''Send data_errors to contacts.
133
134- Data error contacts are defined in the configuration in the
135+ Data error contacts are defined in the configuration in the
136 "project_notification_addresses" map (which assigns project names to a list
137 of email addresses). If no address list for a project is found, the error
138 goes to stderr.
139@@ -687,7 +704,8 @@
140 global error_collector
141
142 # sort errors into address buckets
143- emails = {} # email address -> contents
144+ # email address -> contents
145+ emails = {}
146
147 dbg('mailing %i data errors' % len(error_collector.errors))
148 for error in error_collector.errors:
149
150=== modified file 'lpworkitems/collect.py'
151--- lpworkitems/collect.py 2012-03-05 14:32:43 +0000
152+++ lpworkitems/collect.py 2012-06-29 16:13:29 +0000
153@@ -26,6 +26,7 @@
154 # "interesting")
155 workitem_precedence = [None, u'done', u'postponed', u'blocked', u'todo', u'inprogress']
156
157+
158 class PersonCache(object):
159 """A cache of Launchpad accounts."""
160
161@@ -91,7 +92,7 @@
162 project_name = self.lp.load(milestone.target.self_link).name
163 existing_milestone = self.store.find(
164 models.Milestone,
165- models.Milestone.name==milestone_name).any()
166+ models.Milestone.name == milestone_name).any()
167 if existing_milestone is not None:
168 # TODO: We now allow for the same milestone in different projects
169 # to have different due dates (within reasonable limits).
170@@ -107,19 +108,13 @@
171 if isinstance(existing_target_date, datetime.date):
172 existing_target_date = existing_target_date.strftime("%Y-%m")
173 if (target_date and existing_target_date != target_date):
174- error = MilestoneError(
175- milestone,
176- "Milestone %s in project %s has due_date %s, but project %s "
177- "already had the due date as %s" % (milestone.name, project_name,
178- target_date, existing_milestone.project,
179- existing_target_date))
180-# self.error_collector.store_error(error)
181- return
182- db_milestone = models.Milestone()
183- db_milestone.name = milestone_name
184- db_milestone.due_date = milestone.date_targeted
185- db_milestone.project = project_name
186- self.store.add(db_milestone)
187+ existing_milestone.due_date = milestone.date_targeted
188+ else:
189+ db_milestone = models.Milestone()
190+ db_milestone.name = milestone_name
191+ db_milestone.due_date = milestone.date_targeted
192+ db_milestone.project = project_name
193+ self.store.add(db_milestone)
194
195 def store_lp_milestones(self, milestones):
196 if self.store.find(models.Milestone).any() is not None:
197@@ -274,7 +269,7 @@
198 if ']' in desc:
199 off = desc.index(']')
200 assignee_name = desc[1:off]
201- desc = desc[off+1:].strip()
202+ desc = desc[off + 1:].strip()
203 else:
204 self.error_collector.record_blueprint_error(
205 self.blueprint,
206@@ -318,6 +313,7 @@
207 def get_workitem_if_tracked(self, task, projects=None,
208 distro_release=None):
209 target = self.lp.load(task.target.self_link)
210+
211 def get_rtype(obj):
212 return urllib.splittag(obj.resource_type_link)[1]
213 rtype = get_rtype(target)

Subscribers

People subscribed via source and target branches