-
Notifications
You must be signed in to change notification settings - Fork 48
Sandbox experiment #1065
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Sandbox experiment #1065
Conversation
Signed-off-by: Paul Mars <[email protected]>
94f92fc to
b8f6657
Compare
Signed-off-by: Paul Mars <[email protected]>
| def __init__(self, target: Path, content: str) -> None: | ||
| self._target = target |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe a name like ContentReplacer or (FileContentReplacer) and then use replace() and restore()? Or even a context manager for that so it could look like:
with FileContentReplacer("/etc/issue"):
do_my_stuff()
If the context manager can't be used it could be something like:
d = FileContentReplacer("/etc/issue")
d.replace()
do_my_stuff()
d.restore()
But the context manager would make more sense in this use case imho.
| try: | ||
| self._setup() | ||
| child.start() | ||
| res, err = parent_conn.recv() | ||
| child.join() | ||
| finally: | ||
| logger.debug("[pid=%d] clean up the sandbox", os.getpid()) | ||
| self._cleanup() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems that this try-finally could be a context manager.
Signed-off-by: Paul Mars <[email protected]>
docs/reference/changelog.rst)?Expand the chroot into a sandbox.
Usage example https://github.com/canonical/imagecraft/tree/work/experiment-chroot