| OLD | NEW |
| 1 from __future__ import print_function | 1 from __future__ import print_function |
| 2 | 2 |
| 3 import argparse | 3 import argparse |
| 4 import logging | 4 import logging |
| 5 import os | 5 import os |
| 6 import re | 6 import re |
| 7 import stat | 7 import stat |
| 8 import subprocess | 8 import subprocess |
| 9 import sys | 9 import sys |
| 10 import tarfile | 10 import tarfile |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 # Value must be boxed to support modification from inner function scope | 130 # Value must be boxed to support modification from inner function scope |
| 131 count = [0] | 131 count = [0] |
| 132 capacity -= 2 + len(warning_msg) | 132 capacity -= 2 + len(warning_msg) |
| 133 stderr = sys.stderr | 133 stderr = sys.stderr |
| 134 | 134 |
| 135 def on_write(handle, msg): | 135 def on_write(handle, msg): |
| 136 length = len(msg) | 136 length = len(msg) |
| 137 count[0] += length | 137 count[0] += length |
| 138 | 138 |
| 139 if count[0] > capacity: | 139 if count[0] > capacity: |
| 140 sys.stdout.disable() | 140 wrapped_stdout.disable() |
| 141 sys.stderr.disable() | 141 wrapped_stderr.disable() |
| 142 handle.write(msg[0:capacity - count[0]]) | 142 handle.write(msg[0:capacity - count[0]]) |
| 143 handle.flush() | 143 handle.flush() |
| 144 stderr.write("\n%s\n" % warning_msg) | 144 stderr.write("\n%s\n" % warning_msg) |
| 145 return False | 145 return False |
| 146 | 146 |
| 147 return True | 147 return True |
| 148 | 148 |
| 149 sys.stdout = FilteredIO(sys.stdout, on_write) | 149 # Store local references to the replaced streams to guard against the case |
| 150 sys.stderr = FilteredIO(sys.stderr, on_write) | 150 # where other code replace the global references. |
| 151 sys.stdout = wrapped_stdout = FilteredIO(sys.stdout, on_write) |
| 152 sys.stderr = wrapped_stderr = FilteredIO(sys.stderr, on_write) |
| 151 | 153 |
| 152 | 154 |
| 153 class Browser(object): | 155 class Browser(object): |
| 154 __metaclass__ = ABCMeta | 156 __metaclass__ = ABCMeta |
| 155 | 157 |
| 156 @abstractmethod | 158 @abstractmethod |
| 157 def install(self): | 159 def install(self): |
| 158 return NotImplemented | 160 return NotImplemented |
| 159 | 161 |
| 160 @abstractmethod | 162 @abstractmethod |
| (...skipping 15 matching lines...) Expand all Loading... |
| 176 Includes installation, webdriver installation, and wptrunner setup methods. | 178 Includes installation, webdriver installation, and wptrunner setup methods. |
| 177 """ | 179 """ |
| 178 | 180 |
| 179 product = "firefox" | 181 product = "firefox" |
| 180 binary = "%s/firefox/firefox" | 182 binary = "%s/firefox/firefox" |
| 181 platform_ini = "%s/firefox/platform.ini" | 183 platform_ini = "%s/firefox/platform.ini" |
| 182 | 184 |
| 183 def install(self): | 185 def install(self): |
| 184 """Install Firefox.""" | 186 """Install Firefox.""" |
| 185 call("pip", "install", "-r", os.path.join(wptrunner_root, "requirements_
firefox.txt")) | 187 call("pip", "install", "-r", os.path.join(wptrunner_root, "requirements_
firefox.txt")) |
| 186 resp = get("https://archive.mozilla.org/pub/firefox/nightly/latest-mozil
la-central/firefox-53.0a1.en-US.linux-x86_64.tar.bz2") | 188 index = get("https://archive.mozilla.org/pub/firefox/nightly/latest-mozi
lla-central/") |
| 189 latest = re.compile("<a[^>]*>(firefox-\d+\.\d(?:\w\d)?.en-US.linux-x86_6
4\.tar\.bz2)</a>") |
| 190 filename = latest.search(index.text).group(1) |
| 191 resp = get("https://archive.mozilla.org/pub/firefox/nightly/latest-mozil
la-central/%s" % |
| 192 filename) |
| 187 untar(resp.raw) | 193 untar(resp.raw) |
| 188 | 194 |
| 189 if not os.path.exists("profiles"): | 195 if not os.path.exists("profiles"): |
| 190 os.mkdir("profiles") | 196 os.mkdir("profiles") |
| 191 with open(os.path.join("profiles", "prefs_general.js"), "wb") as f: | 197 with open(os.path.join("profiles", "prefs_general.js"), "wb") as f: |
| 192 resp = get("https://hg.mozilla.org/mozilla-central/raw-file/tip/test
ing/profiles/prefs_general.js") | 198 resp = get("https://hg.mozilla.org/mozilla-central/raw-file/tip/test
ing/profiles/prefs_general.js") |
| 193 f.write(resp.content) | 199 f.write(resp.content) |
| 194 call("pip", "install", "-r", os.path.join(wptrunner_root, "requirements_
firefox.txt")) | 200 call("pip", "install", "-r", os.path.join(wptrunner_root, "requirements_
firefox.txt")) |
| 195 | 201 |
| 196 def _latest_geckodriver_version(self): | 202 def _latest_geckodriver_version(self): |
| (...skipping 559 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 756 return retcode | 762 return retcode |
| 757 | 763 |
| 758 | 764 |
| 759 if __name__ == "__main__": | 765 if __name__ == "__main__": |
| 760 try: | 766 try: |
| 761 retcode = main() | 767 retcode = main() |
| 762 except: | 768 except: |
| 763 raise | 769 raise |
| 764 else: | 770 else: |
| 765 sys.exit(retcode) | 771 sys.exit(retcode) |
| OLD | NEW |