18 lines
815 B
Python
18 lines
815 B
Python
#!/usr/bin/env python3
|
|
import pathlib,os,sys,json
|
|
busy=[]
|
|
for p in pathlib.Path('/proc').glob('[0-9]*'):
|
|
try:
|
|
cwd=os.readlink(p/'cwd')
|
|
if not cwd.startswith('/mnt/storage/src/mosaic-stack'):continue
|
|
args=[a.decode(errors='replace') for a in (p/'cmdline').read_bytes().split(b'\0') if a]
|
|
if not args:continue
|
|
exe=pathlib.Path(args[0]).name
|
|
node=exe=='node' and any(a=='--test' or a.startswith('--test-') or a.endswith('.test.mjs') for a in args[1:])
|
|
browser='chrom' in exe and any(a.startswith('--headless') for a in args[1:])
|
|
shell=exe in ['bash','sh'] and len(args)>1 and pathlib.Path(args[1]).name.startswith('test-')
|
|
if node or browser or shell:busy.append({'pid':int(p.name),'exe':exe,'cwd':cwd})
|
|
except OSError:pass
|
|
print('BUSY '+json.dumps(busy) if busy else 'CLEAR')
|
|
sys.exit(bool(busy))
|