diff options
author | Luciano Bello <luciano@debian.org> | 2015-01-16 23:21:35 +0000 |
---|---|---|
committer | Luciano Bello <luciano@debian.org> | 2015-01-16 23:21:35 +0000 |
commit | f188fc15513f5a56780d38af940fcfa56938fe5b (patch) | |
tree | 8e89cf4674f89579d2fa246157c06a4383f4de7b | |
parent | 4e100a8d02294656cac9fe560935ebb26a9d0f04 (diff) |
unknown-packages: double check and DB update
git-svn-id: svn+ssh://svn.debian.org/svn/secure-testing@31413 e39458fd-73e7-0310-bf30-c45bca0a0e42
-rwxr-xr-x | check-external/unknown-packages.py (renamed from check-external/unknown-packages-pts.py) | 34 |
1 files changed, 29 insertions, 5 deletions
diff --git a/check-external/unknown-packages-pts.py b/check-external/unknown-packages.py index 9f88147f21..5156e99968 100755 --- a/check-external/unknown-packages-pts.py +++ b/check-external/unknown-packages.py @@ -4,6 +4,7 @@ import SOAPpy import os import string import sys +import json cache_file=os.path.join(os.path.dirname(os.path.abspath(__file__)),'known-unknown-packages.cache') db_file=os.path.join(os.path.dirname(os.path.abspath(__file__)),'../data/security.db') @@ -33,12 +34,35 @@ except security_db.SchemaMismatch: ws = SOAPpy.SOAPProxy('https://packages.qa.debian.org/cgi-bin/soap-alpha.cgi') -for pkg,bugs in db.getUnknownPackages(db.cursor()): - if not pkg in open(cache_file).read(): +def checkInPTS(pkg): try: ws.versions(source=pkg) except SOAPpy.faultType: - print pkg, + return False else: - with open(cache_file, 'a') as file: - file.write(pkg+"\n") + return True + +def fromSources(pkg): + try: + data = json.load(urllib2.urlopen('http://sources.debian.net/api/src/%s/latest/' %pkg)) + except urllib2.HTTPError as e: + return [] + if 'error' in data: return [] + else: return data['pkg_infos']['suites'] + +def updateAs(pkg,suite,cursor): + kind = 'experimental' if suite == 'experimental' else 'gone:'+suite + print pkg,kind + cursor.execute("""UPDATE package_notes SET package_kind = ? WHERE package = ?""", (kind,pkg)) + +c=db.cursor() +pkgs=set([ i[0] for i in db.getUnknownPackages(c)]) +pkgs.add('whatpackage'); + +for pkg in pkgs: + suites = fromSources(pkg) + if len(suites) >0: + updateAs(pkg,suites[-1],c) + else: + if checkInPTS(pkg): updateAs(pkg,'n/a',c) + else: print 'UNKNOWN' |