| 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 re | 7 import re |
| 8 import shutil | 8 import shutil |
| 9 import subprocess | 9 import subprocess |
| 10 import tempfile | 10 import tempfile |
| (...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 340 def StartMonitoringPower(self, browser): | 340 def StartMonitoringPower(self, browser): |
| 341 self._power_monitor.StartMonitoringPower(browser) | 341 self._power_monitor.StartMonitoringPower(browser) |
| 342 | 342 |
| 343 def StopMonitoringPower(self): | 343 def StopMonitoringPower(self): |
| 344 return self._power_monitor.StopMonitoringPower() | 344 return self._power_monitor.StopMonitoringPower() |
| 345 | 345 |
| 346 def GetFileContents(self, fname): | 346 def GetFileContents(self, fname): |
| 347 if not self._can_access_protected_file_contents: | 347 if not self._can_access_protected_file_contents: |
| 348 logging.warning('%s cannot be retrieved on non-rooted device.' % fname) | 348 logging.warning('%s cannot be retrieved on non-rooted device.' % fname) |
| 349 return '' | 349 return '' |
| 350 return '\n'.join(self._device.ReadFile(fname, as_root=True)) | 350 return self._device.ReadFile(fname, as_root=True) |
| 351 | 351 |
| 352 def GetPsOutput(self, columns, pid=None): | 352 def GetPsOutput(self, columns, pid=None): |
| 353 assert columns == ['pid', 'name'] or columns == ['pid'], \ | 353 assert columns == ['pid', 'name'] or columns == ['pid'], \ |
| 354 'Only know how to return pid and name. Requested: ' + columns | 354 'Only know how to return pid and name. Requested: ' + columns |
| 355 command = 'ps' | 355 command = 'ps' |
| 356 if pid: | 356 if pid: |
| 357 command += ' -p %d' % pid | 357 command += ' -p %d' % pid |
| 358 ps = self._device.RunShellCommand(command)[1:] | 358 ps = self._device.RunShellCommand(command)[1:] |
| 359 output = [] | 359 output = [] |
| 360 for line in ps: | 360 for line in ps: |
| (...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 640 if 'cpu_affinity' in dir(process): | 640 if 'cpu_affinity' in dir(process): |
| 641 process.cpu_affinity([0]) # New versions of psutil. | 641 process.cpu_affinity([0]) # New versions of psutil. |
| 642 elif 'set_cpu_affinity' in dir(process): | 642 elif 'set_cpu_affinity' in dir(process): |
| 643 process.set_cpu_affinity([0]) # Older versions. | 643 process.set_cpu_affinity([0]) # Older versions. |
| 644 else: | 644 else: |
| 645 logging.warn( | 645 logging.warn( |
| 646 'Cannot set CPU affinity due to stale psutil version: %s', | 646 'Cannot set CPU affinity due to stale psutil version: %s', |
| 647 '.'.join(str(x) for x in psutil.version_info)) | 647 '.'.join(str(x) for x in psutil.version_info)) |
| 648 except (psutil.NoSuchProcess, psutil.AccessDenied): | 648 except (psutil.NoSuchProcess, psutil.AccessDenied): |
| 649 logging.warn('Failed to set adb process CPU affinity') | 649 logging.warn('Failed to set adb process CPU affinity') |
| OLD | NEW |