Notification support for aptget.

This commit is contained in:
ncoop 2016-06-22 23:57:40 -07:00
parent f03926ed71
commit 2505468515

View File

@ -23,10 +23,14 @@ class AptGet(Backend):
command = "apt-get upgrade -s -o Dir::State::Lists=" + cache_dir
apt = run_through_shell(command.split())
update_count = 0
for line in apt.out.split("\n"):
if line.startswith("Inst"):
update_count += 1
return update_count
out = apt.out.splitlines()
out = [line[5:] for line in apt.out if line.startswith("Inst ")]
return out.count("\n"), out
Backend = AptGet
if __name__ == "__main__":
"""
Call this module directly; Print the update count and notification body.
"""
print("Updates: {}\n\n{}".format(*Backend().updates))