From 77e4e603a751d2d526c7033aa8b52f8803556a69 Mon Sep 17 00:00:00 2001 From: "Eshan Roy (Eshanized)" Date: Wed, 24 Apr 2024 14:52:20 +0530 Subject: [PATCH] =?UTF-8?q?=E2=8F=B3=20@eshanized=20updated=20the=20reposi?= =?UTF-8?q?tory!!!?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- blackbox/Functions.py | 104 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 103 insertions(+), 1 deletion(-) diff --git a/blackbox/Functions.py b/blackbox/Functions.py index bdd6b1f..d9155b8 100644 --- a/blackbox/Functions.py +++ b/blackbox/Functions.py @@ -19,7 +19,7 @@ import Functions as fn from Settings import Settings from Package import Package from ui.MessageDialog import MessageDialog - +from ui.GUI import GUI gi.require_version("Gtk" "3.0") # GTK 2.0 is dead! from gi.repository import GLib, Gtk @@ -981,3 +981,105 @@ def cache(package, path_dir_cache): "Exception %s" % e ) +def get_package_description(package): + query_str = [ + "pacman", + "-Si", + package, + ] + try: + with subprocess.Popen( + query_str, + stdout=subprocess.PIPE, + stderr=subprocess.STDOUT, + bufsize=1, + universal_newlines=True, + ) as process: + while True: + if process.poll() is not None: + break + returncode = None + returncode = process.poll() + if returncode is not None: + for line in process.stdout: + if "Description :" in line.strip(): + return line.replace(" ", "").split("Description:")[1].strip() + + except Exception as e: + logger.error( + "Exception: %s" % e + ) + +def get_installed_package_data(self): + latest_package_data = get_all_package_info() + try: + installed_packages_list = [] + pkg_name = None + pkg_version = None + pkg_install_date = None + pkg_installed_size = None + pkg_latest_version = None + with subprocess.Popen( + self.pacman_export_cmd, + stdout=subprocess.PIPE, + stderr=subprocess.STDOUT, + bufsize=1, + universal_newlines=True, + ) as process: + for line in process.stdout: + if "Name :" in line.strip(): + pkg_name = line.replace(" ", "").split("Name:")[1].strip() + if "Version :" in line.strip(): + pkg_name = line.replace(" ", "").split("Version:")[1].strip() + if "Installed Size :" in line.strip(): + pkg_name = line.replace(" ", "").split("Installed Size :")[1].strip() + if "Install Date :" in line.strip(): + pkg_name = line.replace(" ", "").split("Install Date :")[1].strip() + found = False + pkg_latest_version = None + for i in latest_package_data: + if i["name"] == pkg_name: + pkg_latest_version = i["version"] + break + installed_packages_list.append( + ( + pkg_name, + pkg_version, + pkg_latest_version, + pkg_installed_size, + pkg_install_date, + ) + ) + self.pkg_export_queue.put( + installed_packages_list + ) + except Exception as e: + logger.error( + "Exception: %s" % e + ) + +def get_package_files(package_name): + try: + query_str = [ + "pacman", + "-Fl", + package_name, + ] + process = subprocess.run( + query_str, + shell=False, + stdout=subprocess.PIPE, + stderr=subprocess.STDOUT, + timeout=process_timeout, + ) + if process.returncode == 0: + package_files = [] + for line in process.stdout.decode("UTF-8").splitlines(): + package_files.append(line.split(" ")[1], None) + return package_files + else: + return None + except Exception as e: + logger.error( + "Exception in LOC1161: %s" % e + )