Example on parsing Machinery data - SUSE/machinery GitHub Wiki
Parsing machinery data from external applications
Machinery stores its data in ~/.machinery/<name_of_the_inspected_system>/manifest.json
. This file can be parsed from other applications via normal json methods.
As the machinery System Description Format has a format_version number you need to check if your parser is working for the version of a specific manifest file.
Example for Python
import json
# Open JSON file and read it
with open('manifest.json') as json_file:
data = json.load(json_file)
# Access System Description format version
format_version = data["meta"]["format_version"]
print("System Description Version: " + str(format_version))
# Check if format_version is the required version
if format_version != 6:
print("Unsupported format version")
exit(1)
# iterate over a list
for package in data["packages"]["_elements"]:
print("Package name: " + package["name"])
print(" Version: " + package["version"])
print(" Release: " + package["release"])
# Access single values from the data
print("OS name: " + data["os"]["name"])
print("OS version: " + data["os"]["version"])
print("Init System: " + data["services"]["_attributes"]["init_system"])