-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.py
31 lines (27 loc) · 955 Bytes
/
test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
from logtree import *
import asyncio
async def go():
with note("System check."):
with note("Checking epoch date."):
await run(["date", "-d", "@0", "--utc"])
note("System check done.")
with cd("/proc"):
await run(["wc", "-l", "modules"])
await run(["env"], env={"FOO": "BAR"})
moan("Oops, error.")
async def go2():
# Open a new output section.
with note("Doing steps..."):
# Run some commands.
await run(["./step-1", "--flag"])
await run(["./step-2", "--flag"])
# Open an output subsection.
with note("Cleaning up..."):
# Run a command within an output `cd' section.
with cd("./step-2-build"):
await run(["rm", "-rf", "tmp"])
# Back at the root level, open yet another output section.
with note("Notifying..."):
await run(["say", "Important script done."])
with logtree():
asyncio.run(go())