Skip to content

Commit

Permalink
repo sign checker tool
Browse files Browse the repository at this point in the history
Signed-off-by: Jelle van der Waa <jelle@vdwaa.nl>
  • Loading branch information
jelly committed Jan 30, 2012
1 parent 775cd3d commit 338c1bb
Showing 1 changed file with 55 additions and 0 deletions.
55 changes: 55 additions & 0 deletions repo-signed.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#!/usr/bin/env python

from pycman import config,pkginfo


class RepoStats():

def __init__(self, db=None):
self.pkgs=[]
self.db=db
for pkg in self.db.search(''):
self.pkgs.append(pkg)

def getSigSum(self):
yay=0
nay=0
all=self.pkgs.__len__()
for p in self.pkgs:
if p.base64_sig:
yay+=1
else:
nay+=1
return yay, nay, all


class Repos():
def __init__(self):
self.rstats={}
self.handle=None
self.handle=config.init_with_config('/etc/pacman.conf')
for db in self.handle.get_syncdbs():
self.rstats[db.name]=RepoStats(db)

def getSigSums(self):
## ret=[('repo','signed', 'unsigned', 'all')]
ret =[]
for name,a in self.rstats.items():
y,n,all= a.getSigSum()
ret.append((name , y, n, all))
return ret

def getSigPerc(self):
ret = []
for name, yes, no, all in self.getSigSums():
try: ret.append((name, 100 * float(yes) / float(all)))
except ZeroDivisionError: ret.append((name, 0))
return ret


if __name__ == '__main__':
r=Repos()
for name, perc in r.getSigPerc():
length = 18 - len(name)

print (name, length * ' ', int(perc), '%')

0 comments on commit 338c1bb

Please sign in to comment.