summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/process.py
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2016-05-12 08:30:35 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-05-16 23:32:40 +0100
commitbc8971d122a02ed823acf0758da267dccc584f98 (patch)
treedd97329507feb611e64fad7f46d97d657f23eae4 /bitbake/lib/bb/process.py
parente2f4d9f1ec694768b223decb59a9c768a2da962d (diff)
downloadpoky-bc8971d122a02ed823acf0758da267dccc584f98.tar.gz
bitbake: bitbake: Convert to python 3 megacommit This needs breaking up into smaller changes.
(Bitbake rev: cf51f19aed208a75d38c14cd585d9b9f115e3ba3) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/bb/process.py')
-rw-r--r--bitbake/lib/bb/process.py32
1 files changed, 22 insertions, 10 deletions
diff --git a/bitbake/lib/bb/process.py b/bitbake/lib/bb/process.py
index 1c07f2d9b7..28b899694a 100644
--- a/bitbake/lib/bb/process.py
+++ b/bitbake/lib/bb/process.py
@@ -17,7 +17,7 @@ class CmdError(RuntimeError):
17 self.msg = msg 17 self.msg = msg
18 18
19 def __str__(self): 19 def __str__(self):
20 if not isinstance(self.command, basestring): 20 if not isinstance(self.command, str):
21 cmd = subprocess.list2cmdline(self.command) 21 cmd = subprocess.list2cmdline(self.command)
22 else: 22 else:
23 cmd = self.command 23 cmd = self.command
@@ -97,6 +97,8 @@ def _logged_communicate(pipe, log, input, extrafiles):
97 try: 97 try:
98 while pipe.poll() is None: 98 while pipe.poll() is None:
99 rlist = rin 99 rlist = rin
100 stdoutbuf = b""
101 stderrbuf = b""
100 try: 102 try:
101 r,w,e = select.select (rlist, [], [], 1) 103 r,w,e = select.select (rlist, [], [], 1)
102 except OSError as e: 104 except OSError as e:
@@ -104,16 +106,26 @@ def _logged_communicate(pipe, log, input, extrafiles):
104 raise 106 raise
105 107
106 if pipe.stdout in r: 108 if pipe.stdout in r:
107 data = pipe.stdout.read() 109 data = stdoutbuf + pipe.stdout.read()
108 if data is not None: 110 if data is not None and len(data) > 0:
109 outdata.append(data) 111 try:
110 log.write(data) 112 data = data.decode("utf-8")
113 outdata.append(data)
114 log.write(data)
115 stdoutbuf = b""
116 except UnicodeDecodeError:
117 stdoutbuf = data
111 118
112 if pipe.stderr in r: 119 if pipe.stderr in r:
113 data = pipe.stderr.read() 120 data = stderrbuf + pipe.stderr.read()
114 if data is not None: 121 if data is not None and len(data) > 0:
115 errdata.append(data) 122 try:
116 log.write(data) 123 data = data.decode("utf-8")
124 errdata.append(data)
125 log.write(data)
126 stderrbuf = b""
127 except UnicodeDecodeError:
128 stderrbuf = data
117 129
118 readextras(r) 130 readextras(r)
119 131
@@ -135,7 +147,7 @@ def run(cmd, input=None, log=None, extrafiles=None, **options):
135 if not extrafiles: 147 if not extrafiles:
136 extrafiles = [] 148 extrafiles = []
137 149
138 if isinstance(cmd, basestring) and not "shell" in options: 150 if isinstance(cmd, str) and not "shell" in options:
139 options["shell"] = True 151 options["shell"] = True
140 152
141 try: 153 try: