{"action":"created","comment":{"url":"https://api.github.com/repos/mozilla/mozmill-ci/pulls/comments/44631723","id":44631723,"diff_hunk":"@@ -0,0 +1,102 @@\n+#!/usr/bin/env python\n+\n+# This Source Code Form is subject to the terms of the Mozilla Public\n+# License, v. 2.0. If a copy of the MPL was not distributed with this file,\n+# You can obtain one at http://mozilla.org/MPL/2.0/.\n+\n+import os\n+import sys\n+import tarfile\n+import urllib\n+\n+from subprocess import check_call\n+\n+import start\n+\n+\n+DIR_TEST_ENV = \"test/venv\"\n+DIR_JENKINS_ENV = \"jenkins-env\"\n+VERSION_VIRTUALENV = \"13.1.2\"\n+\n+\n+class Jenkins(object):\n+    def __init__(self):\n+        self.proc = start.start_jenkins()\n+\n+    def wait_for_started(self):\n+        # late imports because we need the jenkins virtualenv to be activated\n+        # (this is done in the constructor)\n+        import redo\n+        import requests\n+\n+        session = requests.Session()\n+\n+        def wait_for_jenkins():\n+            if not session.get(\"http://localhost:8080\").status_code == 200:\n+                raise Exception(\"Jenkins did not start successfully.\")\n+\n+        redo.retry(wait_for_jenkins, sleeptime=0.5, jitter=0, sleepscale=1,\n+                   attempts=120)\n+\n+    def kill(self):\n+        self.proc.kill()\n+\n+\n+class VirtualEnv(object):\n+    def __init__(self):\n+        if os.path.exists(DIR_TEST_ENV):\n+            print \"Using virtual environment in \", DIR_TEST_ENV\n+            return\n+\n+        tar_fname = 'virtualenv-%s.tar.gz' % VERSION_VIRTUALENV\n+        print ('Creating a virtual environment (version %s) in %s'\n+               % (VERSION_VIRTUALENV, DIR_TEST_ENV))\n+        urllib.urlretrieve(\n+            ('https://pypi.python.org/packages/source/v/virtualenv/%s'\n+             % tar_fname),\n+            tar_fname\n+        )\n+\n+        tar = tarfile.open(name=tar_fname)\n+        tar.extractall(path='.')\n+        check_call([sys.executable,\n+                    \"virtualenv-%s/virtualenv.py\" % VERSION_VIRTUALENV,\n+                    DIR_TEST_ENV])\n+\n+    def activate(self):\n+        activate_this_file = os.path.join(DIR_TEST_ENV, 'bin',\n+                                          'activate_this.py')\n+        execfile(activate_this_file, dict(__file__=activate_this_file))\n+\n+    def run(self, *args, **kwargs):\n+        check_call(args, **kwargs)\n+\n+\n+def run_tests():\n+    print \"Checking patches\"\n+    check_call([\"./test/check_patches.sh\"])\n+\n+    if not os.path.exists(DIR_JENKINS_ENV):\n+        sys.exit(\"Jenkins env is not initialized. Please run './setup.sh'\")\n+    print \"Starting Jenkins\"\n+    os.environ[\"JENKINS_HOME\"] = \"jenkins-master\"\n+    jenkins = Jenkins()\n+    try:\n+        jenkins.wait_for_started()\n+        venv = VirtualEnv()\n+        venv.activate()\n+        venv.run('pip', 'install', 'selenium')\n+        venv.run('python', \"test/configuration/save_config.py\")\n+    except Exception as exc:","path":"run_tests.py","position":90,"original_position":90,"commit_id":"d75b722cb4398e2c8575a19140debafb2c7cf68a","original_commit_id":"d75b722cb4398e2c8575a19140debafb2c7cf68a","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":"aybe we should remove that now ? In case of a failure, maybe it is acceptable for this script to keep the full stack trace.","created_at":"2015-11-12T08:34:35Z","updated_at":"2015-11-12T08:34:35Z","html_url":"https://github.com/mozilla/mozmill-ci/pull/687#discussion_r44631723","pull_request_url":"https://api.github.com/repos/mozilla/mozmill-ci/pulls/687","_links":{"self":{"href":"https://api.github.com/repos/mozilla/mozmill-ci/pulls/comments/44631723"},"html":{"href":"https://github.com/mozilla/mozmill-ci/pull/687#discussion_r44631723"},"pull_request":{"href":"https://api.github.com/repos/mozilla/mozmill-ci/pulls/687"}}},"pull_request":{"url":"https://api.github.com/repos/mozilla/mozmill-ci/pulls/687","id":50283404,"html_url":"https://github.com/mozilla/mozmill-ci/pull/687","diff_url":"https://github.com/mozilla/mozmill-ci/pull/687.diff","patch_url":"https://github.com/mozilla/mozmill-ci/pull/687.patch","issue_url":"https://api.github.com/repos/mozilla/mozmill-ci/issues/687","number":687,"state":"open","locked":false,"title":"Convert run_tests.sh to a Python script (#498)","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":"This should address issue #498.\r\n\r\nIf we can get rid of start.py (moving the code in the new run_tests.py) then it will be easier to kill jenkins at the end, since we will only have to terminate/kill it. I was not sure so I kept the file, tell me if it can be removed.","created_at":"2015-11-10T17:21:00Z","updated_at":"2015-11-12T08:34:35Z","closed_at":null,"merged_at":null,"merge_commit_sha":"c461a718407502cdbe32df2cb57034b214d5394c","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/mozilla/mozmill-ci/pulls/687/commits","review_comments_url":"https://api.github.com/repos/mozilla/mozmill-ci/pulls/687/comments","review_comment_url":"https://api.github.com/repos/mozilla/mozmill-ci/pulls/comments{/number}","comments_url":"https://api.github.com/repos/mozilla/mozmill-ci/issues/687/comments","statuses_url":"https://api.github.com/repos/mozilla/mozmill-ci/statuses/d75b722cb4398e2c8575a19140debafb2c7cf68a","head":{"label":"parkouss:run_tests.py","ref":"run_tests.py","sha":"d75b722cb4398e2c8575a19140debafb2c7cf68a","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":45920334,"name":"mozmill-ci","full_name":"parkouss/mozmill-ci","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/mozmill-ci","description":"Mozmill continuous integration system driven by Mozilla Pulse and Jenkins","fork":true,"url":"https://api.github.com/repos/parkouss/mozmill-ci","forks_url":"https://api.github.com/repos/parkouss/mozmill-ci/forks","keys_url":"https://api.github.com/repos/parkouss/mozmill-ci/keys{/key_id}","collaborators_url":"https://api.github.com/repos/parkouss/mozmill-ci/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/parkouss/mozmill-ci/teams","hooks_url":"https://api.github.com/repos/parkouss/mozmill-ci/hooks","issue_events_url":"https://api.github.com/repos/parkouss/mozmill-ci/issues/events{/number}","events_url":"https://api.github.com/repos/parkouss/mozmill-ci/events","assignees_url":"https://api.github.com/repos/parkouss/mozmill-ci/assignees{/user}","branches_url":"https://api.github.com/repos/parkouss/mozmill-ci/branches{/branch}","tags_url":"https://api.github.com/repos/parkouss/mozmill-ci/tags","blobs_url":"https://api.github.com/repos/parkouss/mozmill-ci/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/parkouss/mozmill-ci/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/parkouss/mozmill-ci/git/refs{/sha}","trees_url":"https://api.github.com/repos/parkouss/mozmill-ci/git/trees{/sha}","statuses_url":"https://api.github.com/repos/parkouss/mozmill-ci/statuses/{sha}","languages_url":"https://api.github.com/repos/parkouss/mozmill-ci/languages","stargazers_url":"https://api.github.com/repos/parkouss/mozmill-ci/stargazers","contributors_url":"https://api.github.com/repos/parkouss/mozmill-ci/contributors","subscribers_url":"https://api.github.com/repos/parkouss/mozmill-ci/subscribers","subscription_url":"https://api.github.com/repos/parkouss/mozmill-ci/subscription","commits_url":"https://api.github.com/repos/parkouss/mozmill-ci/commits{/sha}","git_commits_url":"https://api.github.com/repos/parkouss/mozmill-ci/git/commits{/sha}","comments_url":"https://api.github.com/repos/parkouss/mozmill-ci/comments{/number}","issue_comment_url":"https://api.github.com/repos/parkouss/mozmill-ci/issues/comments{/number}","contents_url":"https://api.github.com/repos/parkouss/mozmill-ci/contents/{+path}","compare_url":"https://api.github.com/repos/parkouss/mozmill-ci/compare/{base}...{head}","merges_url":"https://api.github.com/repos/parkouss/mozmill-ci/merges","archive_url":"https://api.github.com/repos/parkouss/mozmill-ci/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/parkouss/mozmill-ci/downloads","issues_url":"https://api.github.com/repos/parkouss/mozmill-ci/issues{/number}","pulls_url":"https://api.github.com/repos/parkouss/mozmill-ci/pulls{/number}","milestones_url":"https://api.github.com/repos/parkouss/mozmill-ci/milestones{/number}","notifications_url":"https://api.github.com/repos/parkouss/mozmill-ci/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/parkouss/mozmill-ci/labels{/name}","releases_url":"https://api.github.com/repos/parkouss/mozmill-ci/releases{/id}","created_at":"2015-11-10T15:19:11Z","updated_at":"2015-11-10T15:19:13Z","pushed_at":"2015-11-12T08:33:00Z","git_url":"git://github.com/parkouss/mozmill-ci.git","ssh_url":"git@github.com:parkouss/mozmill-ci.git","clone_url":"https://github.com/parkouss/mozmill-ci.git","svn_url":"https://github.com/parkouss/mozmill-ci","homepage":"https://wiki.mozilla.org/QA/Automation/Projects/Mozmill_Automation/Mozmill_CI","size":71761,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"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":"mozilla:master","ref":"master","sha":"d391ad2513df0eefcafd1f8d83c830ffc0ca0e97","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":3037564,"name":"mozmill-ci","full_name":"mozilla/mozmill-ci","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/mozmill-ci","description":"Mozmill continuous integration system driven by Mozilla Pulse and Jenkins","fork":false,"url":"https://api.github.com/repos/mozilla/mozmill-ci","forks_url":"https://api.github.com/repos/mozilla/mozmill-ci/forks","keys_url":"https://api.github.com/repos/mozilla/mozmill-ci/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mozilla/mozmill-ci/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mozilla/mozmill-ci/teams","hooks_url":"https://api.github.com/repos/mozilla/mozmill-ci/hooks","issue_events_url":"https://api.github.com/repos/mozilla/mozmill-ci/issues/events{/number}","events_url":"https://api.github.com/repos/mozilla/mozmill-ci/events","assignees_url":"https://api.github.com/repos/mozilla/mozmill-ci/assignees{/user}","branches_url":"https://api.github.com/repos/mozilla/mozmill-ci/branches{/branch}","tags_url":"https://api.github.com/repos/mozilla/mozmill-ci/tags","blobs_url":"https://api.github.com/repos/mozilla/mozmill-ci/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mozilla/mozmill-ci/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mozilla/mozmill-ci/git/refs{/sha}","trees_url":"https://api.github.com/repos/mozilla/mozmill-ci/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mozilla/mozmill-ci/statuses/{sha}","languages_url":"https://api.github.com/repos/mozilla/mozmill-ci/languages","stargazers_url":"https://api.github.com/repos/mozilla/mozmill-ci/stargazers","contributors_url":"https://api.github.com/repos/mozilla/mozmill-ci/contributors","subscribers_url":"https://api.github.com/repos/mozilla/mozmill-ci/subscribers","subscription_url":"https://api.github.com/repos/mozilla/mozmill-ci/subscription","commits_url":"https://api.github.com/repos/mozilla/mozmill-ci/commits{/sha}","git_commits_url":"https://api.github.com/repos/mozilla/mozmill-ci/git/commits{/sha}","comments_url":"https://api.github.com/repos/mozilla/mozmill-ci/comments{/number}","issue_comment_url":"https://api.github.com/repos/mozilla/mozmill-ci/issues/comments{/number}","contents_url":"https://api.github.com/repos/mozilla/mozmill-ci/contents/{+path}","compare_url":"https://api.github.com/repos/mozilla/mozmill-ci/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mozilla/mozmill-ci/merges","archive_url":"https://api.github.com/repos/mozilla/mozmill-ci/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mozilla/mozmill-ci/downloads","issues_url":"https://api.github.com/repos/mozilla/mozmill-ci/issues{/number}","pulls_url":"https://api.github.com/repos/mozilla/mozmill-ci/pulls{/number}","milestones_url":"https://api.github.com/repos/mozilla/mozmill-ci/milestones{/number}","notifications_url":"https://api.github.com/repos/mozilla/mozmill-ci/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mozilla/mozmill-ci/labels{/name}","releases_url":"https://api.github.com/repos/mozilla/mozmill-ci/releases{/id}","created_at":"2011-12-23T00:33:51Z","updated_at":"2015-06-27T01:04:39Z","pushed_at":"2015-11-12T08:33:01Z","git_url":"git://github.com/mozilla/mozmill-ci.git","ssh_url":"git@github.com:mozilla/mozmill-ci.git","clone_url":"https://github.com/mozilla/mozmill-ci.git","svn_url":"https://github.com/mozilla/mozmill-ci","homepage":"https://wiki.mozilla.org/QA/Automation/Projects/Mozmill_Automation/Mozmill_CI","size":71761,"stargazers_count":16,"watchers_count":16,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":20,"mirror_url":null,"open_issues_count":43,"forks":20,"open_issues":43,"watchers":16,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/mozilla/mozmill-ci/pulls/687"},"html":{"href":"https://github.com/mozilla/mozmill-ci/pull/687"},"issue":{"href":"https://api.github.com/repos/mozilla/mozmill-ci/issues/687"},"comments":{"href":"https://api.github.com/repos/mozilla/mozmill-ci/issues/687/comments"},"review_comments":{"href":"https://api.github.com/repos/mozilla/mozmill-ci/pulls/687/comments"},"review_comment":{"href":"https://api.github.com/repos/mozilla/mozmill-ci/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/mozilla/mozmill-ci/pulls/687/commits"},"statuses":{"href":"https://api.github.com/repos/mozilla/mozmill-ci/statuses/d75b722cb4398e2c8575a19140debafb2c7cf68a"}}}}