pacman facts¶
- class reemote.facts.pacman.get_packages.Get_packages[source]¶
Bases:
objectRetrieves a list of installed pacman packages from a host.
This Reemote operation executes pacman -Q on the target host to get a list of all installed packages. It then parses this output into a structured list of dictionaries.
The final result of this operation will have its cp.stdout attribute replaced with the parsed list. Each item in the list is a dictionary containing the package ‘name’ and ‘version’.
Examples
# Yield the operation within a Reemote task result = yield Get_packages() # The parsed list is in result.cp.stdout for package in result.cp.stdout: print(f"{package['name']}: {package['version']}")
- reemote.facts.pacman.get_packages.parse_pacman_list_installed(output)[source]¶
Parses the raw output of ‘pacman -Q’ into a list of packages.
This function processes the standard output from the pacman -Q command, which lists all installed packages and their versions. It is designed to handle the specific format of this command’s output.
The parsing logic involves:
Splitting the output into lines.
Skipping the first two header lines.
Extracting the package name (the first word) and the version (the rest of the line) for each package.
- Parameters:
output (str) – The raw string output from a ‘pacman -Q’ command.
- Returns:
- A list of dictionaries, where each dictionary
represents an installed package and contains ‘name’ and ‘version’ keys.
- Return type:
list[dict]