MuPaH/ps_random_walk.py

36 lines
687 B
Python
Raw Permalink Normal View History

2024-10-26 04:11:20 +00:00
import psutil
import random
from time import sleep
from mupah import eighths_scale
import mingus.core.scales as scales
scale = scales.Aeolian("C").ascending()
2024-10-26 04:11:20 +00:00
def reporta(p):
print(eighths_scale(p, scale), p.name())
2024-10-26 04:11:20 +00:00
2024-10-29 05:59:00 +00:00
# walk from init
p = psutil.Process(pid=1)
2024-10-26 04:11:20 +00:00
while True:
2024-10-29 05:59:00 +00:00
reporta(p)
2024-10-26 04:11:20 +00:00
sleep(1)
2024-10-29 05:59:00 +00:00
2024-10-26 04:11:20 +00:00
children = p.children()
if children:
p = psutil.Process(pid=random.choice([subp.pid
for subp in
children]))
print("\t", end="")
2024-10-26 04:11:20 +00:00
else:
p = psutil.Process(pid=random.choice(psutil.pids()))
print('', end="")
2024-10-29 05:59:00 +00:00
2024-10-26 04:11:20 +00:00