[Secure-testing-commits] r31413 - check-external
Luciano Bello
luciano at moszumanska.debian.org
Fri Jan 16 23:21:35 UTC 2015
Author: luciano
Date: 2015-01-16 23:21:35 +0000 (Fri, 16 Jan 2015)
New Revision: 31413
Added:
check-external/unknown-packages.py
Removed:
check-external/unknown-packages-pts.py
Log:
unknown-packages: double check and DB update
Deleted: check-external/unknown-packages-pts.py
===================================================================
--- check-external/unknown-packages-pts.py 2015-01-16 23:17:10 UTC (rev 31412)
+++ check-external/unknown-packages-pts.py 2015-01-16 23:21:35 UTC (rev 31413)
@@ -1,44 +0,0 @@
-#!/usr/bin/python
-import urllib2
-import SOAPpy
-import os
-import string
-import sys
-
-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')
-
-def setup_paths():
- check_file = 'lib/python/debian_support.py'
- path = os.getcwd()
- while 1:
- if os.path.exists("%s/%s" % (path, check_file)):
- sys.path = [path + '/lib/python'] + sys.path
- return path
- idx = string.rfind(path, '/')
- if idx == -1:
- raise ImportError, "could not setup paths"
- path = path[0:idx]
-os.chdir(setup_paths())
-
-import security_db
-
-try:
- db = security_db.DB(db_file)
- new_file = False
-except security_db.SchemaMismatch:
- os.unlink(db_file)
- db = security_db.DB(db_file, verbose=True)
- new_file = True
-
-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():
- try:
- ws.versions(source=pkg)
- except SOAPpy.faultType:
- print pkg,
- else:
- with open(cache_file, 'a') as file:
- file.write(pkg+"\n")
Copied: check-external/unknown-packages.py (from rev 31412, check-external/unknown-packages-pts.py)
===================================================================
--- check-external/unknown-packages.py (rev 0)
+++ check-external/unknown-packages.py 2015-01-16 23:21:35 UTC (rev 31413)
@@ -0,0 +1,68 @@
+#!/usr/bin/python
+import urllib2
+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')
+
+def setup_paths():
+ check_file = 'lib/python/debian_support.py'
+ path = os.getcwd()
+ while 1:
+ if os.path.exists("%s/%s" % (path, check_file)):
+ sys.path = [path + '/lib/python'] + sys.path
+ return path
+ idx = string.rfind(path, '/')
+ if idx == -1:
+ raise ImportError, "could not setup paths"
+ path = path[0:idx]
+os.chdir(setup_paths())
+
+import security_db
+
+try:
+ db = security_db.DB(db_file)
+ new_file = False
+except security_db.SchemaMismatch:
+ os.unlink(db_file)
+ db = security_db.DB(db_file, verbose=True)
+ new_file = True
+
+ws = SOAPpy.SOAPProxy('https://packages.qa.debian.org/cgi-bin/soap-alpha.cgi')
+
+def checkInPTS(pkg):
+ try:
+ ws.versions(source=pkg)
+ except SOAPpy.faultType:
+ return False
+ else:
+ 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'
More information about the Secure-testing-commits
mailing list