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

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

Issue 272713002: [Android] Delete temporaries in SetProtectedFileContents. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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
« no previous file with comments | « no previous file | 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 (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 1154 matching lines...) Expand 10 before | Expand all | Expand 10 after
1165 AndroidCommands._TEMP_SCRIPT_FILE_BASE_FMT) 1165 AndroidCommands._TEMP_SCRIPT_FILE_BASE_FMT)
1166 1166
1167 # Put the contents in a temporary file 1167 # Put the contents in a temporary file
1168 self.SetFileContents(temp_file, contents) 1168 self.SetFileContents(temp_file, contents)
1169 # Create a script to copy the file contents to its final destination 1169 # Create a script to copy the file contents to its final destination
1170 self.SetFileContents(temp_script, 'cat %s > %s' % (temp_file, filename)) 1170 self.SetFileContents(temp_script, 'cat %s > %s' % (temp_file, filename))
1171 1171
1172 command = 'sh %s' % temp_script 1172 command = 'sh %s' % temp_script
1173 command_runner = self._GetProtectedFileCommandRunner() 1173 command_runner = self._GetProtectedFileCommandRunner()
1174 if command_runner: 1174 if command_runner:
1175 return command_runner(command) 1175 command_runner(command)
1176 else: 1176 else:
1177 logging.warning('Could not set contents of protected file: %s' % filename) 1177 logging.warning('Could not set contents of protected file: %s' % filename)
1178 1178
1179 # And remove the temporary files 1179 # And remove the temporary files
1180 self.RunShellCommand('rm ' + temp_file) 1180 self.RunShellCommand('rm ' + temp_file)
craigdh 2014/05/08 00:04:10 this should probably be done as a try/finally to e
1181 self.RunShellCommand('rm ' + temp_script) 1181 self.RunShellCommand('rm ' + temp_script)
1182 1182
1183 def RemovePushedFiles(self): 1183 def RemovePushedFiles(self):
1184 """Removes all files pushed with PushIfNeeded() from the device.""" 1184 """Removes all files pushed with PushIfNeeded() from the device."""
1185 for p in self._pushed_files: 1185 for p in self._pushed_files:
1186 self.RunShellCommand('rm -r %s' % p, timeout_time=2 * 60) 1186 self.RunShellCommand('rm -r %s' % p, timeout_time=2 * 60)
1187 1187
1188 def ListPathContents(self, path): 1188 def ListPathContents(self, path):
1189 """Lists files in all subdirectories of |path|. 1189 """Lists files in all subdirectories of |path|.
1190 1190
(...skipping 772 matching lines...) Expand 10 before | Expand all | Expand 10 after
1963 """ 1963 """
1964 def __init__(self, output): 1964 def __init__(self, output):
1965 self._output = output 1965 self._output = output
1966 1966
1967 def write(self, data): 1967 def write(self, data):
1968 data = data.replace('\r\r\n', '\n') 1968 data = data.replace('\r\r\n', '\n')
1969 self._output.write(data) 1969 self._output.write(data)
1970 1970
1971 def flush(self): 1971 def flush(self):
1972 self._output.flush() 1972 self._output.flush()
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698