OMG such pretty output, such async copy by default

This commit is contained in:
jpic 2020-02-15 21:31:12 +01:00
parent a3a81eaca5
commit f2bad27eb7
4 changed files with 15 additions and 7 deletions

View File

@ -3,4 +3,4 @@ from .base import Action
class Run(Action): class Run(Action):
async def call(self, *args, **kwargs): async def call(self, *args, **kwargs):
return (await self.exec(*self.args, **self.kwargs)) return await self.exec(*self.args, **self.kwargs)

View File

@ -21,7 +21,6 @@ class Actions(list):
class Script(Action): class Script(Action):
root = '/'
contextualize = ['shargs', 'exec', 'rexec', 'env', 'which', 'copy'] contextualize = ['shargs', 'exec', 'rexec', 'env', 'which', 'copy']
def __init__(self, *actions, **kwargs): def __init__(self, *actions, **kwargs):

View File

@ -61,10 +61,18 @@ class Buildah(Localhost):
dst = args[-1] dst = args[-1]
await self.mkdir(dst) await self.mkdir(dst)
args = ['buildah', 'copy', self.ctr] + list( procs = []
[str(a) for a in src] for s in src:
) + [str(dst)] if Path(s).is_dir():
return await self.exec(*args, buildah=False) target = self.mnt / s
if not target.exists():
await self.mkdir(target)
args = ['buildah', 'copy', self.ctr, s, Path(dst) / s]
else:
args = ['buildah', 'copy', self.ctr, s, dst]
procs.append(self.exec(*args, buildah=False))
return await asyncio.gather(*procs)
async def mount(self, src, dst): async def mount(self, src, dst):
"""Mount a host directory into the container.""" """Mount a host directory into the container."""
@ -87,7 +95,7 @@ class Buildah(Localhost):
return p[len(str(self.mnt)):] return p[len(str(self.mnt)):]
def is_wrapper(self): def is_wrapper(self):
return ( return not (
Proc.test Proc.test
or os.getuid() == 0 or os.getuid() == 0
or getattr(self.parent, 'parent', None) or getattr(self.parent, 'parent', None)

View File

@ -30,6 +30,7 @@ class Localhost(Script):
async def exec(self, *args, **kwargs): async def exec(self, *args, **kwargs):
kwargs.setdefault('debug', self.call_kwargs.get('debug', False)) kwargs.setdefault('debug', self.call_kwargs.get('debug', False))
kwargs.setdefault('output', self.output)
args, kwargs = self.shargs(*args, **kwargs) args, kwargs = self.shargs(*args, **kwargs)
proc = await Proc(*args, **kwargs)() proc = await Proc(*args, **kwargs)()
if kwargs.get('wait', True): if kwargs.get('wait', True):