Advertisement
lswest

updateCheck

Jul 8th, 2011
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.01 KB | None | 0 0
  1. #!/usr/bin/env python
  2. #A program to check if there are any updates available for Arch
  3. from subprocess import Popen,PIPE
  4. import os
  5.  
  6. def main():
  7.     ignoreList=[]
  8.     ignore=Popen("sed -r 's/^\s*IgnorePkg\s*=\s*//;tx;d;:x;s/\s+/|/g' /etc/pacman.conf",shell=True,stdout=PIPE)
  9.     a=ignore.communicate()
  10.     if a[0].decode("utf-8") != "":
  11.         ignoreList=a[0].decode("utf-8").split("\n")
  12.     p=Popen("pacman -Qqu",shell=True,stdout=PIPE)
  13.     tally=0
  14.     x=p.communicate()
  15.     if x[0].decode("utf-8") != "":
  16.         PackageList=[]
  17.         PackageList=x[0].decode("utf-8").split("\n")
  18.         for f in PackageList:
  19.             tally=tally+1
  20.             for i in ignoreList:
  21.                 if cmp(f,i) == 0:
  22.                     tally=tally-1
  23.     if tally != 0:
  24.         tally=tally-1
  25.     if int(tally) == 1:
  26.         print("1 package to update")
  27.     elif int(tally) >= 1:
  28.         print("%s packages to update" % str(tally))
  29.     else:
  30.         print("No packages to update")
  31.  
  32. if __name__ == '__main__':
  33.     main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement