-
-
Notifications
You must be signed in to change notification settings - Fork 37
API
Samuel FORESTIER edited this page May 8, 2021
·
4 revisions
Since v4.4.0, Archey lives as a proper Python package (archey
).
This means you can use it within your own Python programs, for instance, as below :
from archey.entries.gpu import GPU
gpu = GPU()
for element in gpu.value:
print(element)
Since v4.11.0, Archey may raise ArcheyException
. You can catch it this way for instance :
from archey.exceptions import ArcheyException
from archey.entries.uptime import Uptime
try:
uptime = Uptime()
except ArcheyException as e:
# ...
pass
else:
print(uptime.value)
Since v4.7.2, Archey is able to output its entries as JSON :
# Use multiple `-j` flags to increase indentation level.
python3 -m archey -jjj
{
"data": { # Configured entries name and respective values (order is not guaranteed for Python < 3.6).
"Distro": {
"name": "Debian GNU/Linux 10 (buster)",
"arch": "x86_64"
},
"Kernel": {
"release": "4.19.0-13-amd64",
"latest": null,
"is_outdated": null
},
"Uptime": {
"days": 2,
"hours": 20,
"minutes": 54,
"seconds": 49
},
"Processes": 256
},
"meta": {
"version": [4, 10, 0], # Version of Archey (Semver segments).
"date": "2020-12-19T12:19:31.407505", # Sample datetime in ISO format.
"count": 4, # Number of entries in the document `data` section.
"distro": "debian" # Since v4.11.0, the distribution identifier internally used.
}
}
You can easily retrieve something valuable, for instance, this way :
archey -j | jq -r '.data.Kernel.release'
4.19.0-13-amd64