summaryrefslogtreecommitdiffstats
path: root/bin/reproducible_common.py
diff options
context:
space:
mode:
authorValerie R Young <spectranaut@riseup.net>2016-09-09 15:12:15 -0400
committerHolger Levsen <holger@layer-acht.org>2016-10-17 11:22:18 +0200
commit078490603dea0a356c79fd448c5d5a861b218992 (patch)
treed2388a3c205a45f0de9cbaf57bb1d5ce4ce923f2 /bin/reproducible_common.py
parenta363474122e9a7b59c099bca13e0f5c5845a87c4 (diff)
downloadjenkins.debian.net-078490603dea0a356c79fd448c5d5a861b218992.tar.xz
reproducible debian: make python sql more sqlite/postgres agnostic
This commit fixes all the python script sql queries that required minimal editing to be syntactically correct for both sqlite and postgres. Almost all fixes consist of the removal of double quotes from query strings. NOTE: the following scripts expect the schedule table's primary key to autoincrement. Running reproducible_db_maintence.py on a postgres database will not add the necessary autoincrementing functionality at this time. The following script WILL run on the sqlite database but will fail on postgres database constructed from reproducible_db_maintence.py until this is fixed: reproducible_remote_scheduler.py reproducible_schedule.py Signed-off-by: Mattia Rizzolo <mattia@debian.org> Signed-off-by: Holger Levsen <holger@layer-acht.org>
Diffstat (limited to 'bin/reproducible_common.py')
-rwxr-xr-xbin/reproducible_common.py46
1 files changed, 23 insertions, 23 deletions
diff --git a/bin/reproducible_common.py b/bin/reproducible_common.py
index 356b4afc..443ef9cf 100755
--- a/bin/reproducible_common.py
+++ b/bin/reproducible_common.py
@@ -202,10 +202,10 @@ filtered_issues = (
filter_query = ''
for issue in filtered_issues:
if filter_query == '':
- filter_query = 'n.issues LIKE "%' + issue + '%"'
+ filter_query = "n.issues LIKE '%%" + issue + "%%'"
filter_html = '<a href="' + REPRODUCIBLE_URL + ISSUES_URI + '/$suite/' + issue + '_issue.html">' + issue + '</a>'
else:
- filter_query += ' OR n.issues LIKE "%' + issue + '%"'
+ filter_query += " OR n.issues LIKE '%%" + issue + "%%'"
filter_html += ' or <a href="' + REPRODUCIBLE_URL + ISSUES_URI + '/$suite/' + issue + '_issue.html">' + issue + '</a>'
@@ -470,10 +470,10 @@ def package_has_notes(package):
def link_package(package, suite, arch, bugs={}, popcon=None, is_popular=None):
url = RB_PKG_URI + '/' + suite + '/' + arch + '/' + package + '.html'
- query = 'SELECT n.issues, n.bugs, n.comments ' + \
- 'FROM notes AS n JOIN sources AS s ON s.id=n.package_id ' + \
- 'WHERE s.name="{pkg}" AND s.suite="{suite}" ' + \
- 'AND s.architecture="{arch}"'
+ query = """SELECT n.issues, n.bugs, n.comments
+ FROM notes AS n JOIN sources AS s ON s.id=n.package_id
+ WHERE s.name='{pkg}' AND s.suite='{suite}'
+ AND s.architecture='{arch}'"""
css_classes = []
if is_popular:
css_classes += ["package-popular"]
@@ -564,9 +564,9 @@ def pkg_has_buildinfo(package, version=False, suite=defaultsuite, arch=defaultar
reproducible.db
"""
if not version:
- query = 'SELECT r.version ' + \
- 'FROM results AS r JOIN sources AS s ON r.package_id=s.id ' + \
- 'WHERE s.name="{}" AND s.suite="{}" AND s.architecture="{}"'
+ query = """SELECT r.version
+ FROM results AS r JOIN sources AS s ON r.package_id=s.id
+ WHERE s.name='{}' AND s.suite='{}' AND s.architecture='{}'"""
query = query.format(package, suite, arch)
version = str(query_db(query)[0][0])
buildinfo = BUILDINFO_PATH + '/' + suite + '/' + arch + '/' + package + \
@@ -579,9 +579,9 @@ def pkg_has_buildinfo(package, version=False, suite=defaultsuite, arch=defaultar
def pkg_has_rbuild(package, version=False, suite=defaultsuite, arch=defaultarch):
if not version:
- query = 'SELECT r.version ' + \
- 'FROM results AS r JOIN sources AS s ON r.package_id=s.id ' + \
- 'WHERE s.name="{}" AND s.suite="{}" AND s.architecture="{}"'
+ query = """SELECT r.version
+ FROM results AS r JOIN sources AS s ON r.package_id=s.id
+ WHERE s.name='{}' AND s.suite='{}' AND s.architecture='{}'"""
query = query.format(package, suite, arch)
version = str(query_db(query)[0][0])
rbuild = RBUILD_PATH + '/' + suite + '/' + arch + '/' + package + '_' + \
@@ -709,7 +709,7 @@ class Bug:
class Issue:
def __init__(self, name):
self.name = name
- query = 'SELECT url, description FROM issues WHERE name="{}"'
+ query = "SELECT url, description FROM issues WHERE name='{}'"
result = query_db(query.format(self.name))
try:
self.url = result[0][0]
@@ -734,9 +734,9 @@ class NotedPkg:
self.package = package
self.suite = suite
self.arch = arch
- query = 'SELECT n.issues, n.bugs, n.comments ' + \
- 'FROM sources AS s JOIN notes AS n ON s.id=n.package_id ' + \
- 'WHERE s.name="{}" AND s.suite="{}" AND s.architecture="{}"'
+ query = """SELECT n.issues, n.bugs, n.comments
+ FROM sources AS s JOIN notes AS n ON s.id=n.package_id
+ WHERE s.name='{}' AND s.suite='{}' AND s.architecture='{}'"""
result = query_db(query.format(self.package, self.suite, self.arch))
try:
result = result[0]
@@ -757,15 +757,15 @@ class Build:
def _get_package_status(self):
try:
- query = 'SELECT r.status, r.version, r.build_date ' + \
- 'FROM results AS r JOIN sources AS s ' + \
- 'ON r.package_id=s.id WHERE s.name="{}" ' + \
- 'AND s.architecture="{}" AND s.suite="{}"'
+ query = """SELECT r.status, r.version, r.build_date
+ FROM results AS r JOIN sources AS s
+ ON r.package_id=s.id WHERE s.name='{}'
+ AND s.architecture='{}' AND s.suite='{}'"""
query = query.format(self.package, self.arch, self.suite)
result = query_db(query)[0]
except IndexError: # not tested, look whether it actually exists
- query = 'SELECT version FROM sources WHERE name="{}" ' + \
- 'AND suite="{}" AND architecture="{}"'
+ query = """SELECT version FROM sources WHERE name='{}'
+ AND suite='{}' AND architecture='{}'"""
query = query.format(self.package, self.suite, self.arch)
try:
result = query_db(query)[0][0]
@@ -795,7 +795,7 @@ class Package:
self.status = self._status[defaultsuite][defaultarch].status
except KeyError:
self.status = False
- query = 'SELECT notify_maintainer FROM sources WHERE name="{}"'
+ query = "SELECT notify_maintainer FROM sources WHERE name='{}'"
try:
result = int(query_db(query.format(self.name))[0][0])
except IndexError: