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

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

Issue 895853003: Update from https://crrev.com/314320 (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 10 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
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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 if isinstance(device, pylib.android_commands.AndroidCommands): 83 if isinstance(device, pylib.android_commands.AndroidCommands):
84 device = pylib.device.device_utils.DeviceUtils(device) 84 device = pylib.device.device_utils.DeviceUtils(device)
85 if not tool: 85 if not tool:
86 tool = valgrind_tools.CreateTool(None, device) 86 tool = valgrind_tools.CreateTool(None, device)
87 with _FileLock(Forwarder._LOCK_PATH): 87 with _FileLock(Forwarder._LOCK_PATH):
88 instance = Forwarder._GetInstanceLocked(tool) 88 instance = Forwarder._GetInstanceLocked(tool)
89 instance._InitDeviceLocked(device, tool) 89 instance._InitDeviceLocked(device, tool)
90 90
91 device_serial = str(device) 91 device_serial = str(device)
92 redirection_commands = [ 92 redirection_commands = [
93 ['--serial-id=' + device_serial, '--map', str(device_port), 93 ['--adb=' + constants.GetAdbPath(),
94 str(host_port)] for device_port, host_port in port_pairs] 94 '--serial-id=' + device_serial,
95 '--map', str(device_port), str(host_port)]
96 for device_port, host_port in port_pairs]
95 logging.info('Forwarding using commands: %s', redirection_commands) 97 logging.info('Forwarding using commands: %s', redirection_commands)
96 98
97 for redirection_command in redirection_commands: 99 for redirection_command in redirection_commands:
98 try: 100 try:
99 (exit_code, output) = cmd_helper.GetCmdStatusAndOutput( 101 (exit_code, output) = cmd_helper.GetCmdStatusAndOutput(
100 [instance._host_forwarder_path] + redirection_command) 102 [instance._host_forwarder_path] + redirection_command)
101 except OSError as e: 103 except OSError as e:
102 if e.errno == 2: 104 if e.errno == 2:
103 raise Exception('Unable to start host forwarder. Make sure you have' 105 raise Exception('Unable to start host forwarder. Make sure you have'
104 ' built host_forwarder.') 106 ' built host_forwarder.')
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 """Internal method used by UnmapDevicePort(). 222 """Internal method used by UnmapDevicePort().
221 223
222 Note that the global lock must be acquired before calling this method. 224 Note that the global lock must be acquired before calling this method.
223 """ 225 """
224 instance = Forwarder._GetInstanceLocked(None) 226 instance = Forwarder._GetInstanceLocked(None)
225 serial = str(device) 227 serial = str(device)
226 serial_with_port = (serial, device_port) 228 serial_with_port = (serial, device_port)
227 if not serial_with_port in instance._device_to_host_port_map: 229 if not serial_with_port in instance._device_to_host_port_map:
228 logging.error('Trying to unmap non-forwarded port %d' % device_port) 230 logging.error('Trying to unmap non-forwarded port %d' % device_port)
229 return 231 return
230 redirection_command = ['--serial-id=' + serial, '--unmap', str(device_port)] 232 redirection_command = ['--adb=' + constants.GetAdbPath(),
233 '--serial-id=' + serial,
234 '--unmap', str(device_port)]
231 (exit_code, output) = cmd_helper.GetCmdStatusAndOutput( 235 (exit_code, output) = cmd_helper.GetCmdStatusAndOutput(
232 [instance._host_forwarder_path] + redirection_command) 236 [instance._host_forwarder_path] + redirection_command)
233 if exit_code != 0: 237 if exit_code != 0:
234 logging.error('%s exited with %d:\n%s' % ( 238 logging.error('%s exited with %d:\n%s' % (
235 instance._host_forwarder_path, exit_code, '\n'.join(output))) 239 instance._host_forwarder_path, exit_code, '\n'.join(output)))
236 host_port = instance._device_to_host_port_map[serial_with_port] 240 host_port = instance._device_to_host_port_map[serial_with_port]
237 del instance._device_to_host_port_map[serial_with_port] 241 del instance._device_to_host_port_map[serial_with_port]
238 del instance._host_to_device_port_map[host_port] 242 del instance._host_to_device_port_map[host_port]
239 243
240 @staticmethod 244 @staticmethod
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 """ 332 """
329 logging.info('Killing device_forwarder.') 333 logging.info('Killing device_forwarder.')
330 Forwarder._instance._initialized_devices.discard(str(device)) 334 Forwarder._instance._initialized_devices.discard(str(device))
331 if not device.FileExists(Forwarder._DEVICE_FORWARDER_PATH): 335 if not device.FileExists(Forwarder._DEVICE_FORWARDER_PATH):
332 return 336 return
333 337
334 cmd = '%s %s --kill-server' % (tool.GetUtilWrapper(), 338 cmd = '%s %s --kill-server' % (tool.GetUtilWrapper(),
335 Forwarder._DEVICE_FORWARDER_PATH) 339 Forwarder._DEVICE_FORWARDER_PATH)
336 device.old_interface.GetAndroidToolStatusAndOutput( 340 device.old_interface.GetAndroidToolStatusAndOutput(
337 cmd, lib_path=Forwarder._DEVICE_FORWARDER_FOLDER) 341 cmd, lib_path=Forwarder._DEVICE_FORWARDER_FOLDER)
OLDNEW
« no previous file with comments | « build/android/pylib/device/device_utils_test.py ('k') | build/android/pylib/gtest/gtest_test_instance.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698