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

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

Issue 22903016: [android] Adds constants.GetOutDirectory() and converts test scripts to use it. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: update adb_install_apk.py Created 7 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 | Annotate | Revision Log
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 """Provides an interface to communicate with the device via the adb command. 5 """Provides an interface to communicate with the device via the adb command.
6 6
7 Assumes adb binary is currently on system path. 7 Assumes adb binary is currently on system path.
8 """ 8 """
9 9
10 import collections 10 import collections
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 if device: 240 if device:
241 self._adb.SetTargetSerial(device) 241 self._adb.SetTargetSerial(device)
242 self._device = device 242 self._device = device
243 self._logcat = None 243 self._logcat = None
244 self.logcat_process = None 244 self.logcat_process = None
245 self._logcat_tmpoutfile = None 245 self._logcat_tmpoutfile = None
246 self._pushed_files = [] 246 self._pushed_files = []
247 self._device_utc_offset = None 247 self._device_utc_offset = None
248 self._potential_push_size = 0 248 self._potential_push_size = 0
249 self._actual_push_size = 0 249 self._actual_push_size = 0
250 self._md5sum_build_dir = ''
251 self._external_storage = '' 250 self._external_storage = ''
252 self._util_wrapper = '' 251 self._util_wrapper = ''
253 252
254 def _LogShell(self, cmd): 253 def _LogShell(self, cmd):
255 """Logs the adb shell command.""" 254 """Logs the adb shell command."""
256 if self._device: 255 if self._device:
257 device_repr = self._device[-4:] 256 device_repr = self._device[-4:]
258 else: 257 else:
259 device_repr = '????' 258 device_repr = '????'
260 logging.info('[%s]> %s', device_repr, cmd) 259 logging.info('[%s]> %s', device_repr, cmd)
(...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after
772 """Gets the md5sum of a host path and device path. 771 """Gets the md5sum of a host path and device path.
773 772
774 Args: 773 Args:
775 host_path: Path (file or directory) on the host. 774 host_path: Path (file or directory) on the host.
776 device_path: Path on the device. 775 device_path: Path on the device.
777 776
778 Returns: 777 Returns:
779 A tuple containing lists of the host and device md5sum results as 778 A tuple containing lists of the host and device md5sum results as
780 created by _ParseMd5SumOutput(). 779 created by _ParseMd5SumOutput().
781 """ 780 """
782 if not self._md5sum_build_dir: 781 md5sum_dist_path = os.path.join(constants.GetBuildDirectory(),
783 default_build_type = os.environ.get('BUILD_TYPE', 'Debug') 782 'md5sum_dist')
784 build_dir = '%s/%s/' % ( 783 assert os.path.exists(md5sum_dist_path), 'Please build md5sum.'
785 cmd_helper.OutDirectory().get(), default_build_type) 784 command = 'push %s %s' % (md5sum_dist_path, MD5SUM_DEVICE_FOLDER)
786 md5sum_dist_path = '%s/md5sum_dist' % build_dir 785 assert _HasAdbPushSucceeded(self._adb.SendCommand(command))
787 if not os.path.exists(md5sum_dist_path):
788 build_dir = '%s/Release/' % cmd_helper.OutDirectory().get()
789 md5sum_dist_path = '%s/md5sum_dist' % build_dir
790 assert os.path.exists(md5sum_dist_path), 'Please build md5sum.'
791 command = 'push %s %s' % (md5sum_dist_path, MD5SUM_DEVICE_FOLDER)
792 assert _HasAdbPushSucceeded(self._adb.SendCommand(command))
793 self._md5sum_build_dir = build_dir
794 786
795 cmd = (MD5SUM_LD_LIBRARY_PATH + ' ' + self._util_wrapper + ' ' + 787 cmd = (MD5SUM_LD_LIBRARY_PATH + ' ' + self._util_wrapper + ' ' +
796 MD5SUM_DEVICE_PATH + ' ' + device_path) 788 MD5SUM_DEVICE_PATH + ' ' + device_path)
797 device_hash_tuples = _ParseMd5SumOutput( 789 device_hash_tuples = _ParseMd5SumOutput(
798 self.RunShellCommand(cmd, timeout_time=2 * 60)) 790 self.RunShellCommand(cmd, timeout_time=2 * 60))
799 assert os.path.exists(host_path), 'Local path not found %s' % host_path 791 assert os.path.exists(host_path), 'Local path not found %s' % host_path
800 md5sum_output = cmd_helper.GetCmdOutput( 792 md5sum_output = cmd_helper.GetCmdOutput(
801 ['%s/md5sum_bin_host' % self._md5sum_build_dir, host_path]) 793 [os.path.join(constants.GetBuildDirectory(), 'md5sum_bin_host'),
794 host_path])
802 host_hash_tuples = _ParseMd5SumOutput(md5sum_output.splitlines()) 795 host_hash_tuples = _ParseMd5SumOutput(md5sum_output.splitlines())
803 return (host_hash_tuples, device_hash_tuples) 796 return (host_hash_tuples, device_hash_tuples)
804 797
805 def GetFilesChanged(self, host_path, device_path): 798 def GetFilesChanged(self, host_path, device_path):
806 """Compares the md5sum of a host path against a device path. 799 """Compares the md5sum of a host path against a device path.
807 800
808 Note: Ignores extra files on the device. 801 Note: Ignores extra files on the device.
809 802
810 Args: 803 Args:
811 host_path: Path (file or directory) on the host. 804 host_path: Path (file or directory) on the host.
(...skipping 730 matching lines...) Expand 10 before | Expand all | Expand 10 after
1542 """ 1535 """
1543 def __init__(self, output): 1536 def __init__(self, output):
1544 self._output = output 1537 self._output = output
1545 1538
1546 def write(self, data): 1539 def write(self, data):
1547 data = data.replace('\r\r\n', '\n') 1540 data = data.replace('\r\r\n', '\n')
1548 self._output.write(data) 1541 self._output.write(data)
1549 1542
1550 def flush(self): 1543 def flush(self):
1551 self._output.flush() 1544 self._output.flush()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698