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

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

Issue 477153003: [Android] Make adb shell commands with single quotes run correctly. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 4 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 | build/android/pylib/device_settings.py » ('j') | 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 695 matching lines...) Expand 10 before | Expand all | Expand 10 after
706 timeout_time: Number of seconds to wait for command to respond before 706 timeout_time: Number of seconds to wait for command to respond before
707 retrying, used by AdbInterface.SendShellCommand. 707 retrying, used by AdbInterface.SendShellCommand.
708 log_result: Boolean to indicate whether we should log the result of the 708 log_result: Boolean to indicate whether we should log the result of the
709 shell command. 709 shell command.
710 710
711 Returns: 711 Returns:
712 list containing the lines of output received from running the command 712 list containing the lines of output received from running the command
713 """ 713 """
714 self._LogShell(command) 714 self._LogShell(command)
715 if "'" in command: 715 if "'" in command:
716 logging.warning(command + " contains ' quotes") 716 command = command.replace('\'', '\'\\\'\'')
717 result = self._adb.SendShellCommand( 717 result = self._adb.SendShellCommand(
718 "'%s'" % command, timeout_time).splitlines() 718 "'%s'" % command, timeout_time).splitlines()
719 # TODO(b.kelemen): we should really be able to drop the stderr of the 719 # TODO(b.kelemen): we should really be able to drop the stderr of the
720 # command or raise an exception based on what the caller wants. 720 # command or raise an exception based on what the caller wants.
721 result = [ l for l in result if not l.startswith('WARNING') ] 721 result = [ l for l in result if not l.startswith('WARNING') ]
722 if ['error: device not found'] == result: 722 if ['error: device not found'] == result:
723 raise errors.DeviceUnresponsiveError('device not found') 723 raise errors.DeviceUnresponsiveError('device not found')
724 if log_result: 724 if log_result:
725 self._LogShell('\n'.join(result)) 725 self._LogShell('\n'.join(result))
726 return result 726 return result
(...skipping 1225 matching lines...) Expand 10 before | Expand all | Expand 10 after
1952 """ 1952 """
1953 def __init__(self, output): 1953 def __init__(self, output):
1954 self._output = output 1954 self._output = output
1955 1955
1956 def write(self, data): 1956 def write(self, data):
1957 data = data.replace('\r\r\n', '\n') 1957 data = data.replace('\r\r\n', '\n')
1958 self._output.write(data) 1958 self._output.write(data)
1959 1959
1960 def flush(self): 1960 def flush(self):
1961 self._output.flush() 1961 self._output.flush()
OLDNEW
« no previous file with comments | « no previous file | build/android/pylib/device_settings.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698