mirror of
https://github.com/Snigdha-OS/snigdhaos-blackbox.git
synced 2025-09-21 20:15:02 +02:00
add function #query_pkg
This commit is contained in:

committed by
GitHub

parent
18f90f1791
commit
c9ba799fb9
@@ -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)
|
||||
|
Reference in New Issue
Block a user