Python3 bindings for qinfo
Project description
qinfo-python
Python Bindings for qinfo.
Installation
pip install qinfo-python
How to compile
Build dependencies:
- Python3 (Cython)
- gcc
- glibc
- make
- patchelf
git clone --recurse-submodules https://github.com/el-wumbus/qinfo-python
cd qinfo-pyhton
pip install -r ./requirements.txt
make package
The package is in the dist
directory.
Usage
Below is a short example of some of the functionality of this module
#!/usr/bin/env python3
import qinfo
from sys import exit as sexit
from os import environ, path
def main():
silent = False
config_file = path.join(environ.get("HOME"), ".config/.qinfo.conf")
configuration_options = qinfo.parse_config(config_file, silent)
if configuration_options is None:
return 1
if configuration_options["display_cpu"]:
cpu = qinfo.cpu_model()
print(f"CPU: {cpu}")
return 0
sexit(main())
Avaliable Functions & What They Return
-
avalible_memory()
-> int- Returns the avalible memory in kB.
-
core_count()
-> int- Returns the core count.
-
cpu_model()
-> string- Returns the cpu model as a string.
-
kernel_release()
-> string- Returns the release and name of the kernel.
-
motherboard_model()
-> string- Returns the model name of the motherboard along with the manufacturer.
-
os_name()
-> string- Returns the operating system name (distro name) as a string.
-
parse_config(config_file_location: string, silent:bool)
-> dict- Returns a dict of all the configuration options.
-
thread_count()
-> int- Returns the thread count.
-
total_memory()
-> int- Returns the total memory in kB.
-
uptime()
-> long- Returns the uptime in seconds.
-
version()
-> string- Returns the version of qinfo being used.
-
hostname()
-> string- Return the hostname of the system as a string.
-
packages()
-> dict- Returns a dict of the number of packages for each supported package manager.
-
rootfs_age()
-> dict- Returns a dict of the age of the root file system.
-
shell()
-> string- Returns a string containing the shell (or if none found, the calling process).
-
username()
-> string- Returns the username of the user running the program as a string.
What the dictionaries look like
parse_config()
returns a dict of the configuration options and their values.
This looks similar to the following:
{
'display_cpu': 1, # Display cpu name and core/thread info
'display_etc_cpu': 0, # Display extra cpu info
'display_mem': 1, # Display memory capacity and usage ratio
'display_board': 1, # Display motherboard info
'display_hostname': 1, # Display the computer's hostname
'display_uptime': 1, # Display the system uptime
'display_gb': 1, # Measure memory in gigabytes instead of kilobytes
'display_kernel': 1, # Display Kernel release version
'display_logo': 1, # Display a logo for the OS if supported
'display_rootfs_birth': 1, # Display the birthdate of the root file system
'display_pkg_count': 1, # Display the number of packages for every supported package manager
'display_shell': 1, # Display the shell calling the program
'display_username': 1, # Display the username of the user calling the program
'display_os': 1, # Display the os name
'date_order' : 0, # supported formats are YYYY/MM/DD (0) and MM/DD/YYYY (1)
'idcolor': '\x1b[1;36m', # Color for the id column
'txtcolor': '', # Color for the text column
'logocolor': '\x1b[0;31m' # Color for the logo
}
The *color values are ansi escape codes.
The rest are int values that are either 1
or 0
(a.k.a booleans).
rootfs_age()
returns a dict containing the date.
This will look like the following:
{
'year': 2022,
'month': 8,
'day': 21
}
packages()
returns a dict that looks something like the following:
{
'pacman': 979,
'apt': 372,
'apk': 87,
'flatpak': 0,
'snap': 0
}
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for qinfo_python-0.1.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2b32ecfcb86afb1cb0bcb9788083b0cf70823d528dabb7789d823a4683480f3e |
|
MD5 | 3081c570b0893be13360f305679d1540 |
|
BLAKE2b-256 | 2d93e095f710484a1c6e2723ad917eb744f431b80312a25e4b3049d64b8728ad |