summaryrefslogtreecommitdiff
path: root/tools/patman/cros_subprocess.py
AgeCommit message (Collapse)AuthorFilesLines
2019-07-11patman: Provide a way to get program output in binary modeSimon Glass1-1/+2
At present cros_subprocess and the tools library use a string to obtain stdout from a program. This works fine on Python 2. With Python 3 we end up with unicode errors in some cases. Fix this by providing a binary mode, which returns the data as bytes() instead of a string. Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-11patman: Update cros_subprocess to use bytesSimon Glass1-20/+27
At present this function uses lists and strings. This does not work so well with Python 3, and testing against '' does not work for a bytearray. Update the code to fix these issues. Signed-off-by: Simon Glass <sjg@chromium.org>
2017-06-09patman: Don't convert input data to unicodeSimon Glass1-4/+0
The communication filter reads data in blocks and converts each block to unicode (if necessary) one at a time. In the unlikely event that a unicode character in the input spans a block this will not work. We get an error like: UnicodeDecodeError: 'utf8' codec can't decode bytes in position 1022-1023: unexpected end of data There is no need to change the input to unicode, so the easiest fix is to drop this feature. Signed-off-by: Simon Glass <sjg@chromium.org> Tested-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
2017-04-13patman: Convert byte arrays to stringsGeorge McCollister1-0/+4
os.read() returns a byte array in Python 3.5.2 and needs to be converted into a string. Check if the returned value is an instance of bytes and if it is decode it as a utf-8 string. If it is not a utf-8 encoded string the decoding may fail with an exception. Prior to this fix the comparisions check data == "" would fail when data was b'' and would cause an infinite memory leaking loop. joins would also fail with an exception below but due to the infinite loop it never made it that far. Signed-off-by: George McCollister <george.mccollister@gmail.com> Acked-by: Simon Glass <sjg@chromium.org>
2016-10-09patman: Make exception handling python 3.x safePaul Burton1-1/+1
Syntax for exception handling is a little more strict in python 3.x. Convert all uses to a form accepted by both python 2.x & python 3.x. Signed-off-by: Paul Burton <paul.burton@imgtec.com> Acked-by: Simon Glass <sjg@chromium.org>
2013-04-05patman: Add cros_subprocess library to manage subprocessesSimon Glass1-0/+397
This adds a new library on top of subprocess which permits access to the subprocess output as it is being generated. We can therefore give the illusion that a process is running independently, but still monitor its output so that we know what is going on. It is possible to display output on a terminal as it is generated (a little like tee). The supplied output function is called with all stdout/stderr data as it arrives. Signed-off-by: Simon Glass <sjg@chromium.org>