Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1# Imports
3from django.conf import settings
4from django.core.exceptions import ImproperlyConfigured
5from django.template import loader
6from .base import ErrorHandler
7from .compat import Github
9# Exports
11__all__ = (
12 "GitHub",
13)
15# Classes
18class GitHub(ErrorHandler):
20 required_settings = [
21 # "SUPERDJANGO_ERROR_CAPTURE_GITHUB_LOGIN",
22 "SUPERDJANGO_ERROR_CAPTURE_GITHUB_REPO",
23 "SUPERDJANGO_ERROR_CAPTURE_GITHUB_TOKEN",
24 ]
26 def __init__(self):
27 """Check for presence of PyGithub."""
28 if Github is None:
29 raise ImproperlyConfigured("The PyGithub package is required to use the GitHub backend: Use "
30 "pip install PyGithub")
32 super().__init__()
34 def handle(self, report):
35 """Post an error to GitHub issues."""
36 body = self._parse_template("errors/github_body.txt")
37 title = self._parse_template("errors/github_title.txt")
39 github = Github(settings.SUPERDJANGO_ERROR_CAPTURE_GITHUB_TOKEN)
40 repo = github.get_repo(settings.SUPERDJANGO_ERROR_CAPTURE_GITHUB_REPO)
42 issue = repo.create_issue(body=body, title=title)
44 issue_url = "https://github.com/%s/issues#issue/" % settings.SUPERDJANGO_ERROR_CAPTURE_GITHUB_REPO
45 return {
46 'issue_url': issue_url + str(issue.id)
47 }