From 78a5b359d81b36bd7c3b56bcc24269e04a32be36 Mon Sep 17 00:00:00 2001 From: vitrinekast Date: Tue, 26 Mar 2024 12:34:14 +0000 Subject: [PATCH] change package get --- script.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/script.py b/script.py index 2429081..e32c524 100644 --- a/script.py +++ b/script.py @@ -42,10 +42,12 @@ since_last_boot = run_command(["uptime","-s"]) slb_date = datetime.strptime(since_last_boot, "%Y-%m-%d %H:%M:%S") time_since_last_boot = now - slb_date -list_package_installs_init = subprocess.run(["grep", 'install', "/var/log/dpkg.log"], capture_output=True) -list_package_installs = run_command(['grep', '-v', "status"], based=list_package_installs_init.stdout) -list_package_upgrade = subprocess.run(["grep", 'upgrade', "/var/log/dpkg.log"], capture_output=True).stdout.decode('UTF-8') -list_package_remove = subprocess.run(["grep", 'remove', "/var/log/dpkg.log"], capture_output=True).stdout.decode('UTF-8') +dpkg_date = now.strftime("%Y-%m-%d") + +list_package_installs = subprocess.run(["grep","-E", '${dpkg_date}.*install|install.*${dpkg_date}', "/var/log/dpkg.log"], capture_output=True).stdout.decode('UTF-8').splitlines() +list_package_upgrade = subprocess.run(["grep","-E", '${dpkg_date}.*upgrade|upgrade.*${dpkg_date}', "/var/log/dpkg.log"], capture_output=True).stdout.decode('UTF-8').splitlines() +list_package_remove = subprocess.run(["grep","-E", '${dpkg_date}.*remove|remove.*${dpkg_date}', "/var/log/dpkg.log"], capture_output=True).stdout.decode('UTF-8').splitlines() + device_info_grab = subprocess.run(["grep", 'Model' , "/proc/cpuinfo"], check=True, capture_output=True) device_info = run_command(['awk', '-F:', '{ print $2}'], based=device_info_grab.stdout) @@ -74,9 +76,9 @@ output = template.render( last_user_added_name=last_user_added_name, users_created_today=users_created_today, since_last_boot=since_last_boot, - list_package_installs=list_package_installs.splitlines(), - list_package_upgrade=list_package_upgrade.splitlines(), - list_package_remove=list_package_remove.splitlines(), + list_package_installs=list_package_installs, + list_package_upgrade=list_package_upgrade, + list_package_remove=list_package_remove, device_info=device_info, days_since_last_boot = time_since_last_boot.days, kitchen_services = kitchen_services,