{"action":"created","comment":{"url":"https://api.github.com/repos/buildbot/buildbot/pulls/comments/43157720","id":43157720,"diff_hunk":"@@ -29,6 +30,30 @@ def getUserAvatar(self, email, size, defaultAvatarUrl):\n         raise NotImplementedError()\n \n \n+class AvatarGitHub(AvatarBase):\n+    name = \"github\"\n+    cache = {}\n+\n+    def getUserAvatar(self, email, size, defaultAvatarUrl):\n+        if self.cache.get(email):\n+            raise resource.Redirect(self.cache[email])\n+\n+        # https://developer.github.com/v3/search/#search-users\n+        url = 'https://api.github.com/search/users?'\n+        url += urllib.urlencode({'q': email, 'in': 'email', 'type': 'user'})\n+        try:\n+            res = urllib.urlopen(url)\n+            res = res.read()\n+            res = json.loads(res)","path":"master/buildbot/www/avatar.py","position":26,"original_position":26,"commit_id":"fa8977d5bfd96a42ba74e86cfeb036777e6b4b4b","original_commit_id":"fa8977d5bfd96a42ba74e86cfeb036777e6b4b4b","user":{"login":"sa2ajj","id":447092,"avatar_url":"https://avatars.githubusercontent.com/u/447092?v=3","gravatar_id":"","url":"https://api.github.com/users/sa2ajj","html_url":"https://github.com/sa2ajj","followers_url":"https://api.github.com/users/sa2ajj/followers","following_url":"https://api.github.com/users/sa2ajj/following{/other_user}","gists_url":"https://api.github.com/users/sa2ajj/gists{/gist_id}","starred_url":"https://api.github.com/users/sa2ajj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sa2ajj/subscriptions","organizations_url":"https://api.github.com/users/sa2ajj/orgs","repos_url":"https://api.github.com/users/sa2ajj/repos","events_url":"https://api.github.com/users/sa2ajj/events{/privacy}","received_events_url":"https://api.github.com/users/sa2ajj/received_events","type":"User","site_admin":false},"body":"why not replace this with\r\n```python\r\nres = json.loads(urllib.urlopen(url).read())\r\n```","created_at":"2015-10-27T17:40:51Z","updated_at":"2015-10-27T17:40:51Z","html_url":"https://github.com/buildbot/buildbot/pull/1894#discussion_r43157720","pull_request_url":"https://api.github.com/repos/buildbot/buildbot/pulls/1894","_links":{"self":{"href":"https://api.github.com/repos/buildbot/buildbot/pulls/comments/43157720"},"html":{"href":"https://github.com/buildbot/buildbot/pull/1894#discussion_r43157720"},"pull_request":{"href":"https://api.github.com/repos/buildbot/buildbot/pulls/1894"}}},"pull_request":{"url":"https://api.github.com/repos/buildbot/buildbot/pulls/1894","id":48730141,"html_url":"https://github.com/buildbot/buildbot/pull/1894","diff_url":"https://github.com/buildbot/buildbot/pull/1894.diff","patch_url":"https://github.com/buildbot/buildbot/pull/1894.patch","issue_url":"https://api.github.com/repos/buildbot/buildbot/issues/1894","number":1894,"state":"open","locked":false,"title":"GitHubAuth: Grab the user's primary email address","user":{"login":"pieterlexis","id":731232,"avatar_url":"https://avatars.githubusercontent.com/u/731232?v=3","gravatar_id":"","url":"https://api.github.com/users/pieterlexis","html_url":"https://github.com/pieterlexis","followers_url":"https://api.github.com/users/pieterlexis/followers","following_url":"https://api.github.com/users/pieterlexis/following{/other_user}","gists_url":"https://api.github.com/users/pieterlexis/gists{/gist_id}","starred_url":"https://api.github.com/users/pieterlexis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pieterlexis/subscriptions","organizations_url":"https://api.github.com/users/pieterlexis/orgs","repos_url":"https://api.github.com/users/pieterlexis/repos","events_url":"https://api.github.com/users/pieterlexis/events{/privacy}","received_events_url":"https://api.github.com/users/pieterlexis/received_events","type":"User","site_admin":false},"body":"Github doesn't provide any email address in the normal oauth response, so we request an extra permission and assign the user's primary email to the email field in buildbot.","created_at":"2015-10-26T11:56:25Z","updated_at":"2015-10-27T17:40:51Z","closed_at":null,"merged_at":null,"merge_commit_sha":"4aeea842b4ccd4341758f5b2fbca16ec4a75f553","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/buildbot/buildbot/pulls/1894/commits","review_comments_url":"https://api.github.com/repos/buildbot/buildbot/pulls/1894/comments","review_comment_url":"https://api.github.com/repos/buildbot/buildbot/pulls/comments{/number}","comments_url":"https://api.github.com/repos/buildbot/buildbot/issues/1894/comments","statuses_url":"https://api.github.com/repos/buildbot/buildbot/statuses/fa8977d5bfd96a42ba74e86cfeb036777e6b4b4b","head":{"label":"pieterlexis:github-auth","ref":"github-auth","sha":"fa8977d5bfd96a42ba74e86cfeb036777e6b4b4b","user":{"login":"pieterlexis","id":731232,"avatar_url":"https://avatars.githubusercontent.com/u/731232?v=3","gravatar_id":"","url":"https://api.github.com/users/pieterlexis","html_url":"https://github.com/pieterlexis","followers_url":"https://api.github.com/users/pieterlexis/followers","following_url":"https://api.github.com/users/pieterlexis/following{/other_user}","gists_url":"https://api.github.com/users/pieterlexis/gists{/gist_id}","starred_url":"https://api.github.com/users/pieterlexis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pieterlexis/subscriptions","organizations_url":"https://api.github.com/users/pieterlexis/orgs","repos_url":"https://api.github.com/users/pieterlexis/repos","events_url":"https://api.github.com/users/pieterlexis/events{/privacy}","received_events_url":"https://api.github.com/users/pieterlexis/received_events","type":"User","site_admin":false},"repo":{"id":33928855,"name":"buildbot","full_name":"pieterlexis/buildbot","owner":{"login":"pieterlexis","id":731232,"avatar_url":"https://avatars.githubusercontent.com/u/731232?v=3","gravatar_id":"","url":"https://api.github.com/users/pieterlexis","html_url":"https://github.com/pieterlexis","followers_url":"https://api.github.com/users/pieterlexis/followers","following_url":"https://api.github.com/users/pieterlexis/following{/other_user}","gists_url":"https://api.github.com/users/pieterlexis/gists{/gist_id}","starred_url":"https://api.github.com/users/pieterlexis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pieterlexis/subscriptions","organizations_url":"https://api.github.com/users/pieterlexis/orgs","repos_url":"https://api.github.com/users/pieterlexis/repos","events_url":"https://api.github.com/users/pieterlexis/events{/privacy}","received_events_url":"https://api.github.com/users/pieterlexis/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/pieterlexis/buildbot","description":"Python-based continuous integration testing framework; send pull requests for your patches!","fork":true,"url":"https://api.github.com/repos/pieterlexis/buildbot","forks_url":"https://api.github.com/repos/pieterlexis/buildbot/forks","keys_url":"https://api.github.com/repos/pieterlexis/buildbot/keys{/key_id}","collaborators_url":"https://api.github.com/repos/pieterlexis/buildbot/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/pieterlexis/buildbot/teams","hooks_url":"https://api.github.com/repos/pieterlexis/buildbot/hooks","issue_events_url":"https://api.github.com/repos/pieterlexis/buildbot/issues/events{/number}","events_url":"https://api.github.com/repos/pieterlexis/buildbot/events","assignees_url":"https://api.github.com/repos/pieterlexis/buildbot/assignees{/user}","branches_url":"https://api.github.com/repos/pieterlexis/buildbot/branches{/branch}","tags_url":"https://api.github.com/repos/pieterlexis/buildbot/tags","blobs_url":"https://api.github.com/repos/pieterlexis/buildbot/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/pieterlexis/buildbot/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/pieterlexis/buildbot/git/refs{/sha}","trees_url":"https://api.github.com/repos/pieterlexis/buildbot/git/trees{/sha}","statuses_url":"https://api.github.com/repos/pieterlexis/buildbot/statuses/{sha}","languages_url":"https://api.github.com/repos/pieterlexis/buildbot/languages","stargazers_url":"https://api.github.com/repos/pieterlexis/buildbot/stargazers","contributors_url":"https://api.github.com/repos/pieterlexis/buildbot/contributors","subscribers_url":"https://api.github.com/repos/pieterlexis/buildbot/subscribers","subscription_url":"https://api.github.com/repos/pieterlexis/buildbot/subscription","commits_url":"https://api.github.com/repos/pieterlexis/buildbot/commits{/sha}","git_commits_url":"https://api.github.com/repos/pieterlexis/buildbot/git/commits{/sha}","comments_url":"https://api.github.com/repos/pieterlexis/buildbot/comments{/number}","issue_comment_url":"https://api.github.com/repos/pieterlexis/buildbot/issues/comments{/number}","contents_url":"https://api.github.com/repos/pieterlexis/buildbot/contents/{+path}","compare_url":"https://api.github.com/repos/pieterlexis/buildbot/compare/{base}...{head}","merges_url":"https://api.github.com/repos/pieterlexis/buildbot/merges","archive_url":"https://api.github.com/repos/pieterlexis/buildbot/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/pieterlexis/buildbot/downloads","issues_url":"https://api.github.com/repos/pieterlexis/buildbot/issues{/number}","pulls_url":"https://api.github.com/repos/pieterlexis/buildbot/pulls{/number}","milestones_url":"https://api.github.com/repos/pieterlexis/buildbot/milestones{/number}","notifications_url":"https://api.github.com/repos/pieterlexis/buildbot/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/pieterlexis/buildbot/labels{/name}","releases_url":"https://api.github.com/repos/pieterlexis/buildbot/releases{/id}","created_at":"2015-04-14T11:54:43Z","updated_at":"2015-04-14T11:54:47Z","pushed_at":"2015-10-26T17:26:33Z","git_url":"git://github.com/pieterlexis/buildbot.git","ssh_url":"git@github.com:pieterlexis/buildbot.git","clone_url":"https://github.com/pieterlexis/buildbot.git","svn_url":"https://github.com/pieterlexis/buildbot","homepage":"http://buildbot.net","size":37365,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"buildbot:master","ref":"master","sha":"36732c4df3dd536661ef6aef162dc5118fc7b70a","user":{"login":"buildbot","id":324515,"avatar_url":"https://avatars.githubusercontent.com/u/324515?v=3","gravatar_id":"","url":"https://api.github.com/users/buildbot","html_url":"https://github.com/buildbot","followers_url":"https://api.github.com/users/buildbot/followers","following_url":"https://api.github.com/users/buildbot/following{/other_user}","gists_url":"https://api.github.com/users/buildbot/gists{/gist_id}","starred_url":"https://api.github.com/users/buildbot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/buildbot/subscriptions","organizations_url":"https://api.github.com/users/buildbot/orgs","repos_url":"https://api.github.com/users/buildbot/repos","events_url":"https://api.github.com/users/buildbot/events{/privacy}","received_events_url":"https://api.github.com/users/buildbot/received_events","type":"Organization","site_admin":false},"repo":{"id":760165,"name":"buildbot","full_name":"buildbot/buildbot","owner":{"login":"buildbot","id":324515,"avatar_url":"https://avatars.githubusercontent.com/u/324515?v=3","gravatar_id":"","url":"https://api.github.com/users/buildbot","html_url":"https://github.com/buildbot","followers_url":"https://api.github.com/users/buildbot/followers","following_url":"https://api.github.com/users/buildbot/following{/other_user}","gists_url":"https://api.github.com/users/buildbot/gists{/gist_id}","starred_url":"https://api.github.com/users/buildbot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/buildbot/subscriptions","organizations_url":"https://api.github.com/users/buildbot/orgs","repos_url":"https://api.github.com/users/buildbot/repos","events_url":"https://api.github.com/users/buildbot/events{/privacy}","received_events_url":"https://api.github.com/users/buildbot/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/buildbot/buildbot","description":"Python-based continuous integration testing framework; your pull requests are more than welcome!","fork":false,"url":"https://api.github.com/repos/buildbot/buildbot","forks_url":"https://api.github.com/repos/buildbot/buildbot/forks","keys_url":"https://api.github.com/repos/buildbot/buildbot/keys{/key_id}","collaborators_url":"https://api.github.com/repos/buildbot/buildbot/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/buildbot/buildbot/teams","hooks_url":"https://api.github.com/repos/buildbot/buildbot/hooks","issue_events_url":"https://api.github.com/repos/buildbot/buildbot/issues/events{/number}","events_url":"https://api.github.com/repos/buildbot/buildbot/events","assignees_url":"https://api.github.com/repos/buildbot/buildbot/assignees{/user}","branches_url":"https://api.github.com/repos/buildbot/buildbot/branches{/branch}","tags_url":"https://api.github.com/repos/buildbot/buildbot/tags","blobs_url":"https://api.github.com/repos/buildbot/buildbot/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/buildbot/buildbot/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/buildbot/buildbot/git/refs{/sha}","trees_url":"https://api.github.com/repos/buildbot/buildbot/git/trees{/sha}","statuses_url":"https://api.github.com/repos/buildbot/buildbot/statuses/{sha}","languages_url":"https://api.github.com/repos/buildbot/buildbot/languages","stargazers_url":"https://api.github.com/repos/buildbot/buildbot/stargazers","contributors_url":"https://api.github.com/repos/buildbot/buildbot/contributors","subscribers_url":"https://api.github.com/repos/buildbot/buildbot/subscribers","subscription_url":"https://api.github.com/repos/buildbot/buildbot/subscription","commits_url":"https://api.github.com/repos/buildbot/buildbot/commits{/sha}","git_commits_url":"https://api.github.com/repos/buildbot/buildbot/git/commits{/sha}","comments_url":"https://api.github.com/repos/buildbot/buildbot/comments{/number}","issue_comment_url":"https://api.github.com/repos/buildbot/buildbot/issues/comments{/number}","contents_url":"https://api.github.com/repos/buildbot/buildbot/contents/{+path}","compare_url":"https://api.github.com/repos/buildbot/buildbot/compare/{base}...{head}","merges_url":"https://api.github.com/repos/buildbot/buildbot/merges","archive_url":"https://api.github.com/repos/buildbot/buildbot/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/buildbot/buildbot/downloads","issues_url":"https://api.github.com/repos/buildbot/buildbot/issues{/number}","pulls_url":"https://api.github.com/repos/buildbot/buildbot/pulls{/number}","milestones_url":"https://api.github.com/repos/buildbot/buildbot/milestones{/number}","notifications_url":"https://api.github.com/repos/buildbot/buildbot/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/buildbot/buildbot/labels{/name}","releases_url":"https://api.github.com/repos/buildbot/buildbot/releases{/id}","created_at":"2010-07-06T17:56:53Z","updated_at":"2015-10-27T12:16:33Z","pushed_at":"2015-10-27T17:19:27Z","git_url":"git://github.com/buildbot/buildbot.git","ssh_url":"git@github.com:buildbot/buildbot.git","clone_url":"https://github.com/buildbot/buildbot.git","svn_url":"https://github.com/buildbot/buildbot","homepage":"http://buildbot.net","size":55318,"stargazers_count":1814,"watchers_count":1814,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":783,"mirror_url":null,"open_issues_count":24,"forks":783,"open_issues":24,"watchers":1814,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/buildbot/buildbot/pulls/1894"},"html":{"href":"https://github.com/buildbot/buildbot/pull/1894"},"issue":{"href":"https://api.github.com/repos/buildbot/buildbot/issues/1894"},"comments":{"href":"https://api.github.com/repos/buildbot/buildbot/issues/1894/comments"},"review_comments":{"href":"https://api.github.com/repos/buildbot/buildbot/pulls/1894/comments"},"review_comment":{"href":"https://api.github.com/repos/buildbot/buildbot/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/buildbot/buildbot/pulls/1894/commits"},"statuses":{"href":"https://api.github.com/repos/buildbot/buildbot/statuses/fa8977d5bfd96a42ba74e86cfeb036777e6b4b4b"}}}}