Hide keyboard shortcuts

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 

2 

3from django.conf import settings 

4from django.core.exceptions import ImproperlyConfigured 

5from django.template import loader 

6from .base import ErrorHandler 

7from .compat import Github 

8 

9# Exports 

10 

11__all__ = ( 

12 "GitHub", 

13) 

14 

15# Classes 

16 

17 

18class GitHub(ErrorHandler): 

19 

20 required_settings = [ 

21 # "SUPERDJANGO_ERROR_CAPTURE_GITHUB_LOGIN", 

22 "SUPERDJANGO_ERROR_CAPTURE_GITHUB_REPO", 

23 "SUPERDJANGO_ERROR_CAPTURE_GITHUB_TOKEN", 

24 ] 

25 

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") 

31 

32 super().__init__() 

33 

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") 

38 

39 github = Github(settings.SUPERDJANGO_ERROR_CAPTURE_GITHUB_TOKEN) 

40 repo = github.get_repo(settings.SUPERDJANGO_ERROR_CAPTURE_GITHUB_REPO) 

41 

42 issue = repo.create_issue(body=body, title=title) 

43 

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 }