add function #query_pkg

This commit is contained in:
Abhiraj Roy (iconized)
2024-04-24 17:34:17 +05:30
committed by GitHub
parent 18f90f1791
commit c9ba799fb9

View File

@@ -1201,4 +1201,27 @@ def get_current_installed():
file.write(line)
file.close()
else:
logger.warning("Failed to run %s" % query_str)
logger.warning("Failed to run %s" % query_str)
def query_pkg(package):
try:
package = package.strip()
path = base_dir + "/cache/installed.lst"
pacman_localdb = base_dir + "/cache/pacman-localdb"
if os.path.exists(path):
if is_file_stale(path, 0, 0, 30):
get_current_installed()
else:
get_current_installed()
with open(path, "r") as f:
pkg = package.strip("\n")
for line in f:
installed = line.split(" ")
if pkg == installed[0]:
return True
# file.close()
return False
except Exception as e:
logger.error("Exception in LOC1206: %s " % e)