OS Module¶
The py.os standard library module provides relational predicates for environment variables, working directory management, and system metadata. For running shell commands and subprocesses, see the Process module.
The implementation lives in clausal/modules/py/os.py.
Import¶
-import_from(py.os, [EnvironmentVariable, SetEnvironmentVariable,
WorkingDirectory, ChangeDirectory,
Pid, Argv, Platform, CPUCount])
Or via module import:
Predicates¶
EnvironmentVariable/2¶
EnvironmentVariable(Name, Value) — get or enumerate environment variables.
- Name bound: look up the value. Fails if the variable is not set.
- Name unbound: enumerate all environment variables via backtracking.
SetEnvironmentVariable/2¶
SetEnvironmentVariable(Name, Value) — set an environment variable. Both arguments must be ground strings.
UnsetEnvironmentVariable/1¶
UnsetEnvironmentVariable(Name) — remove an environment variable. Fails if the variable is not set.
WorkingDirectory/1¶
WorkingDirectory(Path) — unify Path with the current working directory.
ChangeDirectory/1¶
ChangeDirectory(Path) — change the current working directory. Path must be ground. Fails if the path does not exist.
Pid/1¶
Pid(P) — unify P with the current process ID (integer).
Argv/1¶
Argv(Args) — unify Args with sys.argv as a Python list.
Platform/1¶
Platform(P) — unify P with sys.platform (e.g. "linux", "darwin", "win32").
CPUCount/1¶
CPUCount(N) — unify N with the number of CPUs available.