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

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

Issue 1261763004: Remove handling code for android_command in pylib. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove 2 more TODO comments Created 5 years, 4 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/perf/cache_control.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
11 11
12 from pylib import cmd_helper 12 from pylib import cmd_helper
13 from pylib import constants 13 from pylib import constants
14 from pylib import valgrind_tools 14 from pylib import valgrind_tools
15 15
16 # TODO(jbudorick) Remove once telemetry gets switched over.
17 import pylib.android_commands
18 import pylib.device.device_utils 16 import pylib.device.device_utils
19 17
20 18
21 def _GetProcessStartTime(pid): 19 def _GetProcessStartTime(pid):
22 return psutil.Process(pid).create_time 20 return psutil.Process(pid).create_time
23 21
24 22
25 class _FileLock(object): 23 class _FileLock(object):
26 """With statement-aware implementation of a file lock. 24 """With statement-aware implementation of a file lock.
27 25
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 port will by dynamically assigned on the device. You can 64 port will by dynamically assigned on the device. You can
67 get the number of the assigned port using the 65 get the number of the assigned port using the
68 DevicePortForHostPort method. 66 DevicePortForHostPort method.
69 device: A DeviceUtils instance. 67 device: A DeviceUtils instance.
70 tool: Tool class to use to get wrapper, if necessary, for executing the 68 tool: Tool class to use to get wrapper, if necessary, for executing the
71 forwarder (see valgrind_tools.py). 69 forwarder (see valgrind_tools.py).
72 70
73 Raises: 71 Raises:
74 Exception on failure to forward the port. 72 Exception on failure to forward the port.
75 """ 73 """
76 # TODO(jbudorick) Remove once telemetry gets switched over.
77 assert not isinstance(device, pylib.android_commands.AndroidCommands)
78 if not tool: 74 if not tool:
79 tool = valgrind_tools.CreateTool(None, device) 75 tool = valgrind_tools.CreateTool(None, device)
80 with _FileLock(Forwarder._LOCK_PATH): 76 with _FileLock(Forwarder._LOCK_PATH):
81 instance = Forwarder._GetInstanceLocked(tool) 77 instance = Forwarder._GetInstanceLocked(tool)
82 instance._InitDeviceLocked(device, tool) 78 instance._InitDeviceLocked(device, tool)
83 79
84 device_serial = str(device) 80 device_serial = str(device)
85 redirection_commands = [ 81 redirection_commands = [
86 ['--adb=' + constants.GetAdbPath(), 82 ['--adb=' + constants.GetAdbPath(),
87 '--serial-id=' + device_serial, 83 '--serial-id=' + device_serial,
(...skipping 27 matching lines...) Expand all
115 device_port, host_port) 111 device_port, host_port)
116 112
117 @staticmethod 113 @staticmethod
118 def UnmapDevicePort(device_port, device): 114 def UnmapDevicePort(device_port, device):
119 """Unmaps a previously forwarded device port. 115 """Unmaps a previously forwarded device port.
120 116
121 Args: 117 Args:
122 device: A DeviceUtils instance. 118 device: A DeviceUtils instance.
123 device_port: A previously forwarded port (through Map()). 119 device_port: A previously forwarded port (through Map()).
124 """ 120 """
125 # TODO(jbudorick) Remove once telemetry gets switched over.
126 assert not isinstance(device, pylib.android_commands.AndroidCommands)
127 with _FileLock(Forwarder._LOCK_PATH): 121 with _FileLock(Forwarder._LOCK_PATH):
128 Forwarder._UnmapDevicePortLocked(device_port, device) 122 Forwarder._UnmapDevicePortLocked(device_port, device)
129 123
130 @staticmethod 124 @staticmethod
131 def UnmapAllDevicePorts(device): 125 def UnmapAllDevicePorts(device):
132 """Unmaps all the previously forwarded ports for the provided device. 126 """Unmaps all the previously forwarded ports for the provided device.
133 127
134 Args: 128 Args:
135 device: A DeviceUtils instance. 129 device: A DeviceUtils instance.
136 port_pairs: A list of tuples (device_port, host_port) to unmap. 130 port_pairs: A list of tuples (device_port, host_port) to unmap.
137 """ 131 """
138 # TODO(jbudorick) Remove once telemetry gets switched over.
139 assert not isinstance(device, pylib.android_commands.AndroidCommands)
140 with _FileLock(Forwarder._LOCK_PATH): 132 with _FileLock(Forwarder._LOCK_PATH):
141 if not Forwarder._instance: 133 if not Forwarder._instance:
142 return 134 return
143 adb_serial = str(device) 135 adb_serial = str(device)
144 if adb_serial not in Forwarder._instance._initialized_devices: 136 if adb_serial not in Forwarder._instance._initialized_devices:
145 return 137 return
146 port_map = Forwarder._GetInstanceLocked( 138 port_map = Forwarder._GetInstanceLocked(
147 None)._device_to_host_port_map 139 None)._device_to_host_port_map
148 for (device_serial, device_port) in port_map.keys(): 140 for (device_serial, device_port) in port_map.keys():
149 if adb_serial == device_serial: 141 if adb_serial == device_serial:
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 logging.info('Killing device_forwarder.') 311 logging.info('Killing device_forwarder.')
320 Forwarder._instance._initialized_devices.discard(str(device)) 312 Forwarder._instance._initialized_devices.discard(str(device))
321 if not device.FileExists(Forwarder._DEVICE_FORWARDER_PATH): 313 if not device.FileExists(Forwarder._DEVICE_FORWARDER_PATH):
322 return 314 return
323 315
324 cmd = '%s %s --kill-server' % (tool.GetUtilWrapper(), 316 cmd = '%s %s --kill-server' % (tool.GetUtilWrapper(),
325 Forwarder._DEVICE_FORWARDER_PATH) 317 Forwarder._DEVICE_FORWARDER_PATH)
326 device.RunShellCommand( 318 device.RunShellCommand(
327 cmd, env={'LD_LIBRARY_PATH': Forwarder._DEVICE_FORWARDER_FOLDER}, 319 cmd, env={'LD_LIBRARY_PATH': Forwarder._DEVICE_FORWARDER_FOLDER},
328 check_return=True) 320 check_return=True)
OLDNEW
« no previous file with comments | « build/android/pylib/flag_changer.py ('k') | build/android/pylib/perf/cache_control.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698