okami.mom/strata
git clone https://git.nkp.pet/okami.mom/strata
aff3a132f
main
1"""Is a program of one of Strata's own folders running (an engine package, a Control bundle, a shape engine)? Local only. 2 3A folder in use is never removed: on Windows the removal would take its libraries from under the running engine. (This was 4dsv41_paths.in_use; it never depended on DeepSeek's engine, and every package folder kind uses it.) 5""" 6from __future__import annotations 7 8import os 9from pathlib import Path 10 11 12def in_use (folder )-> bool : 13"""True when any running process's program or working folder lies in `folder` (psutil; without psutil: False).""" 14folder = Path (folder ) 15try : 16import psutil 17except ImportError : 18return False 19here = os .path .normcase (os .path .abspath (folder ))+ os .sep 20for p in psutil .process_iter (["exe" ,"cwd" ]): 21try : 22for where in (p .info .get ("exe" ),p .info .get ("cwd" )):# the program, or the folder a Python server runs in (a Control) 23if where and os .path .normcase (os .path .abspath (where )+ os .sep ).startswith (here ): 24return True 25except (psutil .Error ,OSError ,ValueError ): 26continue 27return False