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

Side by Side Diff: build/android/pylib/device/device_utils.py

Issue 255783008: Add option to wipe device. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix nits. Created 6 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « build/android/provision_devices.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2014 The Chromium Authors. All rights reserved. 1 # Copyright 2014 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 """ 5 """
6 Provides a variety of device interactions based on adb. 6 Provides a variety of device interactions based on adb.
7 7
8 Eventually, this will be based on adb_wrapper. 8 Eventually, this will be based on adb_wrapper.
9 """ 9 """
10 10
11 import multiprocessing
12 import os
13 import sys
11 import pylib.android_commands 14 import pylib.android_commands
12 from pylib.device import adb_wrapper 15 from pylib.device import adb_wrapper
13 16
17 CHROME_SRC_DIR = os.path.abspath(
18 os.path.join(os.path.dirname(__file__), '..', '..', '..', '..'))
19 sys.path.append(os.path.join(
20 CHROME_SRC_DIR, 'third_party', 'android_testrunner'))
21 import errors
14 22
15 def GetAVDs(): 23 def GetAVDs():
16 return pylib.android_commands.GetAVDs() 24 return pylib.android_commands.GetAVDs()
17 25
18 26
27 # multiprocessing map_async requires a top-level function for pickle library.
28 def RebootDeviceSafe(device):
29 """Reboot a device, wait for it to start, and squelch timeout exceptions."""
30 try:
31 DeviceUtils(device).old_interface.Reboot(True)
32 except errors.DeviceUnresponsiveError as e:
33 return e
34
35
36 def RebootDevices():
37 """Reboot all attached and online devices."""
38 devices = pylib.android_commands.GetAttachedDevices()
39 print 'Rebooting: %s' % devices
40 if devices:
41 pool = multiprocessing.Pool(len(devices))
42 results = pool.map_async(RebootDeviceSafe, devices).get(99999)
43
44 for device, result in zip(devices, results):
45 if result:
46 print '%s failed to startup.' % device
47
48 if any(results):
49 print 'RebootDevices() Warning: %s' % results
50 else:
51 print 'Reboots complete.'
52
53
19 class DeviceUtils(object): 54 class DeviceUtils(object):
20 55
21 def __init__(self, device): 56 def __init__(self, device):
22 self.old_interface = None 57 self.old_interface = None
23 if isinstance(device, basestring): 58 if isinstance(device, basestring):
24 self.old_interface = pylib.android_commands.AndroidCommands(device) 59 self.old_interface = pylib.android_commands.AndroidCommands(device)
25 elif isinstance(device, adb_wrapper.AdbWrapper): 60 elif isinstance(device, adb_wrapper.AdbWrapper):
26 self.old_interface = pylib.android_commands.AndroidCommands(str(device)) 61 self.old_interface = pylib.android_commands.AndroidCommands(str(device))
27 elif isinstance(device, pylib.android_commands.AndroidCommands): 62 elif isinstance(device, pylib.android_commands.AndroidCommands):
28 self.old_interface = device 63 self.old_interface = device
29 elif not device: 64 elif not device:
30 self.old_interface = pylib.android_commands.AndroidCommands() 65 self.old_interface = pylib.android_commands.AndroidCommands()
31 66
OLDNEW
« no previous file with comments | « build/android/provision_devices.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698