Skip to content

Commit 1ac2af3

Browse files
schuellerfsupakeen
authored andcommitted
on-prem: Pause after execution to present logs
1 parent c2090a3 commit 1ac2af3

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

on-prem/bin/run.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,27 @@ async def stop(process, timeout=5.0):
3131
process.kill()
3232

3333

34+
def tree(dir_path: Path, prefix: str = ''):
35+
"""A recursive generator, given a directory Path object
36+
will yield a visual tree structure line by line
37+
with each line prefixed by the same characters
38+
"""
39+
space = ' '
40+
branch = '│ '
41+
tee = '├── '
42+
last = '└── '
43+
44+
contents = list(dir_path.iterdir())
45+
# contents each get pointers that are ├── with a final └── :
46+
pointers = [tee] * (len(contents) - 1) + [last]
47+
for pointer, path in zip(pointers, contents):
48+
yield prefix + pointer + path.name
49+
if path.is_dir(): # extend the prefix and recurse:
50+
extension = branch if pointer == tee else space
51+
# i.e. space because last, └── , above so no more |
52+
yield from tree(path, prefix=prefix+extension)
53+
54+
3455
async def env(
3556
osbuild_version,
3657
osbuild_composer_version,
@@ -140,6 +161,12 @@ async def env(
140161
await cli.wait()
141162

142163
await asyncio.gather(stop(composer), stop(worker))
164+
print("\nLogs are here")
165+
print(path_tmp)
166+
for line in tree(Path(path_tmp)):
167+
print(line)
168+
print("Inspect them now, then press [ENTER] to remove them")
169+
input()
143170

144171
return 0
145172

0 commit comments

Comments
 (0)