def events(): ll = [] def handler(item): ll.append(item) cmd = ShellCommand('tail', '/var/log/syslog') yield 'event: ping\n' yield 'data: Executing "{}"\n\n'.format(cmd) asyncio.set_event_loop(LOOP) future = asyncio.ensure_future(cmd.run(handler), loop=LOOP) while LOOP.run_until_complete(future): while ll: yield 'event: ping\n' yield 'data: {}\n\n'.format(ll.pop(0)) else: if future.done(): break asyncio.sleep(.1) yield 'event: close\n' yield 'data: Done! Command {cmd}. Exit Code {exit_code}\n\n'.format( cmd=cmd, exit_code=future.result().exit_code )
def link(self, builder): if len(self.objects) == 0: return False compiler = builder.toolchain.compiler target = builder.output_file(self) flags = map(lambda x: x.path, self.objects) + self.ldflags + ['-o', target] cmd = ShellCommand(compiler, flags) builder.print_msg('LD', target) code, output = cmd.run(verbose=builder.verbose) print output.strip() return code == 0
def compile_object(self, builder, source, flags=None): compiler = builder.toolchain.compiler obj = os.path.join(builder.tmpdir, source.objectfile) if source.is_newer(obj) is False: return {'source': source, 'status': 'skipped'} flags = [] if flags is None else flags include = self._gen_include_flags() flags = [source.path, '-c'] + include + self.cflags + flags + ['-o', obj] cmd = ShellCommand(compiler, flags) code, output = cmd.run(verbose=builder.verbose) if 0 == code: status = 'success' self.compiled_objects += [obj] else: status = 'failed' return {'source': source, 'status': status, 'output': output}