Chromium Code Reviews| Index: build/android/pylib/device/device_utils.py |
| diff --git a/build/android/pylib/device/device_utils.py b/build/android/pylib/device/device_utils.py |
| index 8a8de22519f3d69bc93681657494ed076eaeba05..7b1af35261b65956a8785a77d586e721fb045c8f 100644 |
| --- a/build/android/pylib/device/device_utils.py |
| +++ b/build/android/pylib/device/device_utils.py |
| @@ -8,6 +8,7 @@ Eventually, this will be based on adb_wrapper. |
| """ |
| # pylint: disable=W0613 |
| +import pipes |
| import sys |
| import time |
| @@ -635,6 +636,31 @@ class DeviceUtils(object): |
| self.old_interface.SetFileContents(device_path, contents) |
| @decorators.WithTimeoutAndRetriesFromInstance() |
| + def WriteTextFile(self, device_path, text, as_root=False, timeout=None, |
| + retries=None): |
|
jbudorick
2014/09/11 13:57:07
nit: line this up with the params above
|
| + """Writes |text| to a file on the device. |
| + |
| + Assuming that |text| is a small string, this is typically more efficient |
| + than |WriteFile|, as no files are pushed into the device. |
| + |
| + Args: |
| + device_path: A string containing the absolute path to the file to write |
| + on the device. |
| + text: A short string of text to write to the file on the device. |
| + as_root: A boolean indicating whether the write should be executed with |
| + root privileges. |
| + timeout: timeout in seconds |
| + retries: number of retries |
| + |
| + Raises: |
| + CommandFailedError if the file could not be written on the device. |
| + CommandTimeoutError on timeout. |
| + DeviceUnreachableError on missing device. |
| + """ |
| + self._RunShellCommandImpl('echo {1} > {0}'.format(device_path, |
| + pipes.quote(text)), check_return=True, as_root=as_root) |
| + |
| + @decorators.WithTimeoutAndRetriesFromInstance() |
| def Ls(self, device_path, timeout=None, retries=None): |
| """Lists the contents of a directory on the device. |