Skip to content

Commit 4407cfa

Browse files
committed
toolchain log output cosmetic
1 parent 8f04c7b commit 4407cfa

File tree

3 files changed

+17
-6
lines changed

3 files changed

+17
-6
lines changed

pythonforandroid/bootstraps/pygame/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def run_distribute(self):
4444
hostpython = sh.Command(self.ctx.hostpython)
4545
# AND: This *doesn't* need to be in arm env?
4646
shprint(hostpython, '-OO', '-m', 'compileall', self.ctx.get_python_install_dir(),
47-
_tail=10, _critical=True)
47+
_tail=10, _filterout="^Listing", _critical=True)
4848
if not exists('python-install'):
4949
shprint(sh.cp, '-a', self.ctx.get_python_install_dir(), './python-install')
5050

pythonforandroid/bootstraps/sdl2/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ def run_distribute(self):
3434
hostpython = sh.Command(self.ctx.hostpython)
3535
# AND: This *doesn't* need to be in arm env?
3636
shprint(hostpython, '-OO', '-m', 'compileall',
37-
self.ctx.get_python_install_dir())
37+
self.ctx.get_python_install_dir(),
38+
_tail=10, _filterout="^Listing", _critical=True)
3839
if not exists('python-install'):
3940
shprint(sh.cp, '-a', self.ctx.get_python_install_dir(), './python-install')
4041

pythonforandroid/toolchain.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,8 @@ def shprint(command, *args, **kwargs):
127127
kwargs["_bg"] = True
128128
is_critical = kwargs.pop('_critical', False)
129129
tail_n = kwargs.pop('_tail', 0)
130+
filter_in = kwargs.pop('_filter', None)
131+
filter_out = kwargs.pop('_filterout', None)
130132
if len(logger.handlers) > 1:
131133
logger.removeHandler(logger.handlers[1])
132134
try:
@@ -161,16 +163,24 @@ def shprint(command, *args, **kwargs):
161163
if need_closing_newline: sys.stdout.write('{}\r{:>{width}}\r'.format(Style.RESET_ALL, ' ', width=(columns - 1)))
162164
except sh.ErrorReturnCode, err:
163165
if need_closing_newline: sys.stdout.write('{}\r{:>{width}}\r'.format(Style.RESET_ALL, ' ', width=(columns - 1)))
164-
if tail_n:
165-
def printtail(name, forecolor, tail_n, out):
166+
if tail_n or filter_in or filter_out:
167+
def printtail(out, name, forecolor, tail_n = 0, re_filter_in = None, re_filter_out = None):
166168
lines = out.splitlines()
169+
if re_filter_in is not None: lines = [l for l in lines if re_filter_in.search(l)]
170+
if re_filter_out is not None: lines = [l for l in lines if not re_filter_out.search(l)]
167171
if tail_n == 0 or len(lines) <= tail_n:
168172
info('{}:\n{}\t{}{}'.format(name, forecolor, '\t\n'.join(lines), Fore.RESET))
169173
else:
170174
info('{} (last {} lines of {}):\n{}\t{}{}'.format(name, tail_n, len(lines), forecolor, '\t\n'.join(lines[-tail_n:]), Fore.RESET))
171-
printtail('STDOUT', Fore.YELLOW, tail_n, err.stdout)
172-
printtail('STDERR', Fore.RED, 0, err.stderr)
175+
printtail(err.stdout, 'STDOUT', Fore.YELLOW, tail_n,
176+
re.compile(filter_in) if filter_in else None,
177+
re.compile(filter_out) if filter_out else None)
178+
printtail(err.stderr, 'STDERR', Fore.RED)
173179
if is_critical:
180+
env = kwargs.get("env")
181+
if env is not None:
182+
info("{}ENV:{}\n{}\n".format(Fore.YELLOW, Fore.RESET, "\n".join("set {}={}".format(n,v) for n,v in env.items())))
183+
info("{}COMMAND:{}\ncd {} && {} {}\n".format(Fore.YELLOW, Fore.RESET, getcwd(), command, ' '.join(args)))
174184
warning("{}ERROR: {} failed!{}".format(Fore.RED, command, Fore.RESET))
175185
exit(1)
176186
else:

0 commit comments

Comments
 (0)