Chromium Code Reviews| 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 logging | 5 import logging |
| 6 import os | 6 import os |
| 7 import posixpath | 7 import posixpath |
| 8 import re | 8 import re |
| 9 import subprocess | 9 import subprocess |
| 10 import tempfile | 10 import tempfile |
| (...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 477 old_flag = self._device.GetProp('socket.relaxsslcheck') | 477 old_flag = self._device.GetProp('socket.relaxsslcheck') |
| 478 self._device.SetProp('socket.relaxsslcheck', value) | 478 self._device.SetProp('socket.relaxsslcheck', value) |
| 479 return old_flag | 479 return old_flag |
| 480 | 480 |
| 481 def ForwardHostToDevice(self, host_port, device_port): | 481 def ForwardHostToDevice(self, host_port, device_port): |
| 482 self._device.adb.Forward('tcp:%d' % host_port, device_port) | 482 self._device.adb.Forward('tcp:%d' % host_port, device_port) |
| 483 | 483 |
| 484 def StopForwardingHost(self, host_port): | 484 def StopForwardingHost(self, host_port): |
| 485 for line in self._device.adb.ForwardList().strip().splitlines(): | 485 for line in self._device.adb.ForwardList().strip().splitlines(): |
| 486 line = line.split(' ') | 486 line = line.split(' ') |
| 487 if line[0] == self._device and line[1] == 'tcp:%s' % host_port: | 487 if len(line) >= 2: |
| 488 self._device.adb.ForwardRemove('tcp:%d' % host_port) | 488 if line[0] == self._device and line[1] == 'tcp:%s' % host_port: |
| 489 break | 489 self._device.adb.ForwardRemove('tcp:%d' % host_port) |
| 490 break | |
| 491 else: | |
| 492 logging.warning('Attempted to split line in StopForwardingHost method, ' | |
| 493 'but outcome was unexpected:\n%s' % line) | |
|
mikecase (-- gone --)
2016/10/14 16:58:13
nit: I would reword this error message to somethin
rnephew (Reviews Here)
2016/10/14 17:06:41
Done.
| |
| 490 else: | 494 else: |
| 491 logging.warning('Port %s not found in adb forward --list for device %s', | 495 logging.warning('Port %s not found in adb forward --list for device %s', |
| 492 host_port, self._device) | 496 host_port, self._device) |
| 493 | 497 |
| 494 def DismissCrashDialogIfNeeded(self): | 498 def DismissCrashDialogIfNeeded(self): |
| 495 """Dismiss any error dialogs. | 499 """Dismiss any error dialogs. |
| 496 | 500 |
| 497 Limit the number in case we have an error loop or we are failing to dismiss. | 501 Limit the number in case we have an error loop or we are failing to dismiss. |
| 498 """ | 502 """ |
| 499 for _ in xrange(10): | 503 for _ in xrange(10): |
| (...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 775 for process in psutil.process_iter(): | 779 for process in psutil.process_iter(): |
| 776 try: | 780 try: |
| 777 if psutil.version_info >= (2, 0): | 781 if psutil.version_info >= (2, 0): |
| 778 if 'adb' in process.name(): | 782 if 'adb' in process.name(): |
| 779 process.cpu_affinity([0]) | 783 process.cpu_affinity([0]) |
| 780 else: | 784 else: |
| 781 if 'adb' in process.name: | 785 if 'adb' in process.name: |
| 782 process.set_cpu_affinity([0]) | 786 process.set_cpu_affinity([0]) |
| 783 except (psutil.NoSuchProcess, psutil.AccessDenied): | 787 except (psutil.NoSuchProcess, psutil.AccessDenied): |
| 784 logging.warn('Failed to set adb process CPU affinity') | 788 logging.warn('Failed to set adb process CPU affinity') |
| OLD | NEW |