{"action":"created","comment":{"url":"https://api.github.com/repos/mozilla/mozregression/pulls/comments/37655453","id":37655453,"diff_hunk":"@@ -0,0 +1,230 @@\n+\"\"\"\n+This module offers an API to get information for one build.\n+\n+The public API is composed of two classes, :class:`NightlyInfoFetcher` and\n+:class:`InboundInfoFetcher`. they both inherit from the :class:`InfoFetcher`.\n+\n+Here is an example of usage, to get the build url of builds::\n+\n+  from datetime import date\n+  from mozregression.fetch_config import create_config\n+\n+  fetch_config = create_config('firefox', 'linux', 64)\n+  # note that you should configure the fetch_config to use another repo\n+  # than the defaut one for the application.\n+\n+  # find build info for one date (looks in nightly builds)\n+  info_fetcher = NightlyInfoFetcher(fetch_config)\n+  print info_fetcher.find_build_info(date(2015, 01, 01))['build_url']\n+\n+  # find build info for one changeset (looks in inbound builds)\n+  info_fetcher = InboundInfoFetcher(fetch_config)\n+  print info_fetcher.find_build_info(\"a_valid_changeset\")['build_url']\n+\"\"\"\n+\n+import os\n+import re\n+import threading\n+import taskcluster\n+from taskcluster.exceptions import TaskclusterFailure\n+from mozlog.structuredlog import get_default_logger\n+from concurrent import futures\n+\n+from mozregression.network import url_links, retry_get\n+from mozregression.errors import BuildInfoNotFound\n+\n+\n+class InfoFetcher(object):\n+    def __init__(self, fetch_config):\n+        self._logger = get_default_logger(__name__)\n+        self.fetch_config = fetch_config\n+        self.build_regex = re.compile(fetch_config.build_regex())\n+        self.build_info_regex = re.compile(fetch_config.build_info_regex())\n+\n+    def _update_build_info_from_txt(self, build_info):\n+        if 'build_txt_url' in build_info:\n+            build_info.update(\n+                self._fetch_txt_info(build_info['build_txt_url'])\n+            )\n+\n+    def _fetch_txt_info(self, url):\n+        \"\"\"\n+        Retrieve information from a build information txt file.\n+\n+        Returns a dict with keys repository and changeset if information\n+        is found.\n+        \"\"\"\n+        data = {}\n+        response = retry_get(url)\n+        for line in response.text.splitlines():\n+            if '/rev/' in line:\n+                repository, changeset = line.split('/rev/')\n+                data['repository'] = repository\n+                data['changeset'] = changeset\n+                break\n+        if not data:\n+            # the txt file could be in an old format:\n+            # DATE CHANGESET\n+            # we can try to extract that to get the changeset at least.\n+            matched = re.match('^\\d+ (\\w+)$', response.text.strip())\n+            if matched:\n+                data['changeset'] = matched.group(1)\n+        return data\n+\n+    def find_build_info(self, changeset_or_date, fetch_txt_info=True):\n+        \"\"\"\n+        Abstract method to retrieve build information over the internet for\n+        one build.\n+\n+        This returns a dict that contain build information. At minima, this","path":"mozregression/fetch_build_info.py","position":79,"original_position":79,"commit_id":"c8de9c17d5f338470036e0cf260c32f17e4ca58b","original_commit_id":"c8de9c17d5f338470036e0cf260c32f17e4ca58b","user":{"login":"wlach","id":20569,"avatar_url":"https://avatars.githubusercontent.com/u/20569?v=3","gravatar_id":"","url":"https://api.github.com/users/wlach","html_url":"https://github.com/wlach","followers_url":"https://api.github.com/users/wlach/followers","following_url":"https://api.github.com/users/wlach/following{/other_user}","gists_url":"https://api.github.com/users/wlach/gists{/gist_id}","starred_url":"https://api.github.com/users/wlach/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wlach/subscriptions","organizations_url":"https://api.github.com/users/wlach/orgs","repos_url":"https://api.github.com/users/wlach/repos","events_url":"https://api.github.com/users/wlach/events{/privacy}","received_events_url":"https://api.github.com/users/wlach/received_events","type":"User","site_admin":false},"body":"At minima -> At minimum","created_at":"2015-08-21T17:11:54Z","updated_at":"2015-08-21T17:11:54Z","html_url":"https://github.com/mozilla/mozregression/pull/276#discussion_r37655453","pull_request_url":"https://api.github.com/repos/mozilla/mozregression/pulls/276","_links":{"self":{"href":"https://api.github.com/repos/mozilla/mozregression/pulls/comments/37655453"},"html":{"href":"https://github.com/mozilla/mozregression/pull/276#discussion_r37655453"},"pull_request":{"href":"https://api.github.com/repos/mozilla/mozregression/pulls/276"}}},"pull_request":{"url":"https://api.github.com/repos/mozilla/mozregression/pulls/276","id":42519872,"html_url":"https://github.com/mozilla/mozregression/pull/276","diff_url":"https://github.com/mozilla/mozregression/pull/276.diff","patch_url":"https://github.com/mozilla/mozregression/pull/276.patch","issue_url":"https://api.github.com/repos/mozilla/mozregression/issues/276","number":276,"state":"closed","locked":false,"title":"Bug 1194996 - create a simple API to fetch build information for a build","user":{"login":"parkouss","id":7723923,"avatar_url":"https://avatars.githubusercontent.com/u/7723923?v=3","gravatar_id":"","url":"https://api.github.com/users/parkouss","html_url":"https://github.com/parkouss","followers_url":"https://api.github.com/users/parkouss/followers","following_url":"https://api.github.com/users/parkouss/following{/other_user}","gists_url":"https://api.github.com/users/parkouss/gists{/gist_id}","starred_url":"https://api.github.com/users/parkouss/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/parkouss/subscriptions","organizations_url":"https://api.github.com/users/parkouss/orgs","repos_url":"https://api.github.com/users/parkouss/repos","events_url":"https://api.github.com/users/parkouss/events{/privacy}","received_events_url":"https://api.github.com/users/parkouss/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-08-15T14:17:40Z","updated_at":"2015-08-21T17:11:54Z","closed_at":"2015-08-21T10:38:40Z","merged_at":"2015-08-21T10:38:40Z","merge_commit_sha":"390a471c58238adc5a6090ccabf1aaae7192029d","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/mozilla/mozregression/pulls/276/commits","review_comments_url":"https://api.github.com/repos/mozilla/mozregression/pulls/276/comments","review_comment_url":"https://api.github.com/repos/mozilla/mozregression/pulls/comments{/number}","comments_url":"https://api.github.com/repos/mozilla/mozregression/issues/276/comments","statuses_url":"https://api.github.com/repos/mozilla/mozregression/statuses/c8de9c17d5f338470036e0cf260c32f17e4ca58b","head":{"label":"parkouss:fetch_build_info","ref":"fetch_build_info","sha":"c8de9c17d5f338470036e0cf260c32f17e4ca58b","user":{"login":"parkouss","id":7723923,"avatar_url":"https://avatars.githubusercontent.com/u/7723923?v=3","gravatar_id":"","url":"https://api.github.com/users/parkouss","html_url":"https://github.com/parkouss","followers_url":"https://api.github.com/users/parkouss/followers","following_url":"https://api.github.com/users/parkouss/following{/other_user}","gists_url":"https://api.github.com/users/parkouss/gists{/gist_id}","starred_url":"https://api.github.com/users/parkouss/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/parkouss/subscriptions","organizations_url":"https://api.github.com/users/parkouss/orgs","repos_url":"https://api.github.com/users/parkouss/repos","events_url":"https://api.github.com/users/parkouss/events{/privacy}","received_events_url":"https://api.github.com/users/parkouss/received_events","type":"User","site_admin":false},"repo":{"id":20301061,"name":"mozregression","full_name":"parkouss/mozregression","owner":{"login":"parkouss","id":7723923,"avatar_url":"https://avatars.githubusercontent.com/u/7723923?v=3","gravatar_id":"","url":"https://api.github.com/users/parkouss","html_url":"https://github.com/parkouss","followers_url":"https://api.github.com/users/parkouss/followers","following_url":"https://api.github.com/users/parkouss/following{/other_user}","gists_url":"https://api.github.com/users/parkouss/gists{/gist_id}","starred_url":"https://api.github.com/users/parkouss/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/parkouss/subscriptions","organizations_url":"https://api.github.com/users/parkouss/orgs","repos_url":"https://api.github.com/users/parkouss/repos","events_url":"https://api.github.com/users/parkouss/events{/privacy}","received_events_url":"https://api.github.com/users/parkouss/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/parkouss/mozregression","description":"Regression range finder for Mozilla nightly builds","fork":true,"url":"https://api.github.com/repos/parkouss/mozregression","forks_url":"https://api.github.com/repos/parkouss/mozregression/forks","keys_url":"https://api.github.com/repos/parkouss/mozregression/keys{/key_id}","collaborators_url":"https://api.github.com/repos/parkouss/mozregression/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/parkouss/mozregression/teams","hooks_url":"https://api.github.com/repos/parkouss/mozregression/hooks","issue_events_url":"https://api.github.com/repos/parkouss/mozregression/issues/events{/number}","events_url":"https://api.github.com/repos/parkouss/mozregression/events","assignees_url":"https://api.github.com/repos/parkouss/mozregression/assignees{/user}","branches_url":"https://api.github.com/repos/parkouss/mozregression/branches{/branch}","tags_url":"https://api.github.com/repos/parkouss/mozregression/tags","blobs_url":"https://api.github.com/repos/parkouss/mozregression/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/parkouss/mozregression/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/parkouss/mozregression/git/refs{/sha}","trees_url":"https://api.github.com/repos/parkouss/mozregression/git/trees{/sha}","statuses_url":"https://api.github.com/repos/parkouss/mozregression/statuses/{sha}","languages_url":"https://api.github.com/repos/parkouss/mozregression/languages","stargazers_url":"https://api.github.com/repos/parkouss/mozregression/stargazers","contributors_url":"https://api.github.com/repos/parkouss/mozregression/contributors","subscribers_url":"https://api.github.com/repos/parkouss/mozregression/subscribers","subscription_url":"https://api.github.com/repos/parkouss/mozregression/subscription","commits_url":"https://api.github.com/repos/parkouss/mozregression/commits{/sha}","git_commits_url":"https://api.github.com/repos/parkouss/mozregression/git/commits{/sha}","comments_url":"https://api.github.com/repos/parkouss/mozregression/comments{/number}","issue_comment_url":"https://api.github.com/repos/parkouss/mozregression/issues/comments{/number}","contents_url":"https://api.github.com/repos/parkouss/mozregression/contents/{+path}","compare_url":"https://api.github.com/repos/parkouss/mozregression/compare/{base}...{head}","merges_url":"https://api.github.com/repos/parkouss/mozregression/merges","archive_url":"https://api.github.com/repos/parkouss/mozregression/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/parkouss/mozregression/downloads","issues_url":"https://api.github.com/repos/parkouss/mozregression/issues{/number}","pulls_url":"https://api.github.com/repos/parkouss/mozregression/pulls{/number}","milestones_url":"https://api.github.com/repos/parkouss/mozregression/milestones{/number}","notifications_url":"https://api.github.com/repos/parkouss/mozregression/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/parkouss/mozregression/labels{/name}","releases_url":"https://api.github.com/repos/parkouss/mozregression/releases{/id}","created_at":"2014-05-29T16:53:07Z","updated_at":"2015-05-04T06:08:28Z","pushed_at":"2015-08-21T13:55:27Z","git_url":"git://github.com/parkouss/mozregression.git","ssh_url":"git@github.com:parkouss/mozregression.git","clone_url":"https://github.com/parkouss/mozregression.git","svn_url":"https://github.com/parkouss/mozregression","homepage":"http://mozilla.github.com/mozregression","size":2629,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"mozilla:master","ref":"master","sha":"0947062127e1b8590ad6bed8b51f4cb1f277c6f4","user":{"login":"mozilla","id":131524,"avatar_url":"https://avatars.githubusercontent.com/u/131524?v=3","gravatar_id":"","url":"https://api.github.com/users/mozilla","html_url":"https://github.com/mozilla","followers_url":"https://api.github.com/users/mozilla/followers","following_url":"https://api.github.com/users/mozilla/following{/other_user}","gists_url":"https://api.github.com/users/mozilla/gists{/gist_id}","starred_url":"https://api.github.com/users/mozilla/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mozilla/subscriptions","organizations_url":"https://api.github.com/users/mozilla/orgs","repos_url":"https://api.github.com/users/mozilla/repos","events_url":"https://api.github.com/users/mozilla/events{/privacy}","received_events_url":"https://api.github.com/users/mozilla/received_events","type":"Organization","site_admin":false},"repo":{"id":512679,"name":"mozregression","full_name":"mozilla/mozregression","owner":{"login":"mozilla","id":131524,"avatar_url":"https://avatars.githubusercontent.com/u/131524?v=3","gravatar_id":"","url":"https://api.github.com/users/mozilla","html_url":"https://github.com/mozilla","followers_url":"https://api.github.com/users/mozilla/followers","following_url":"https://api.github.com/users/mozilla/following{/other_user}","gists_url":"https://api.github.com/users/mozilla/gists{/gist_id}","starred_url":"https://api.github.com/users/mozilla/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mozilla/subscriptions","organizations_url":"https://api.github.com/users/mozilla/orgs","repos_url":"https://api.github.com/users/mozilla/repos","events_url":"https://api.github.com/users/mozilla/events{/privacy}","received_events_url":"https://api.github.com/users/mozilla/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mozilla/mozregression","description":"Regression range finder for Mozilla nightly builds","fork":false,"url":"https://api.github.com/repos/mozilla/mozregression","forks_url":"https://api.github.com/repos/mozilla/mozregression/forks","keys_url":"https://api.github.com/repos/mozilla/mozregression/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mozilla/mozregression/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mozilla/mozregression/teams","hooks_url":"https://api.github.com/repos/mozilla/mozregression/hooks","issue_events_url":"https://api.github.com/repos/mozilla/mozregression/issues/events{/number}","events_url":"https://api.github.com/repos/mozilla/mozregression/events","assignees_url":"https://api.github.com/repos/mozilla/mozregression/assignees{/user}","branches_url":"https://api.github.com/repos/mozilla/mozregression/branches{/branch}","tags_url":"https://api.github.com/repos/mozilla/mozregression/tags","blobs_url":"https://api.github.com/repos/mozilla/mozregression/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mozilla/mozregression/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mozilla/mozregression/git/refs{/sha}","trees_url":"https://api.github.com/repos/mozilla/mozregression/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mozilla/mozregression/statuses/{sha}","languages_url":"https://api.github.com/repos/mozilla/mozregression/languages","stargazers_url":"https://api.github.com/repos/mozilla/mozregression/stargazers","contributors_url":"https://api.github.com/repos/mozilla/mozregression/contributors","subscribers_url":"https://api.github.com/repos/mozilla/mozregression/subscribers","subscription_url":"https://api.github.com/repos/mozilla/mozregression/subscription","commits_url":"https://api.github.com/repos/mozilla/mozregression/commits{/sha}","git_commits_url":"https://api.github.com/repos/mozilla/mozregression/git/commits{/sha}","comments_url":"https://api.github.com/repos/mozilla/mozregression/comments{/number}","issue_comment_url":"https://api.github.com/repos/mozilla/mozregression/issues/comments{/number}","contents_url":"https://api.github.com/repos/mozilla/mozregression/contents/{+path}","compare_url":"https://api.github.com/repos/mozilla/mozregression/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mozilla/mozregression/merges","archive_url":"https://api.github.com/repos/mozilla/mozregression/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mozilla/mozregression/downloads","issues_url":"https://api.github.com/repos/mozilla/mozregression/issues{/number}","pulls_url":"https://api.github.com/repos/mozilla/mozregression/pulls{/number}","milestones_url":"https://api.github.com/repos/mozilla/mozregression/milestones{/number}","notifications_url":"https://api.github.com/repos/mozilla/mozregression/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mozilla/mozregression/labels{/name}","releases_url":"https://api.github.com/repos/mozilla/mozregression/releases{/id}","created_at":"2010-02-11T05:49:14Z","updated_at":"2015-08-18T11:43:42Z","pushed_at":"2015-08-21T10:38:40Z","git_url":"git://github.com/mozilla/mozregression.git","ssh_url":"git@github.com:mozilla/mozregression.git","clone_url":"https://github.com/mozilla/mozregression.git","svn_url":"https://github.com/mozilla/mozregression","homepage":"http://mozilla.github.com/mozregression","size":3141,"stargazers_count":53,"watchers_count":53,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":45,"mirror_url":null,"open_issues_count":4,"forks":45,"open_issues":4,"watchers":53,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/mozilla/mozregression/pulls/276"},"html":{"href":"https://github.com/mozilla/mozregression/pull/276"},"issue":{"href":"https://api.github.com/repos/mozilla/mozregression/issues/276"},"comments":{"href":"https://api.github.com/repos/mozilla/mozregression/issues/276/comments"},"review_comments":{"href":"https://api.github.com/repos/mozilla/mozregression/pulls/276/comments"},"review_comment":{"href":"https://api.github.com/repos/mozilla/mozregression/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/mozilla/mozregression/pulls/276/commits"},"statuses":{"href":"https://api.github.com/repos/mozilla/mozregression/statuses/c8de9c17d5f338470036e0cf260c32f17e4ca58b"}}}}