From 18f90f17917ff5d0375eba9cbe88d04f9068621f Mon Sep 17 00:00:00 2001 From: "Abhiraj Roy (iconized)" <157954129+iconized@users.noreply.github.com> Date: Wed, 24 Apr 2024 17:32:26 +0530 Subject: [PATCH] extend function #1 --- blackbox/Functions.py | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/blackbox/Functions.py b/blackbox/Functions.py index 689b15f..1a1e1e3 100644 --- a/blackbox/Functions.py +++ b/blackbox/Functions.py @@ -1174,4 +1174,31 @@ def get_package_information(package_name): return "error: package '%s' not found!\n" % package_name else: - \ No newline at end of file +# NOTE : ICON ON THE BACK +def get_current_installed(): + logger.debug( + "Get currently installed packages" + ) + path = base_dir + "/cache/installed.lst" + + query_str = [ + "pacman", + "-Q", + ] + + subprocess_query = subprocess.Popen( + query_str, + shell=False, + stdout=subprocess.PIPE, + ) + + out, err = subprocess_query.communicate(timeout=process_timeout) + + # added validation on process result + if subprocess_query.returncode == 0: + file = open(path, "w") + for line in out.decode("utf-8"): + file.write(line) + file.close() + else: + logger.warning("Failed to run %s" % query_str) \ No newline at end of file