| OLD | NEW |
| 1 # Copyright 2013 The Chromium Authors. All rights reserved. | 1 # Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 import contextlib | 5 import contextlib |
| 6 import httplib | 6 import httplib |
| 7 import json | 7 import json |
| 8 import logging | 8 import logging |
| 9 import pprint | 9 import pprint |
| 10 import re | 10 import re |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 except util.TimeoutException: | 187 except util.TimeoutException: |
| 188 logging.error('ExtensionsToLoad: ' + | 188 logging.error('ExtensionsToLoad: ' + |
| 189 repr([e.extension_id for e in self._extensions_to_load])) | 189 repr([e.extension_id for e in self._extensions_to_load])) |
| 190 logging.error('Extension list: ' + | 190 logging.error('Extension list: ' + |
| 191 pprint.pformat(self.extension_backend, indent=4)) | 191 pprint.pformat(self.extension_backend, indent=4)) |
| 192 raise | 192 raise |
| 193 | 193 |
| 194 def ListInspectableContexts(self): | 194 def ListInspectableContexts(self): |
| 195 return json.loads(self.Request('')) | 195 return json.loads(self.Request('')) |
| 196 | 196 |
| 197 def Request(self, path, timeout=5, throw_network_exception=False): | 197 def Request(self, path, timeout=30, throw_network_exception=False): |
| 198 url = 'http://127.0.0.1:%i/json' % self._port | 198 url = 'http://127.0.0.1:%i/json' % self._port |
| 199 if path: | 199 if path: |
| 200 url += '/' + path | 200 url += '/' + path |
| 201 try: | 201 try: |
| 202 proxy_handler = urllib2.ProxyHandler({}) # Bypass any system proxy. | 202 proxy_handler = urllib2.ProxyHandler({}) # Bypass any system proxy. |
| 203 opener = urllib2.build_opener(proxy_handler) | 203 opener = urllib2.build_opener(proxy_handler) |
| 204 with contextlib.closing(opener.open(url, timeout=timeout)) as req: | 204 with contextlib.closing(opener.open(url, timeout=timeout)) as req: |
| 205 return req.read() | 205 return req.read() |
| 206 except (socket.error, httplib.BadStatusLine, urllib2.URLError) as e: | 206 except (socket.error, httplib.BadStatusLine, urllib2.URLError) as e: |
| 207 if throw_network_exception: | 207 if throw_network_exception: |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 312 | 312 |
| 313 @property | 313 @property |
| 314 def supports_system_info(self): | 314 def supports_system_info(self): |
| 315 return self.GetSystemInfo() != None | 315 return self.GetSystemInfo() != None |
| 316 | 316 |
| 317 def GetSystemInfo(self): | 317 def GetSystemInfo(self): |
| 318 if self._system_info_backend is None: | 318 if self._system_info_backend is None: |
| 319 self._system_info_backend = system_info_backend.SystemInfoBackend( | 319 self._system_info_backend = system_info_backend.SystemInfoBackend( |
| 320 self._port) | 320 self._port) |
| 321 return self._system_info_backend.GetSystemInfo() | 321 return self._system_info_backend.GetSystemInfo() |
| OLD | NEW |