Extend execute_live to handle input

use the new functionality for docker drun
This commit is contained in:
bom 2024-02-23 15:21:56 +01:00
parent 48452baac5
commit 3cc6206d06

View file

@ -58,8 +58,8 @@ class ImageApi:
) )
def drun(self, name: str): def drun(self, name: str):
self.execution_api.execute( self.execution_api.execute_live(
f'docker run -it --entrypoint="" {name} /bin/bash' f'docker run -it {name} /bin/bash'
) )
def dockerhub_login(self, username: str, password: str): def dockerhub_login(self, username: str, password: str):
@ -121,13 +121,10 @@ class ExecutionApi:
if dry_run: if dry_run:
print(command) print(command)
else: else:
process = Popen(command, stdout=PIPE, shell=shell) process = Popen(command, shell=shell)
for line in iter(process.stdout.readline, b""): outs, _ = process.communicate()
print(line.decode("utf-8"), end="") while outs is not None:
process.stdout.close() stdout.buffer.write(outs)
return_code = process.wait()
if return_code != 0:
raise RuntimeError(f"Execute live failed with code: {return_code}")
class EnvironmentApi: class EnvironmentApi: