Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- #A program to check if there are any updates available for Arch
- from subprocess import Popen,PIPE
- import os
- def main():
- ignoreList=[]
- ignore=Popen("sed -r 's/^\s*IgnorePkg\s*=\s*//;tx;d;:x;s/\s+/|/g' /etc/pacman.conf",shell=True,stdout=PIPE)
- a=ignore.communicate()
- if a[0].decode("utf-8") != "":
- ignoreList=a[0].decode("utf-8").split("\n")
- p=Popen("pacman -Qqu",shell=True,stdout=PIPE)
- tally=0
- x=p.communicate()
- if x[0].decode("utf-8") != "":
- PackageList=[]
- PackageList=x[0].decode("utf-8").split("\n")
- for f in PackageList:
- tally=tally+1
- for i in ignoreList:
- if cmp(f,i) == 0:
- tally=tally-1
- if tally != 0:
- tally=tally-1
- if int(tally) == 1:
- print("1 package to update")
- elif int(tally) >= 1:
- print("%s packages to update" % str(tally))
- else:
- print("No packages to update")
- if __name__ == '__main__':
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement