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

Unified Diff: build/android/pylib/flag_changer.py

Issue 806843002: Reland of Migrate DeviceUtils.ReadFile to adb_wrapper (try 3) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: enable command line test only for android Created 5 years, 11 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/device/device_utils_test.py ('k') | build/android/pylib/instrumentation/test_runner.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: build/android/pylib/flag_changer.py
diff --git a/build/android/pylib/flag_changer.py b/build/android/pylib/flag_changer.py
index c0bcadbe3bd4a9a47d2146b8a428d8dc9188d92a..718bc3971500b2c94dcaa6606ccc0c364de5ae10 100644
--- a/build/android/pylib/flag_changer.py
+++ b/build/android/pylib/flag_changer.py
@@ -7,6 +7,8 @@ import logging
import pylib.android_commands
import pylib.device.device_utils
+from pylib.device import device_errors
+
class FlagChanger(object):
"""Changes the flags Chrome runs with.
@@ -32,9 +34,10 @@ class FlagChanger(object):
self._cmdline_file = cmdline_file
# Save the original flags.
- self._orig_line = self._device.ReadFile(self._cmdline_file)
- if self._orig_line:
- self._orig_line = self._orig_line[0].strip()
+ try:
+ self._orig_line = self._device.ReadFile(self._cmdline_file).strip()
+ except device_errors.CommandFailedError:
+ self._orig_line = ''
# Parse out the flags into a list to facilitate adding and removing flags.
self._current_flags = self._TokenizeFlags(self._orig_line)
@@ -104,8 +107,8 @@ class FlagChanger(object):
self._device.WriteFile(
self._cmdline_file, cmd_line, as_root=use_root)
file_contents = self._device.ReadFile(
- self._cmdline_file, as_root=use_root)
- assert len(file_contents) == 1 and file_contents[0] == cmd_line, (
+ self._cmdline_file, as_root=use_root).rstrip()
+ assert file_contents == cmd_line, (
'Failed to set the command line file at %s' % self._cmdline_file)
else:
self._device.RunShellCommand('rm ' + self._cmdline_file,
« no previous file with comments | « build/android/pylib/device/device_utils_test.py ('k') | build/android/pylib/instrumentation/test_runner.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698