Skip to content

Commit

Permalink
isolate: raise when --init or --cleanup fail
Browse files Browse the repository at this point in the history
  • Loading branch information
seirl committed Mar 4, 2017
1 parent 2a740d0 commit 7028b0c
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions camisole/isolate.py
Expand Up @@ -76,7 +76,10 @@ async def __aenter__(self):
self.cmd_base = ['isolate', '--box-id', str(self.box_id), '--cg']

cmd_init = self.cmd_base + ['--init']
retcode, stdout, _ = await communicate(cmd_init)
retcode, stdout, stderr = await communicate(cmd_init)
if retcode != 0:
raise RuntimeError("{} returned code {}: “{}”".format(
cmd_init, retcode, stderr))
self.path = pathlib.Path(stdout.strip().decode()) / 'box'
self.meta_file = tempfile.NamedTemporaryFile(prefix='camisole-meta-')
self.meta_file.__enter__()
Expand Down Expand Up @@ -119,7 +122,10 @@ async def __aexit__(self, exc, value, tb):
}

cmd_cleanup = self.cmd_base + ['--cleanup']
await communicate(cmd_cleanup)
retcode, stdout, stderr = await communicate(cmd_cleanup)
if retcode != 0:
raise RuntimeError("{} returned code {}: “{}”".format(
cmd_init, retcode, stderr))

self.meta_file.__exit__(exc, value, tb)

Expand Down

0 comments on commit 7028b0c

Please sign in to comment.