Merge lp:~lool/launchpad-work-items-tracker/fix-line-wrap-breakage into lp:~linaro-automation/launchpad-work-items-tracker/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
Reviewer Review Type Date Requested Status
Milo Casagrande (community) Approve
Review via email: mp+118092@code.launchpad.net

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.
Revision history for this message
Milo Casagrande (milo) wrote :

Looks good, merging now.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'collect'
--- collect 2012-07-10 16:24:31 +0000
+++ collect 2012-08-03 13:24:24 +0000
@@ -209,6 +209,7 @@
209209
210210
211def lp_import_blueprint_workitems(collector, bp, distro_release,211def lp_import_blueprint_workitems(collector, bp, distro_release,
212 people_cache=None, projects=None):
212 '''Collect work items from a Launchpad blueprint.213 '''Collect work items from a Launchpad blueprint.
213214
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.
@@ -333,7 +334,8 @@
333 member.name, team.name)334 member.name, team.name)
334 if recursive or team.name in cfg.get('recursive_teams', []):335 if recursive or team.name in cfg.get('recursive_teams', []):
335 _import_teams_recurse(336 _import_teams_recurse(
336 collector, cfg, member, top_level_team_names + [member.name],337 collector, cfg, member,
338 top_level_team_names + [member.name],
337 people_cache=people_cache, recursive=True)339 people_cache=people_cache, recursive=True)
338340
339341
@@ -371,12 +373,14 @@
371 blueprint.status = lp_project.summary or name373 blueprint.status = lp_project.summary or name
372 collector.store_blueprint(blueprint)374 collector.store_blueprint(blueprint)
373375
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(),
377 **cfg['work_item_bugs']):
375 id = task.self_link.split('/')[-1]378 id = task.self_link.split('/')[-1]
376 title = task.title.split('"', 1)[1].rstrip('"')379 title = task.title.split('"', 1)[1].rstrip('"')
377 state = bug_wi_states[task.status]380 state = bug_wi_states[task.status]
378 if state is None:381 if state is None:
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)' % (
383 id, title, task.status))
380 continue384 continue
381 dbg('lp_import_bug_workitems: #%s: %s (%s)' % (id, title, state))385 dbg('lp_import_bug_workitems: #%s: %s (%s)' % (id, title, state))
382386
@@ -409,14 +413,17 @@
409 milestones.extend([ms for ms in project.all_milestones])413 milestones.extend([ms for ms in project.all_milestones])
410414
411 if 'release' in cfg:415 if 'release' in cfg:
412 lp_project = collector.lp.distributions['ubuntu'].getSeries(name_or_version=cfg['release'])416 lp_project = collector.lp.distributions['ubuntu'].getSeries(
417 name_or_version=cfg['release'])
413 projects.append((lp_project, None))418 projects.append((lp_project, None))
414 add_milestones(lp_project)419 add_milestones(lp_project)
415 else:420 else:
416 assert 'project' in cfg, 'Configuration needs to specify project or release'421 assert 'project' in cfg, \
422 'Configuration needs to specify project or release'
417 lp_project = collector.lp.projects[cfg['project']]423 lp_project = collector.lp.projects[cfg['project']]
418 if 'project_series' in cfg:424 if 'project_series' in cfg:
419 lp_project_series = lp_project.getSeries(name=cfg['project_series'])425 lp_project_series = lp_project.getSeries(
426 name=cfg['project_series'])
420 add_milestones(lp_project_series)427 add_milestones(lp_project_series)
421 else:428 else:
422 lp_project_series = None429 lp_project_series = None
@@ -482,10 +489,12 @@
482489
483 for project, series in projects:490 for project, series in projects:
484 # XXX: should this be valid_ or all_specifications?491 # XXX: should this be valid_ or all_specifications?
485 project_spec_group_matcher = spec_group_matchers.get(project.name, None)492 project_spec_group_matcher = spec_group_matchers.get(project.name,
493 None)
486 project_bps = project.valid_specifications494 project_bps = project.valid_specifications
487 for bp in project_bps:495 for bp in project_bps:
488 if name_pattern is not None and re.search(name_pattern, bp.name) is None:496 if name_pattern is not None and \
497 re.search(name_pattern, bp.name) is None:
489 continue498 continue
490 if project_spec_group_matcher is not None:499 if project_spec_group_matcher is not None:
491 match = re.search(project_spec_group_matcher, bp.name)500 match = re.search(project_spec_group_matcher, bp.name)
@@ -500,7 +509,8 @@
500 add_blueprint(bp)509 add_blueprint(bp)
501 if series is not None:510 if series is not None:
502 for bp in series.valid_specifications:511 for bp in series.valid_specifications:
503 if name_pattern is not None and re.search(name_pattern, bp.name) is None:512 if name_pattern is not None and \
513 re.search(name_pattern, bp.name) is None:
504 continue514 continue
505 if project_spec_group_matcher is not None:515 if project_spec_group_matcher is not None:
506 match = re.search(project_spec_group_matcher, bp.name)516 match = re.search(project_spec_group_matcher, bp.name)
@@ -596,7 +606,8 @@
596 else:606 else:
597 status_search = fields[2:]607 status_search = fields[2:]
598 for f in status_search:608 for f in status_search:
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 \
610 u'INPROGRESS' in f or u'BLOCKED' in f:
600 ff = f.split()611 ff = f.split()
601 if len(ff) == 2:612 if len(ff) == 2:
602 assignee = ff[1]613 assignee = ff[1]
@@ -645,14 +656,17 @@
645 for url, default_assignee in cfg.get('moin_pages', {}).iteritems():656 for url, default_assignee in cfg.get('moin_pages', {}).iteritems():
646 url = unicode_or_None(url)657 url = unicode_or_None(url)
647 default_assignee = unicode_or_None(default_assignee)658 default_assignee = unicode_or_None(default_assignee)
648 dbg('moin_import(): processing %s (default assignee: %s)' % (url, default_assignee))659 dbg('moin_import(): processing %s (default assignee: %s)' % (
649 for group, status, items in get_moin_workitems_group(url, default_assignee):660 url, default_assignee))
661 for group, status, items in get_moin_workitems_group(url,
662 default_assignee):
650 url_clean = url.replace('?action=raw', '')663 url_clean = url.replace('?action=raw', '')
651 name = url_clean.split('://', 1)[1].split('/', 1)[1]664 name = url_clean.split('://', 1)[1].split('/', 1)[1]
652 if group:665 if group:
653 name += u' ' + group666 name += u' ' + group
654 spec_url = u'%s#%s' % (url_clean, escape_url(group))667 spec_url = u'%s#%s' % (url_clean, escape_url(group))
655 dbg(' got group %s: name="%s", url="%s"' % (group, name, spec_url))668 dbg(' got group %s: name="%s", url="%s"' % (
669 group, name, spec_url))
656 else:670 else:
657 spec_url = url_clean671 spec_url = url_clean
658 dbg(' no group: name="%s", url="%s"' % (name, spec_url))672 dbg(' no group: name="%s", url="%s"' % (name, spec_url))
@@ -691,7 +705,8 @@
691 optparser.add_option('-c', '--config',705 optparser.add_option('-c', '--config',
692 help='Path to configuration file', dest='config', metavar='PATH')706 help='Path to configuration file', dest='config', metavar='PATH')
693 optparser.add_option('-p', '--pattern', metavar='REGEX',707 optparser.add_option('-p', '--pattern', metavar='REGEX',
694 help='Regex pattern for blueprint name (optional, mainly for testing)', dest='pattern')708 help='Regex pattern for blueprint name (optional, mainly for testing)',
709 dest='pattern')
695 optparser.add_option('--debug', action='store_true', default=False,710 optparser.add_option('--debug', action='store_true', default=False,
696 help='Enable debugging output in parsing routines')711 help='Enable debugging output in parsing routines')
697 optparser.add_option('--mail', action='store_true', default=False,712 optparser.add_option('--mail', action='store_true', default=False,
@@ -729,24 +744,30 @@
729 project_name = error.get_project_name()744 project_name = error.get_project_name()
730 if project_name is not None:745 if project_name is not None:
731 addresses = cfg['project_notification_addresses'][project_name]746 addresses = cfg['project_notification_addresses'][project_name]
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' % (
733 project_name, ', '.join(addresses)))748 error.get_blueprint_name(), project_name,
749 ', '.join(addresses)))
734 for a in addresses:750 for a in addresses:
735 emails.setdefault(a, '')751 emails.setdefault(a, '')
736 emails[a] += error.format_for_display() + '\n'752 emails[a] += error.format_for_display() + '\n'
737 else:753 else:
738 print >> sys.stderr, error.format_for_display(), '(no error_contact pattern)'754 print >> sys.stderr, error.format_for_display(), \
755 '(no error_contact pattern)'
739756
740 # send mails757 # send mails
741 for addr, contents in emails.iteritems():758 for addr, contents in emails.iteritems():
742 msg = MIMEText(contents.encode('ascii', 'replace'))759 msg = MIMEText(contents.encode('ascii', 'replace'))
743 msg['Subject'] = 'Errors in work item definitions'760 msg['Subject'] = 'Errors in work item definitions'
744 msg['From'] = 'Launchpad work item tracker <work-items-tracker-hackers@lists.launchpad.net>'761 msg['From'] = 'Launchpad work item tracker ' + \
762 '<work-items-tracker-hackers@lists.launchpad.net>'
745 msg['To'] = addr763 msg['To'] = addr
746 s = smtplib.SMTP()764 s = smtplib.SMTP()
747 s.connect()765 s.connect()
748 s.sendmail(os.environ.get('EMAIL', pwd.getpwuid(os.geteuid()).pw_name + '@localhost'),766 s.sendmail(os.environ.get(
749 addr, msg.as_string())767 'EMAIL',
768 pwd.getpwuid(os.geteuid()).pw_name + '@localhost'),
769 addr,
770 msg.as_string())
750 s.quit()771 s.quit()
751772
752773
@@ -793,9 +814,14 @@
793 sys.exit(0)814 sys.exit(0)
794815
795 if "beta" in EDGE_SERVICE_ROOT:816 if "beta" in EDGE_SERVICE_ROOT:
796 lp = Launchpad.login_with('ubuntu-work-items', service_root=EDGE_SERVICE_ROOT.replace("edge.", "").replace("beta", "devel"))817 service_root = EDGE_SERVICE_ROOT
818 service_root = service_root.replace("edge.", "")
819 service_root = service_root.replace("beta", "devel")
820 lp = Launchpad.login_with('ubuntu-work-items',
821 service_root=service_root)
797 else:822 else:
798 lp = Launchpad.login_with('ubuntu-work-items', service_root="production", version="devel")823 lp = Launchpad.login_with('ubuntu-work-items',
824 service_root="production", version="devel")
799825
800 store = get_store(opts.database)826 store = get_store(opts.database)
801 collector = CollectorStore(store, lp, error_collector)827 collector = CollectorStore(store, lp, error_collector)

Subscribers

People subscribed via source and target branches