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

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

Issue 12218091: Android Telemetry: automates devices running "user" build. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 10 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 696 matching lines...) Expand 10 before | Expand all | Expand 10 after
707 _TEMP_FILE_BASE_FMT = 'temp_file_%d' 707 _TEMP_FILE_BASE_FMT = 'temp_file_%d'
708 _TEMP_SCRIPT_FILE_BASE_FMT = 'temp_script_file_%d.sh' 708 _TEMP_SCRIPT_FILE_BASE_FMT = 'temp_script_file_%d.sh'
709 709
710 def _GetDeviceTempFileName(self, base_name): 710 def _GetDeviceTempFileName(self, base_name):
711 i = 0 711 i = 0
712 while self.FileExistsOnDevice( 712 while self.FileExistsOnDevice(
713 self.GetExternalStorage() + '/' + base_name % i): 713 self.GetExternalStorage() + '/' + base_name % i):
714 i += 1 714 i += 1
715 return self.GetExternalStorage() + '/' + base_name % i 715 return self.GetExternalStorage() + '/' + base_name % i
716 716
717 def GetProtectedFileContents(self, filename, log_result=False):
718 """Gets contents from the protected file specified by |filename|.
719
720 This is less efficient than GetFileContents, but will work for protected
721 files and device files.
722 """
723 temp_script = self._GetDeviceTempFileName(
724 AndroidCommands._TEMP_SCRIPT_FILE_BASE_FMT)
725 self.SetFileContents(temp_script,
726 'if [ -f "' + filename + '" ]; then cat "' + filename + '"; fi')
727 # Run the script as root
728 return self.RunShellCommand('su -c sh %s' % temp_script)
Sami 2013/02/11 14:57:13 Any reason why we can't just do 'su -c cat "%s" 2>
bulach 2013/02/11 18:47:25 great idea, looks better... :) fixed GetFileConten
729
717 def SetProtectedFileContents(self, filename, contents): 730 def SetProtectedFileContents(self, filename, contents):
718 """Writes |contents| to the protected file specified by |filename|. 731 """Writes |contents| to the protected file specified by |filename|.
719 732
720 This is less efficient than SetFileContents, but will work for protected 733 This is less efficient than SetFileContents, but will work for protected
721 files and device files. 734 files and device files.
722 """ 735 """
723 temp_file = self._GetDeviceTempFileName(AndroidCommands._TEMP_FILE_BASE_FMT) 736 temp_file = self._GetDeviceTempFileName(AndroidCommands._TEMP_FILE_BASE_FMT)
724 temp_script = self._GetDeviceTempFileName( 737 temp_script = self._GetDeviceTempFileName(
725 AndroidCommands._TEMP_SCRIPT_FILE_BASE_FMT) 738 AndroidCommands._TEMP_SCRIPT_FILE_BASE_FMT)
726 739
(...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after
1190 """ 1203 """
1191 def __init__(self, output): 1204 def __init__(self, output):
1192 self._output = output 1205 self._output = output
1193 1206
1194 def write(self, data): 1207 def write(self, data):
1195 data = data.replace('\r\r\n', '\n') 1208 data = data.replace('\r\r\n', '\n')
1196 self._output.write(data) 1209 self._output.write(data)
1197 1210
1198 def flush(self): 1211 def flush(self):
1199 self._output.flush() 1212 self._output.flush()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698