lib.vardir

Process-wide resolver for SmartHomeNG’s var directory.

The var tree (cache, logs, pidfile, databases, plugin data…) lives at <base>/var unless --var_dir was given on the command line. bin/smarthome.py calls set_var_dir() once after parsing the arguments; everything else reads the location through get_var_dir(), resolve_var_path() or SmartHome.get_vardir(), so code that runs before a SmartHome instance exists (pidfile, debug logging, ephemeris cache) resolves to the same place.

lib.vardir.get_pidfile()[Quellcode]

Return the path of SmartHomeNG’s pidfile.

Rückgabetyp:

str

lib.vardir.get_run_file(name)[Quellcode]

Return the path of the runtime file name (pidfile, thread info…) below <var>/run.

Rückgabetyp:

str

lib.vardir.get_var_dir()[Quellcode]

Return the absolute path of the var directory.

Rückgabetyp:

str

lib.vardir.rebase_var_prefix(path)[Quellcode]

Re-root a relative var/... path under the configured var directory.

Paths without a leading var segment (absolute paths, plugins/foo/var/x…) and every path while the var directory is the default are returned unchanged.

Rückgabetyp:

str

lib.vardir.resolve_var_path(path)[Quellcode]

Resolve path to an absolute path.

A relative path starting with var is located below the configured var directory, any other relative path below the base directory; absolute paths are returned unchanged (normalised).

Rückgabetyp:

str

lib.vardir.set_var_dir(path)[Quellcode]

Set the var directory.

Parameter:

path (str | None) – directory to use (~ is expanded, relative paths are made absolute); None or ‚‘ restores the default <base>/var

Rückgabetyp:

None