From d8c1c620465785b42747a6796b9a872578742e37 Mon Sep 17 00:00:00 2001 From: davidovski Date: Tue, 18 Jan 2022 23:59:00 +0000 Subject: added stats command --- src/util.py | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) (limited to 'src/util.py') diff --git a/src/util.py b/src/util.py index 647f211..5ce93a9 100644 --- a/src/util.py +++ b/src/util.py @@ -1,4 +1,5 @@ import shutil +import csv import requests import colors import time @@ -129,7 +130,23 @@ def ask_confirmation(text, default=True, no_confirm=False): return reponse.lower() == "y" or len(reponse) == 0 -if __name__ == "__main__": - for i in range(1000): - loading_bar(i, 1000, "it is loading...") - time.sleep(0.01) +def get_distro(): + + RELEASE_DATA = {} + + with open("/etc/os-release") as f: + reader = csv.reader(f, delimiter="=") + for row in reader: + if row: + RELEASE_DATA[row[0]] = row[1] + + if RELEASE_DATA["ID"] in ["debian", "raspbian"]: + with open("/etc/debian_version") as f: + DEBIAN_VERSION = f.readline().strip() + major_version = DEBIAN_VERSION.split(".")[0] + version_split = RELEASE_DATA["VERSION"].split(" ", maxsplit=1) + if version_split[0] == major_version: + # Just major version shown, replace it with the full version + RELEASE_DATA["VERSION"] = " ".join([DEBIAN_VERSION] + version_split[1:]) + + return RELEASE_DATA -- cgit v1.2.1