| OLD | NEW |
| 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2012 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 # pylint: disable=W0212 | 5 # pylint: disable=W0212 |
| 6 | 6 |
| 7 import fcntl | 7 import fcntl |
| 8 import logging | 8 import logging |
| 9 import os | 9 import os |
| 10 import psutil | 10 import psutil |
| (...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 263 pid_with_start_time = pid_file.readline() | 263 pid_with_start_time = pid_file.readline() |
| 264 if pid_with_start_time: | 264 if pid_with_start_time: |
| 265 (pid, process_start_time) = pid_with_start_time.split(':') | 265 (pid, process_start_time) = pid_with_start_time.split(':') |
| 266 if pid == str(pid_for_lock): | 266 if pid == str(pid_for_lock): |
| 267 if process_start_time == str(_GetProcessStartTime(pid_for_lock)): | 267 if process_start_time == str(_GetProcessStartTime(pid_for_lock)): |
| 268 return | 268 return |
| 269 self._KillHostLocked() | 269 self._KillHostLocked() |
| 270 pid_file.seek(0) | 270 pid_file.seek(0) |
| 271 pid_file.write( | 271 pid_file.write( |
| 272 '%s:%s' % (pid_for_lock, str(_GetProcessStartTime(pid_for_lock)))) | 272 '%s:%s' % (pid_for_lock, str(_GetProcessStartTime(pid_for_lock)))) |
| 273 pid_file.truncate() |
| 273 | 274 |
| 274 def _InitDeviceLocked(self, device, tool): | 275 def _InitDeviceLocked(self, device, tool): |
| 275 """Initializes the device_forwarder daemon for a specific device (once). | 276 """Initializes the device_forwarder daemon for a specific device (once). |
| 276 | 277 |
| 277 Note that the global lock must be acquired before calling this method. This | 278 Note that the global lock must be acquired before calling this method. This |
| 278 method kills any existing device_forwarder daemon on the device that could | 279 method kills any existing device_forwarder daemon on the device that could |
| 279 be stale, pushes the latest version of the daemon (to the device) and starts | 280 be stale, pushes the latest version of the daemon (to the device) and starts |
| 280 it. | 281 it. |
| 281 | 282 |
| 282 Args: | 283 Args: |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 327 """ | 328 """ |
| 328 logging.info('Killing device_forwarder.') | 329 logging.info('Killing device_forwarder.') |
| 329 Forwarder._instance._initialized_devices.discard(str(device)) | 330 Forwarder._instance._initialized_devices.discard(str(device)) |
| 330 if not device.FileExists(Forwarder._DEVICE_FORWARDER_PATH): | 331 if not device.FileExists(Forwarder._DEVICE_FORWARDER_PATH): |
| 331 return | 332 return |
| 332 | 333 |
| 333 cmd = '%s %s --kill-server' % (tool.GetUtilWrapper(), | 334 cmd = '%s %s --kill-server' % (tool.GetUtilWrapper(), |
| 334 Forwarder._DEVICE_FORWARDER_PATH) | 335 Forwarder._DEVICE_FORWARDER_PATH) |
| 335 device.old_interface.GetAndroidToolStatusAndOutput( | 336 device.old_interface.GetAndroidToolStatusAndOutput( |
| 336 cmd, lib_path=Forwarder._DEVICE_FORWARDER_FOLDER) | 337 cmd, lib_path=Forwarder._DEVICE_FORWARDER_FOLDER) |
| OLD | NEW |