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

Unified Diff: build/android/pylib/device/device_utils.py

Issue 547623002: Simpler logic to setup/restore Chrome command line (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fixed nit (lined up params) Created 6 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « build/android/pylib/android_commands.py ('k') | build/android/pylib/device/device_utils_test.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..c1d6d448d5271938fb46d0bbb44c450c95896427 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):
+ """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.
« no previous file with comments | « build/android/pylib/android_commands.py ('k') | build/android/pylib/device/device_utils_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698