From 6a0e906ac7e1c831b083d4983d819e613d45392a Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Thu, 20 Jun 2019 18:59:53 +0000 Subject: Fixing some logic issues in sys_command --- archinstall.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'archinstall.py') diff --git a/archinstall.py b/archinstall.py index 41e3feec..22993f7f 100644 --- a/archinstall.py +++ b/archinstall.py @@ -156,6 +156,7 @@ class sys_command(): alive = True trace_log = b'' + last_trigger_pos = 0 while alive: for fileno, event in poller.poll(0.1): try: @@ -170,20 +171,27 @@ class sys_command(): print(output) lower = output.lower() + broke = False if 'triggers' in self.opts: for trigger in list(self.opts['triggers']): - if trigger.lower() in trace_log.lower(): + if trigger.lower() in trace_log[last_trigger_pos:].lower(): if 'debug' in self.opts and self.opts['debug']: print('[N] Writing to subsystem: {}'.format(self.opts['triggers'][trigger].decode('UTF-8'))) + + last_trigger_pos = len(trace_log) os.write(child_fd, self.opts['triggers'][trigger]) del(self.opts['triggers'][trigger]) + broke = True break + if broke: + continue + ## Adding a exit trigger: if len(self.opts['triggers']) == 0: if 'debug' in self.opts and self.opts['debug']: print('[N] Waiting for last command to finish...') - if bytes(f'[root@{args["hostname"]} ~]#'.lower(), 'UTF-8') in output[-len(f'[root@{args["hostname"]} ~]#')-5:].lower(): + if bytes(f'[root@{args["hostname"]} ~]#'.lower(), 'UTF-8') in trace_log[-len(f'[root@{args["hostname"]} ~]#')-5:].lower(): if 'debug' in self.opts and self.opts['debug']: print('[N] Last command finished, exiting subsystem.') alive = False -- cgit v1.2.3-70-g09d2