Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(491)

Side by Side Diff: build/android/pylib/forwarder.py

Issue 358993003: [Android] Switch to DeviceUtils versions of file functions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « build/android/pylib/flag_changer.py ('k') | build/android/pylib/gtest/test_package_apk.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 283
284 Args: 284 Args:
285 device: A DeviceUtils instance. 285 device: A DeviceUtils instance.
286 tool: Tool class to use to get wrapper, if necessary, for executing the 286 tool: Tool class to use to get wrapper, if necessary, for executing the
287 forwarder (see valgrind_tools.py). 287 forwarder (see valgrind_tools.py).
288 """ 288 """
289 device_serial = device.old_interface.Adb().GetSerialNumber() 289 device_serial = device.old_interface.Adb().GetSerialNumber()
290 if device_serial in self._initialized_devices: 290 if device_serial in self._initialized_devices:
291 return 291 return
292 Forwarder._KillDeviceLocked(device, tool) 292 Forwarder._KillDeviceLocked(device, tool)
293 device.old_interface.PushIfNeeded( 293 device.PushChangedFiles(
294 self._device_forwarder_path_on_host, 294 self._device_forwarder_path_on_host,
295 Forwarder._DEVICE_FORWARDER_FOLDER) 295 Forwarder._DEVICE_FORWARDER_FOLDER)
296 cmd = '%s %s' % (tool.GetUtilWrapper(), Forwarder._DEVICE_FORWARDER_PATH) 296 cmd = '%s %s' % (tool.GetUtilWrapper(), Forwarder._DEVICE_FORWARDER_PATH)
297 (exit_code, output) = device.old_interface.GetAndroidToolStatusAndOutput( 297 (exit_code, output) = device.old_interface.GetAndroidToolStatusAndOutput(
298 cmd, lib_path=Forwarder._DEVICE_FORWARDER_FOLDER) 298 cmd, lib_path=Forwarder._DEVICE_FORWARDER_FOLDER)
299 if exit_code != 0: 299 if exit_code != 0:
300 raise Exception( 300 raise Exception(
301 'Failed to start device forwarder:\n%s' % '\n'.join(output)) 301 'Failed to start device forwarder:\n%s' % '\n'.join(output))
302 self._initialized_devices.add(device_serial) 302 self._initialized_devices.add(device_serial)
303 303
(...skipping 17 matching lines...) Expand all
321 """Kills the forwarder process running on the device. 321 """Kills the forwarder process running on the device.
322 322
323 Note that the global lock must be acquired before calling this method. 323 Note that the global lock must be acquired before calling this method.
324 324
325 Args: 325 Args:
326 device: Instance of DeviceUtils for talking to the device. 326 device: Instance of DeviceUtils for talking to the device.
327 tool: Wrapper tool (e.g. valgrind) that can be used to execute the device 327 tool: Wrapper tool (e.g. valgrind) that can be used to execute the device
328 forwarder (see valgrind_tools.py). 328 forwarder (see valgrind_tools.py).
329 """ 329 """
330 logging.info('Killing device_forwarder.') 330 logging.info('Killing device_forwarder.')
331 if not device.old_interface.FileExistsOnDevice( 331 if not device.FileExists(Forwarder._DEVICE_FORWARDER_PATH):
332 Forwarder._DEVICE_FORWARDER_PATH):
333 return 332 return
334 333
335 cmd = '%s %s --kill-server' % (tool.GetUtilWrapper(), 334 cmd = '%s %s --kill-server' % (tool.GetUtilWrapper(),
336 Forwarder._DEVICE_FORWARDER_PATH) 335 Forwarder._DEVICE_FORWARDER_PATH)
337 device.old_interface.GetAndroidToolStatusAndOutput( 336 device.old_interface.GetAndroidToolStatusAndOutput(
338 cmd, lib_path=Forwarder._DEVICE_FORWARDER_FOLDER) 337 cmd, lib_path=Forwarder._DEVICE_FORWARDER_FOLDER)
339 338
340 # TODO(pliard): Remove the following call to KillAllBlocking() when we are 339 # TODO(pliard): Remove the following call to KillAllBlocking() when we are
341 # sure that the old version of device_forwarder (not supporting 340 # sure that the old version of device_forwarder (not supporting
342 # 'kill-server') is not running on the bots anymore. 341 # 'kill-server') is not running on the bots anymore.
343 timeout_sec = 5 342 timeout_sec = 5
344 try: 343 try:
345 device.KillAll( 344 device.KillAll(
346 'device_forwarder', blocking=True, timeout=timeout_sec) 345 'device_forwarder', blocking=True, timeout=timeout_sec)
347 except device_errors.CommandFailedError: 346 except device_errors.CommandFailedError:
348 pids = device.old_interface.ExtractPid('device_forwarder') 347 pids = device.old_interface.ExtractPid('device_forwarder')
349 if pids: 348 if pids:
350 raise 349 raise
OLDNEW
« no previous file with comments | « build/android/pylib/flag_changer.py ('k') | build/android/pylib/gtest/test_package_apk.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698