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

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

Issue 197883005: [Telementry][Android] Only copy changed or missing files of profile (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add shebang to satisfy presubmit checks Created 6 years, 9 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 | build/android/pylib/efficient_android_directory_copy.sh » ('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 """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 # pylint: disable-all 9 # pylint: disable-all
10 10
(...skipping 1782 matching lines...) Expand 10 before | Expand all | Expand 10 after
1793 package = match.group(2) 1793 package = match.group(2)
1794 logging.warning('Trying to dismiss %s dialog for %s' % match.groups()) 1794 logging.warning('Trying to dismiss %s dialog for %s' % match.groups())
1795 self.SendKeyEvent(KEYCODE_DPAD_RIGHT) 1795 self.SendKeyEvent(KEYCODE_DPAD_RIGHT)
1796 self.SendKeyEvent(KEYCODE_DPAD_RIGHT) 1796 self.SendKeyEvent(KEYCODE_DPAD_RIGHT)
1797 self.SendKeyEvent(KEYCODE_ENTER) 1797 self.SendKeyEvent(KEYCODE_ENTER)
1798 match = _FindFocusedWindow() 1798 match = _FindFocusedWindow()
1799 if match: 1799 if match:
1800 logging.error('Still showing a %s dialog for %s' % match.groups()) 1800 logging.error('Still showing a %s dialog for %s' % match.groups())
1801 return package 1801 return package
1802 1802
1803 def EfficientDeviceDirectoryCopy(self, source, dest):
1804 """ Copy a directory efficiently on the device
1805
1806 Uses a shell script running on the target to copy new and changed files the
1807 source directory to the destination directory and remove added files. This
1808 is in some cases much faster than cp -r.
1809
1810 Args:
1811 source: absolute path of source directory
1812 dest: absolute path of destination directory
1813 """
1814 logging.info('In EfficientDeviceDirectoryCopy %s %s', source, dest)
1815 temp_script_file = self._GetDeviceTempFileName(
1816 AndroidCommands._TEMP_SCRIPT_FILE_BASE_FMT)
1817 host_script_path = os.path.join(constants.DIR_SOURCE_ROOT,
1818 'build',
1819 'android',
1820 'pylib',
1821 'efficient_android_directory_copy.sh')
1822 self._adb.Push(host_script_path, temp_script_file)
1823 self.EnableAdbRoot
1824 out = self.RunShellCommand('sh %s %s %s' % (temp_script_file, source, dest),
1825 timeout_time=120)
1826 if self._device:
1827 device_repr = self._device[-4:]
1828 else:
1829 device_repr = '????'
1830 for line in out:
1831 logging.info('[%s]> %s', device_repr, line)
1832 self.RunShellCommand('rm %s' % temp_script_file)
1833
1803 1834
1804 class NewLineNormalizer(object): 1835 class NewLineNormalizer(object):
1805 """A file-like object to normalize EOLs to '\n'. 1836 """A file-like object to normalize EOLs to '\n'.
1806 1837
1807 Pexpect runs adb within a pseudo-tty device (see 1838 Pexpect runs adb within a pseudo-tty device (see
1808 http://www.noah.org/wiki/pexpect), so any '\n' printed by adb is written 1839 http://www.noah.org/wiki/pexpect), so any '\n' printed by adb is written
1809 as '\r\n' to the logfile. Since adb already uses '\r\n' to terminate 1840 as '\r\n' to the logfile. Since adb already uses '\r\n' to terminate
1810 lines, the log ends up having '\r\r\n' at the end of each line. This 1841 lines, the log ends up having '\r\r\n' at the end of each line. This
1811 filter replaces the above with a single '\n' in the data stream. 1842 filter replaces the above with a single '\n' in the data stream.
1812 """ 1843 """
1813 def __init__(self, output): 1844 def __init__(self, output):
1814 self._output = output 1845 self._output = output
1815 1846
1816 def write(self, data): 1847 def write(self, data):
1817 data = data.replace('\r\r\n', '\n') 1848 data = data.replace('\r\r\n', '\n')
1818 self._output.write(data) 1849 self._output.write(data)
1819 1850
1820 def flush(self): 1851 def flush(self):
1821 self._output.flush() 1852 self._output.flush()
OLDNEW
« no previous file with comments | « no previous file | build/android/pylib/efficient_android_directory_copy.sh » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698