Update notifications for pacman, cower, yaourt.

These modules are also runnable directly from terminal.
This commit is contained in:
ncoop 2016-06-21 15:49:56 -07:00
parent ae1274d5d3
commit 9d907732f1
4 changed files with 24 additions and 6 deletions

View File

@ -13,6 +13,12 @@ class Cower(Backend):
def updates(self): def updates(self):
command = ["cower", "-u"] command = ["cower", "-u"]
cower = run_through_shell(command) cower = run_through_shell(command)
return cower.out.count('\n') return cower.out.count('\n'), cower.out
Backend = Cower Backend = Cower
if __name__ == "__main__":
"""
Call this module directly; Print the update count and notification body.
"""
print("Updates: {}\n\n{}".format(*Backend().updates))

View File

@ -35,5 +35,4 @@ if __name__ == "__main__":
""" """
Call this module directly; Print the update count and notification body. Call this module directly; Print the update count and notification body.
""" """
dnf = Dnf() print("Updates: {}\n\n{}".format(*Backend().updates))
print("Updates: {}\n\n{}".format(*dnf.updates))

View File

@ -12,6 +12,12 @@ class Pacman(Backend):
def updates(self): def updates(self):
command = ["checkupdates"] command = ["checkupdates"]
checkupdates = run_through_shell(command) checkupdates = run_through_shell(command)
return checkupdates.out.count('\n') return checkupdates.out.count("\n"), checkupdates.out
Backend = Pacman Backend = Pacman
if __name__ == "__main__":
"""
Call this module directly; Print the update count and notification body.
"""
print("Updates: {}\n\n{}".format(*Backend().updates))

View File

@ -25,8 +25,15 @@ class Yaourt(Backend):
def updates(self): def updates(self):
command = ["yaourt", "-Qua"] command = ["yaourt", "-Qua"]
checkupdates = run_through_shell(command) checkupdates = run_through_shell(command)
out = checkupdates.out
if(self.aur_only): if(self.aur_only):
return len(re.findall("^aur/", checkupdates.out, flags=re.M)) out = [line for line in out if line.startswith("aur")]
return checkupdates.out.count("\n") return out.count("\n"), out
Backend = Yaourt Backend = Yaourt
if __name__ == "__main__":
"""
Call this module directly; Print the update count and notification body.
"""
print("Updates: {}\n\n{}".format(*Backend().updates))