Merge lp:~lool/launchpad-work-items-tracker/fix-line-wrap-breakage into lp:~linaro-automation/launchpad-work-items-tracker/linaro
- fix-line-wrap-breakage
- Merge into linaro
Proposed by
Loïc Minier
Status: | Merged |
---|---|
Merged at revision: | 340 |
Proposed branch: | lp:~lool/launchpad-work-items-tracker/fix-line-wrap-breakage |
Merge into: | lp:~linaro-automation/launchpad-work-items-tracker/linaro |
Diff against target: |
179 lines (+48/-22) 1 file modified
collect (+48/-22) |
To merge this branch: | bzr merge lp:~lool/launchpad-work-items-tracker/fix-line-wrap-breakage |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Milo Casagrande (community) | Approve | ||
Review via email: mp+118092@code.launchpad.net |
Commit message
Description of the change
Latest changes have broken ./collect due to some copy-paste regression between staging and main linaro branch (sorry); this fixes it and also makes collect entirely PEP8 clean (some line too long warnings remained).
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 'collect' | |||
2 | --- collect 2012-07-10 16:24:31 +0000 | |||
3 | +++ collect 2012-08-03 13:24:24 +0000 | |||
4 | @@ -209,6 +209,7 @@ | |||
5 | 209 | 209 | ||
6 | 210 | 210 | ||
7 | 211 | def lp_import_blueprint_workitems(collector, bp, distro_release, | 211 | def lp_import_blueprint_workitems(collector, bp, distro_release, |
8 | 212 | people_cache=None, projects=None): | ||
9 | 212 | '''Collect work items from a Launchpad blueprint. | 213 | '''Collect work items from a Launchpad blueprint. |
10 | 213 | 214 | ||
11 | 214 | This includes work items from the whiteboard as well as linked bugs. | 215 | This includes work items from the whiteboard as well as linked bugs. |
12 | @@ -333,7 +334,8 @@ | |||
13 | 333 | member.name, team.name) | 334 | member.name, team.name) |
14 | 334 | if recursive or team.name in cfg.get('recursive_teams', []): | 335 | if recursive or team.name in cfg.get('recursive_teams', []): |
15 | 335 | _import_teams_recurse( | 336 | _import_teams_recurse( |
17 | 336 | collector, cfg, member, top_level_team_names + [member.name], | 337 | collector, cfg, member, |
18 | 338 | top_level_team_names + [member.name], | ||
19 | 337 | people_cache=people_cache, recursive=True) | 339 | people_cache=people_cache, recursive=True) |
20 | 338 | 340 | ||
21 | 339 | 341 | ||
22 | @@ -371,12 +373,14 @@ | |||
23 | 371 | blueprint.status = lp_project.summary or name | 373 | blueprint.status = lp_project.summary or name |
24 | 372 | collector.store_blueprint(blueprint) | 374 | collector.store_blueprint(blueprint) |
25 | 373 | 375 | ||
27 | 374 | for task in lp_project.searchTasks(status=bug_wi_states.keys(), **cfg['work_item_bugs']): | 376 | for task in lp_project.searchTasks(status=bug_wi_states.keys(), |
28 | 377 | **cfg['work_item_bugs']): | ||
29 | 375 | id = task.self_link.split('/')[-1] | 378 | id = task.self_link.split('/')[-1] |
30 | 376 | title = task.title.split('"', 1)[1].rstrip('"') | 379 | title = task.title.split('"', 1)[1].rstrip('"') |
31 | 377 | state = bug_wi_states[task.status] | 380 | state = bug_wi_states[task.status] |
32 | 378 | if state is None: | 381 | if state is None: |
34 | 379 | dbg('lp_import_bug_workitems: ignoring #%s: %s (status: %s)' % (id, title, task.status)) | 382 | dbg('lp_import_bug_workitems: ignoring #%s: %s (status: %s)' % ( |
35 | 383 | id, title, task.status)) | ||
36 | 380 | continue | 384 | continue |
37 | 381 | dbg('lp_import_bug_workitems: #%s: %s (%s)' % (id, title, state)) | 385 | dbg('lp_import_bug_workitems: #%s: %s (%s)' % (id, title, state)) |
38 | 382 | 386 | ||
39 | @@ -409,14 +413,17 @@ | |||
40 | 409 | milestones.extend([ms for ms in project.all_milestones]) | 413 | milestones.extend([ms for ms in project.all_milestones]) |
41 | 410 | 414 | ||
42 | 411 | if 'release' in cfg: | 415 | if 'release' in cfg: |
44 | 412 | lp_project = collector.lp.distributions['ubuntu'].getSeries(name_or_version=cfg['release']) | 416 | lp_project = collector.lp.distributions['ubuntu'].getSeries( |
45 | 417 | name_or_version=cfg['release']) | ||
46 | 413 | projects.append((lp_project, None)) | 418 | projects.append((lp_project, None)) |
47 | 414 | add_milestones(lp_project) | 419 | add_milestones(lp_project) |
48 | 415 | else: | 420 | else: |
50 | 416 | assert 'project' in cfg, 'Configuration needs to specify project or release' | 421 | assert 'project' in cfg, \ |
51 | 422 | 'Configuration needs to specify project or release' | ||
52 | 417 | lp_project = collector.lp.projects[cfg['project']] | 423 | lp_project = collector.lp.projects[cfg['project']] |
53 | 418 | if 'project_series' in cfg: | 424 | if 'project_series' in cfg: |
55 | 419 | lp_project_series = lp_project.getSeries(name=cfg['project_series']) | 425 | lp_project_series = lp_project.getSeries( |
56 | 426 | name=cfg['project_series']) | ||
57 | 420 | add_milestones(lp_project_series) | 427 | add_milestones(lp_project_series) |
58 | 421 | else: | 428 | else: |
59 | 422 | lp_project_series = None | 429 | lp_project_series = None |
60 | @@ -482,10 +489,12 @@ | |||
61 | 482 | 489 | ||
62 | 483 | for project, series in projects: | 490 | for project, series in projects: |
63 | 484 | # XXX: should this be valid_ or all_specifications? | 491 | # XXX: should this be valid_ or all_specifications? |
65 | 485 | project_spec_group_matcher = spec_group_matchers.get(project.name, None) | 492 | project_spec_group_matcher = spec_group_matchers.get(project.name, |
66 | 493 | None) | ||
67 | 486 | project_bps = project.valid_specifications | 494 | project_bps = project.valid_specifications |
68 | 487 | for bp in project_bps: | 495 | for bp in project_bps: |
70 | 488 | if name_pattern is not None and re.search(name_pattern, bp.name) is None: | 496 | if name_pattern is not None and \ |
71 | 497 | re.search(name_pattern, bp.name) is None: | ||
72 | 489 | continue | 498 | continue |
73 | 490 | if project_spec_group_matcher is not None: | 499 | if project_spec_group_matcher is not None: |
74 | 491 | match = re.search(project_spec_group_matcher, bp.name) | 500 | match = re.search(project_spec_group_matcher, bp.name) |
75 | @@ -500,7 +509,8 @@ | |||
76 | 500 | add_blueprint(bp) | 509 | add_blueprint(bp) |
77 | 501 | if series is not None: | 510 | if series is not None: |
78 | 502 | for bp in series.valid_specifications: | 511 | for bp in series.valid_specifications: |
80 | 503 | if name_pattern is not None and re.search(name_pattern, bp.name) is None: | 512 | if name_pattern is not None and \ |
81 | 513 | re.search(name_pattern, bp.name) is None: | ||
82 | 504 | continue | 514 | continue |
83 | 505 | if project_spec_group_matcher is not None: | 515 | if project_spec_group_matcher is not None: |
84 | 506 | match = re.search(project_spec_group_matcher, bp.name) | 516 | match = re.search(project_spec_group_matcher, bp.name) |
85 | @@ -596,7 +606,8 @@ | |||
86 | 596 | else: | 606 | else: |
87 | 597 | status_search = fields[2:] | 607 | status_search = fields[2:] |
88 | 598 | for f in status_search: | 608 | for f in status_search: |
90 | 599 | if u'DONE' in f or u'POSTPONED' in f or u'TODO' in f or u'INPROGRESS' in f or u'BLOCKED' in f: | 609 | if u'DONE' in f or u'POSTPONED' in f or u'TODO' in f or \ |
91 | 610 | u'INPROGRESS' in f or u'BLOCKED' in f: | ||
92 | 600 | ff = f.split() | 611 | ff = f.split() |
93 | 601 | if len(ff) == 2: | 612 | if len(ff) == 2: |
94 | 602 | assignee = ff[1] | 613 | assignee = ff[1] |
95 | @@ -645,14 +656,17 @@ | |||
96 | 645 | for url, default_assignee in cfg.get('moin_pages', {}).iteritems(): | 656 | for url, default_assignee in cfg.get('moin_pages', {}).iteritems(): |
97 | 646 | url = unicode_or_None(url) | 657 | url = unicode_or_None(url) |
98 | 647 | default_assignee = unicode_or_None(default_assignee) | 658 | default_assignee = unicode_or_None(default_assignee) |
101 | 648 | dbg('moin_import(): processing %s (default assignee: %s)' % (url, default_assignee)) | 659 | dbg('moin_import(): processing %s (default assignee: %s)' % ( |
102 | 649 | for group, status, items in get_moin_workitems_group(url, default_assignee): | 660 | url, default_assignee)) |
103 | 661 | for group, status, items in get_moin_workitems_group(url, | ||
104 | 662 | default_assignee): | ||
105 | 650 | url_clean = url.replace('?action=raw', '') | 663 | url_clean = url.replace('?action=raw', '') |
106 | 651 | name = url_clean.split('://', 1)[1].split('/', 1)[1] | 664 | name = url_clean.split('://', 1)[1].split('/', 1)[1] |
107 | 652 | if group: | 665 | if group: |
108 | 653 | name += u' ' + group | 666 | name += u' ' + group |
109 | 654 | spec_url = u'%s#%s' % (url_clean, escape_url(group)) | 667 | spec_url = u'%s#%s' % (url_clean, escape_url(group)) |
111 | 655 | dbg(' got group %s: name="%s", url="%s"' % (group, name, spec_url)) | 668 | dbg(' got group %s: name="%s", url="%s"' % ( |
112 | 669 | group, name, spec_url)) | ||
113 | 656 | else: | 670 | else: |
114 | 657 | spec_url = url_clean | 671 | spec_url = url_clean |
115 | 658 | dbg(' no group: name="%s", url="%s"' % (name, spec_url)) | 672 | dbg(' no group: name="%s", url="%s"' % (name, spec_url)) |
116 | @@ -691,7 +705,8 @@ | |||
117 | 691 | optparser.add_option('-c', '--config', | 705 | optparser.add_option('-c', '--config', |
118 | 692 | help='Path to configuration file', dest='config', metavar='PATH') | 706 | help='Path to configuration file', dest='config', metavar='PATH') |
119 | 693 | optparser.add_option('-p', '--pattern', metavar='REGEX', | 707 | optparser.add_option('-p', '--pattern', metavar='REGEX', |
121 | 694 | help='Regex pattern for blueprint name (optional, mainly for testing)', dest='pattern') | 708 | help='Regex pattern for blueprint name (optional, mainly for testing)', |
122 | 709 | dest='pattern') | ||
123 | 695 | optparser.add_option('--debug', action='store_true', default=False, | 710 | optparser.add_option('--debug', action='store_true', default=False, |
124 | 696 | help='Enable debugging output in parsing routines') | 711 | help='Enable debugging output in parsing routines') |
125 | 697 | optparser.add_option('--mail', action='store_true', default=False, | 712 | optparser.add_option('--mail', action='store_true', default=False, |
126 | @@ -729,24 +744,30 @@ | |||
127 | 729 | project_name = error.get_project_name() | 744 | project_name = error.get_project_name() |
128 | 730 | if project_name is not None: | 745 | if project_name is not None: |
129 | 731 | addresses = cfg['project_notification_addresses'][project_name] | 746 | addresses = cfg['project_notification_addresses'][project_name] |
132 | 732 | dbg('spec %s is targetted to "%s", mailing to %s' % (error.get_blueprint_name(), | 747 | dbg('spec %s is targetted to "%s", mailing to %s' % ( |
133 | 733 | project_name, ', '.join(addresses))) | 748 | error.get_blueprint_name(), project_name, |
134 | 749 | ', '.join(addresses))) | ||
135 | 734 | for a in addresses: | 750 | for a in addresses: |
136 | 735 | emails.setdefault(a, '') | 751 | emails.setdefault(a, '') |
137 | 736 | emails[a] += error.format_for_display() + '\n' | 752 | emails[a] += error.format_for_display() + '\n' |
138 | 737 | else: | 753 | else: |
140 | 738 | print >> sys.stderr, error.format_for_display(), '(no error_contact pattern)' | 754 | print >> sys.stderr, error.format_for_display(), \ |
141 | 755 | '(no error_contact pattern)' | ||
142 | 739 | 756 | ||
143 | 740 | # send mails | 757 | # send mails |
144 | 741 | for addr, contents in emails.iteritems(): | 758 | for addr, contents in emails.iteritems(): |
145 | 742 | msg = MIMEText(contents.encode('ascii', 'replace')) | 759 | msg = MIMEText(contents.encode('ascii', 'replace')) |
146 | 743 | msg['Subject'] = 'Errors in work item definitions' | 760 | msg['Subject'] = 'Errors in work item definitions' |
148 | 744 | msg['From'] = 'Launchpad work item tracker <work-items-tracker-hackers@lists.launchpad.net>' | 761 | msg['From'] = 'Launchpad work item tracker ' + \ |
149 | 762 | '<work-items-tracker-hackers@lists.launchpad.net>' | ||
150 | 745 | msg['To'] = addr | 763 | msg['To'] = addr |
151 | 746 | s = smtplib.SMTP() | 764 | s = smtplib.SMTP() |
152 | 747 | s.connect() | 765 | s.connect() |
155 | 748 | s.sendmail(os.environ.get('EMAIL', pwd.getpwuid(os.geteuid()).pw_name + '@localhost'), | 766 | s.sendmail(os.environ.get( |
156 | 749 | addr, msg.as_string()) | 767 | 'EMAIL', |
157 | 768 | pwd.getpwuid(os.geteuid()).pw_name + '@localhost'), | ||
158 | 769 | addr, | ||
159 | 770 | msg.as_string()) | ||
160 | 750 | s.quit() | 771 | s.quit() |
161 | 751 | 772 | ||
162 | 752 | 773 | ||
163 | @@ -793,9 +814,14 @@ | |||
164 | 793 | sys.exit(0) | 814 | sys.exit(0) |
165 | 794 | 815 | ||
166 | 795 | if "beta" in EDGE_SERVICE_ROOT: | 816 | if "beta" in EDGE_SERVICE_ROOT: |
168 | 796 | lp = Launchpad.login_with('ubuntu-work-items', service_root=EDGE_SERVICE_ROOT.replace("edge.", "").replace("beta", "devel")) | 817 | service_root = EDGE_SERVICE_ROOT |
169 | 818 | service_root = service_root.replace("edge.", "") | ||
170 | 819 | service_root = service_root.replace("beta", "devel") | ||
171 | 820 | lp = Launchpad.login_with('ubuntu-work-items', | ||
172 | 821 | service_root=service_root) | ||
173 | 797 | else: | 822 | else: |
175 | 798 | lp = Launchpad.login_with('ubuntu-work-items', service_root="production", version="devel") | 823 | lp = Launchpad.login_with('ubuntu-work-items', |
176 | 824 | service_root="production", version="devel") | ||
177 | 799 | 825 | ||
178 | 800 | store = get_store(opts.database) | 826 | store = get_store(opts.database) |
179 | 801 | collector = CollectorStore(store, lp, error_collector) | 827 | collector = CollectorStore(store, lp, error_collector) |
Looks good, merging now.