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

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

Issue 1315743004: [Android] Add a custom pylintrc for build/android/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix appurify_sanitized import-errors Created 5 years, 3 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 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 if adb_serial == device_serial: 145 if adb_serial == device_serial:
146 Forwarder._UnmapDevicePortLocked(device_port, device) 146 Forwarder._UnmapDevicePortLocked(device_port, device)
147 # There are no more ports mapped, kill the device_forwarder. 147 # There are no more ports mapped, kill the device_forwarder.
148 tool = valgrind_tools.CreateTool(None, device) 148 tool = valgrind_tools.CreateTool(None, device)
149 Forwarder._KillDeviceLocked(device, tool) 149 Forwarder._KillDeviceLocked(device, tool)
150 150
151 @staticmethod 151 @staticmethod
152 def DevicePortForHostPort(host_port): 152 def DevicePortForHostPort(host_port):
153 """Returns the device port that corresponds to a given host port.""" 153 """Returns the device port that corresponds to a given host port."""
154 with _FileLock(Forwarder._LOCK_PATH): 154 with _FileLock(Forwarder._LOCK_PATH):
155 (_device_serial, device_port) = Forwarder._GetInstanceLocked( 155 _, device_port = Forwarder._GetInstanceLocked(
156 None)._host_to_device_port_map.get(host_port) 156 None)._host_to_device_port_map.get(host_port)
157 return device_port 157 return device_port
158 158
159 @staticmethod 159 @staticmethod
160 def RemoveHostLog(): 160 def RemoveHostLog():
161 if os.path.exists(Forwarder._HOST_FORWARDER_LOG): 161 if os.path.exists(Forwarder._HOST_FORWARDER_LOG):
162 os.unlink(Forwarder._HOST_FORWARDER_LOG) 162 os.unlink(Forwarder._HOST_FORWARDER_LOG)
163 163
164 @staticmethod 164 @staticmethod
165 def GetHostLog(): 165 def GetHostLog():
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 @staticmethod 207 @staticmethod
208 def _UnmapDevicePortLocked(device_port, device): 208 def _UnmapDevicePortLocked(device_port, device):
209 """Internal method used by UnmapDevicePort(). 209 """Internal method used by UnmapDevicePort().
210 210
211 Note that the global lock must be acquired before calling this method. 211 Note that the global lock must be acquired before calling this method.
212 """ 212 """
213 instance = Forwarder._GetInstanceLocked(None) 213 instance = Forwarder._GetInstanceLocked(None)
214 serial = str(device) 214 serial = str(device)
215 serial_with_port = (serial, device_port) 215 serial_with_port = (serial, device_port)
216 if not serial_with_port in instance._device_to_host_port_map: 216 if not serial_with_port in instance._device_to_host_port_map:
217 logging.error('Trying to unmap non-forwarded port %d' % device_port) 217 logging.error('Trying to unmap non-forwarded port %d', device_port)
218 return 218 return
219 redirection_command = ['--adb=' + constants.GetAdbPath(), 219 redirection_command = ['--adb=' + constants.GetAdbPath(),
220 '--serial-id=' + serial, 220 '--serial-id=' + serial,
221 '--unmap', str(device_port)] 221 '--unmap', str(device_port)]
222 logging.info('Undo forwarding using command: %s', redirection_command) 222 logging.info('Undo forwarding using command: %s', redirection_command)
223 (exit_code, output) = cmd_helper.GetCmdStatusAndOutput( 223 (exit_code, output) = cmd_helper.GetCmdStatusAndOutput(
224 [instance._host_forwarder_path] + redirection_command) 224 [instance._host_forwarder_path] + redirection_command)
225 if exit_code != 0: 225 if exit_code != 0:
226 logging.error('%s exited with %d:\n%s' % ( 226 logging.error(
227 instance._host_forwarder_path, exit_code, '\n'.join(output))) 227 '%s exited with %d:\n%s',
228 instance._host_forwarder_path, exit_code, '\n'.join(output))
228 host_port = instance._device_to_host_port_map[serial_with_port] 229 host_port = instance._device_to_host_port_map[serial_with_port]
229 del instance._device_to_host_port_map[serial_with_port] 230 del instance._device_to_host_port_map[serial_with_port]
230 del instance._host_to_device_port_map[host_port] 231 del instance._host_to_device_port_map[host_port]
231 232
232 @staticmethod 233 @staticmethod
233 def _GetPidForLock(): 234 def _GetPidForLock():
234 """Returns the PID used for host_forwarder initialization. 235 """Returns the PID used for host_forwarder initialization.
235 236
236 The PID of the "sharder" is used to handle multiprocessing. The "sharder" 237 The PID of the "sharder" is used to handle multiprocessing. The "sharder"
237 is the initial process that forks that is the parent process. 238 is the initial process that forks that is the parent process.
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 logging.info('Killing device_forwarder.') 317 logging.info('Killing device_forwarder.')
317 Forwarder._instance._initialized_devices.discard(str(device)) 318 Forwarder._instance._initialized_devices.discard(str(device))
318 if not device.FileExists(Forwarder._DEVICE_FORWARDER_PATH): 319 if not device.FileExists(Forwarder._DEVICE_FORWARDER_PATH):
319 return 320 return
320 321
321 cmd = '%s %s --kill-server' % (tool.GetUtilWrapper(), 322 cmd = '%s %s --kill-server' % (tool.GetUtilWrapper(),
322 Forwarder._DEVICE_FORWARDER_PATH) 323 Forwarder._DEVICE_FORWARDER_PATH)
323 device.RunShellCommand( 324 device.RunShellCommand(
324 cmd, env={'LD_LIBRARY_PATH': Forwarder._DEVICE_FORWARDER_FOLDER}, 325 cmd, env={'LD_LIBRARY_PATH': Forwarder._DEVICE_FORWARDER_FOLDER},
325 check_return=True) 326 check_return=True)
OLDNEW
« no previous file with comments | « build/android/pylib/device_settings.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