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

Side by Side Diff: mojo/devtools/common/devtoolslib/android_shell.py

Issue 1376603007: Teach mojo_benchmark --save-traces to pull results from Android devices. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Address Etienne's comments. Created 5 years, 2 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 | « no previous file | mojo/devtools/common/mojo_benchmark » ('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 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 import atexit 5 import atexit
6 import hashlib 6 import hashlib
7 import json 7 import json
8 import logging 8 import logging
9 import os 9 import os
10 import os.path 10 import os.path
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 self.adb_running_as_root = False 192 self.adb_running_as_root = False
193 193
194 return self.adb_running_as_root 194 return self.adb_running_as_root
195 195
196 def _is_shell_package_installed(self): 196 def _is_shell_package_installed(self):
197 # Adb should print one line if the package is installed and return empty 197 # Adb should print one line if the package is installed and return empty
198 # string otherwise. 198 # string otherwise.
199 return len(subprocess.check_output(self._adb_command([ 199 return len(subprocess.check_output(self._adb_command([
200 'shell', 'pm', 'list', 'packages', _MOJO_SHELL_PACKAGE_NAME]))) > 0 200 'shell', 'pm', 'list', 'packages', _MOJO_SHELL_PACKAGE_NAME]))) > 0
201 201
202 @staticmethod
203 def get_tmp_dir_path():
204 """Returns a path to a cache directory owned by the shell where temporary
205 files can be stored.
206 """
207 return '/data/data/%s/cache/tmp/' % _MOJO_SHELL_PACKAGE_NAME
208
209 def pull_file(self, device_path, destination_path, remove_original=False):
210 """Copies or moves the specified file on the device to the host."""
211 subprocess.check_call(self._adb_command([
212 'pull', device_path, destination_path]))
213 if remove_original:
214 subprocess.check_call(self._adb_command([
215 'shell', 'rm', device_path]))
216
202 def check_device(self, require_root=False): 217 def check_device(self, require_root=False):
203 """Verifies if the device configuration allows adb to run. 218 """Verifies if the device configuration allows adb to run.
204 219
205 If a target device was indicated in the constructor, it checks that the 220 If a target device was indicated in the constructor, it checks that the
206 device is available. Otherwise, it checks that there is exactly one 221 device is available. Otherwise, it checks that there is exactly one
207 available device. 222 available device.
208 223
209 Returns: 224 Returns:
210 A tuple of (result, msg). |result| is True iff if the device is correctly 225 A tuple of (result, msg). |result| is True iff if the device is correctly
211 configured and False otherwise. |msg| is the reason for failure if 226 configured and False otherwise. |msg| is the reason for failure if
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
421 Results.output = rf.read() 436 Results.output = rf.read()
422 437
423 run_thread = threading.Thread(target=do_run) 438 run_thread = threading.Thread(target=do_run)
424 run_thread.start() 439 run_thread.start()
425 run_thread.join(timeout) 440 run_thread.join(timeout)
426 441
427 if run_thread.is_alive(): 442 if run_thread.is_alive():
428 self.stop_shell() 443 self.stop_shell()
429 return None, Results.output, True 444 return None, Results.output, True
430 return None, Results.output, False 445 return None, Results.output, False
OLDNEW
« no previous file with comments | « no previous file | mojo/devtools/common/mojo_benchmark » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698