Output flushing
This commit is contained in:
parent
5f740f3e72
commit
c78874a7e0
@ -101,7 +101,7 @@ class Build(Script):
|
||||
argv += [
|
||||
type(self).__name__.lower(), # script name ?
|
||||
]
|
||||
output(' '.join(argv), 'EXECUTION')
|
||||
output(' '.join(argv), 'EXECUTION', flush=True)
|
||||
|
||||
proc = await asyncio.create_subprocess_shell(
|
||||
shlex.join(argv),
|
||||
|
||||
@ -28,7 +28,7 @@ class Output:
|
||||
self.prefixes = dict()
|
||||
self.prefix_length = 0
|
||||
|
||||
def __call__(self, line, prefix, highlight=True):
|
||||
def __call__(self, line, prefix, highlight=True, flush=True):
|
||||
if prefix and prefix not in self.prefixes:
|
||||
self.prefixes[prefix] = (
|
||||
self.colors[len([*self.prefixes.keys()]) - 1]
|
||||
@ -58,6 +58,9 @@ class Output:
|
||||
+ self.highlight(line, highlight)
|
||||
).encode('utf8'))
|
||||
|
||||
if flush:
|
||||
sys.stdout.flush()
|
||||
|
||||
def cmd(self, line, prefix):
|
||||
self(
|
||||
Fore.LIGHTBLACK_EX
|
||||
@ -108,7 +111,7 @@ class PrefixStreamProtocol(asyncio.subprocess.SubprocessStreamProtocol):
|
||||
for line in data.split(b'\n'):
|
||||
if not line:
|
||||
continue
|
||||
output(line, self.prefix)
|
||||
output(line, self.prefix, flush=False)
|
||||
sys.stdout.flush()
|
||||
super().pipe_data_received(fd, data)
|
||||
|
||||
|
||||
@ -70,11 +70,10 @@ class Script:
|
||||
')'
|
||||
]),
|
||||
getattr(visitor, 'name',
|
||||
getattr(visitable, 'name', None))
|
||||
getattr(visitable, 'name', None)),
|
||||
)
|
||||
if result:
|
||||
await result
|
||||
sys.stdout.flush()
|
||||
|
||||
for prefix in ('init_', 'pre_', '', 'post_', 'clean_'):
|
||||
method = prefix + self.name
|
||||
@ -101,7 +100,6 @@ class Script:
|
||||
except Exception as e:
|
||||
await clean()
|
||||
raise
|
||||
sys.stdout.flush()
|
||||
|
||||
async def run(self, *args, **kwargs):
|
||||
for key, value in kwargs.items():
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user