Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent crashes if an owner's account has been suspended on Launchpad #7

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 22 additions & 5 deletions lp2gh/bugs.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,17 +58,34 @@


def message_to_dict(message):
owner = message.owner
return {'owner': owner.name,
# We skip errors caused by suspended users
try:
owner = message.owner
owner_name = owner.name or "unknown"
except:
owner_name = "unknown"

return {'owner': owner_name,
'content': message.content,
'date_created': util.to_timestamp(message.date_created),
}


def bug_task_to_dict(bug_task):
bug = bug_task.bug
assignee = bug_task.assignee
owner = bug_task.owner

# We skip errors caused by suspended users
try:
assignee = bug_task.assignee
assignee_name = assignee.name or None,
except:
assignee_name = None
try:
owner = bug_task.owner
owner_name = owner.name or "unknown"
except:
owner_name = "unknown"

messages = list(bug.messages)[1:]
milestone = bug_task.milestone
duplicates = bug.duplicates
Expand All @@ -77,7 +94,7 @@ def bug_task_to_dict(bug_task):
'status': bug_task.status,
'importance': bug_task.importance,
'assignee': assignee and assignee.name or None,
'owner': owner.name,
'owner': owner_name,
'milestone': milestone and milestone.name,
'title': bug.title,
'description': bug.description,
Expand Down