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