MCPcopy Create free account
hub / github.com/archlinux/archinstall / __enter__

Method __enter__

archinstall/lib/boot.py:24–54  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

22 self.ready = False
23
24 def __enter__(self) -> Self:
25 if Boot._active_boot and Boot._active_boot.path != self.path:
26 raise KeyError('Archinstall only supports booting up one instance and another session is already active.')
27
28 if Boot._active_boot:
29 self.session = Boot._active_boot.session
30 self.ready = Boot._active_boot.ready
31 else:
32 # '-P' or --console=pipe could help us not having to do a bunch
33 # of os.write() calls, but instead use pipes (stdin, stdout and stderr) as usual.
34 self.session = SysCommandWorker(
35 [
36 'systemd-nspawn',
37 '-D',
38 self.path,
39 '--timezone=off',
40 '-b',
41 '--no-pager',
42 '--machine',
43 self.container_name,
44 ]
45 )
46
47 if not self.ready and self.session:
48 while self.session.is_alive():
49 if b' login:' in self.session:
50 self.ready = True
51 break
52
53 Boot._active_boot = self
54 return self
55
56 def __exit__(self, exc_type: type[BaseException] | None, exc_value: BaseException | None, traceback: TracebackType | None) -> None:
57 # b''.join(sys_command('sync')) # No need to, since the underlying fs() object will call sync.

Callers

nothing calls this directly

Calls 2

SysCommandWorkerClass · 0.90
is_aliveMethod · 0.45

Tested by

no test coverage detected