Filesystem

import knots_hub.filesystem

manipulate the filesystem

class knots_hub.filesystem.HubInstallFilesystem(root: Path)

Represent the filesystem structure of a hub installation.

NOT all paths are guaranteed to exist depending on the state of the installation.

THe dintinction between “expected” and “current” for executable path is caused by the possibility of having a local instance that is at an older version than the current runtime (which may have been started from the server executable that is not installe dyet but is about to).

Parameters:

root – filesystem path to a directory that may not exist yet.

__init__(root: Path)
property current_exe_new: Path | None

Returns: filesystem path to an existing executable or None if not found

property current_exe_old: Path | None

Returns: filesystem path to an existing executable or None if not found

property current_exe_src: Path | None

Returns: filesystem path to an existing executable or None if not found

property expected_exe_new: Path

Returns: filesystem path to an executable that may exist

property expected_exe_old: Path

Returns: filesystem path to an executable that may exist

property expected_exe_src: Path

Returns: filesystem path to an executable that may exist

hubinstall_path

filesystem path to the location to the file indicating the directectory is a root hub install.

install_new_dir

filesystem path to the location to store the “new” install step

install_old_dir

filesystem path to the location to store the “old” install step

install_src_dir

filesystem path to the location to store the “src” install step

property installed_time: float | None

Returns: time in seconds since the Epoch at which the hub was installed for the first time.

property is_installed: bool
property last_executable: Path | None

Filesystem path to the last locally installed executable (that may still need update steps).

Note the executable might be of a previous version than the current runtime.

log_path

filesystem path to the location to store disk logs

root

filesystem path to a root directory that may not exist yet.

knots_hub.filesystem.find_hub_executable(directory: Path) Path | None

Get the path of the hub executable stored in the given directory.

Parameters:

directory – filesystem path to an existing directory

Returns:

filesystem path to an existing file or None if not found

knots_hub.filesystem.get_expected_hub_executable(directory: Path) Path

Get the path of the expected hub executable for this library version.

Note a previous version might be installed locally so this is why this path might exist or not.

Parameters:

directory – filesystem path to a directory that may exist

Returns:

filesystem path to a file that might exist or not.

knots_hub.filesystem.rmtree(path: Path)

Remove the directory and its content while handling any potential PermissionError.

Parameters:

path – filesystem path to an existing directory