summaryrefslogtreecommitdiffstats
path: root/bin/reproducible_remote_scheduler.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_remote_scheduler.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_remote_scheduler.py')
-rwxr-xr-xbin/reproducible_remote_scheduler.py32
1 files changed, 16 insertions, 16 deletions
diff --git a/bin/reproducible_remote_scheduler.py b/bin/reproducible_remote_scheduler.py
index 6ba1f3a3..aec225eb 100755
--- a/bin/reproducible_remote_scheduler.py
+++ b/bin/reproducible_remote_scheduler.py
@@ -116,23 +116,23 @@ if arch not in ARCHS:
if issue or status or built_after or built_before:
formatter = dict(suite=suite, arch=arch, notes_table='')
log.info('Querying packages with given issues/status...')
- query = 'SELECT s.name ' + \
- 'FROM sources AS s, {notes_table} results AS r ' + \
- 'WHERE r.package_id=s.id ' + \
- 'AND s.architecture= "{arch}" ' + \
- 'AND s.suite = "{suite}" AND r.status != "blacklisted" '
+ query = "SELECT s.name " + \
+ "FROM sources AS s, {notes_table} results AS r " + \
+ "WHERE r.package_id=s.id " + \
+ "AND s.architecture= '{arch}' " + \
+ "AND s.suite = '{suite}' AND r.status != 'blacklisted' "
if issue:
- query += 'AND n.package_id=s.id AND n.issues LIKE "%{issue}%" '
+ query += "AND n.package_id=s.id AND n.issues LIKE '%{issue}%' "
formatter['issue'] = issue
- formatter['notes_table'] = 'notes AS n,'
+ formatter['notes_table'] = "notes AS n,"
if status:
- query += 'AND r.status = "{status}"'
+ query += "AND r.status = '{status}'"
formatter['status'] = status
if built_after:
- query += 'AND r.build_date > "{built_after}" '
+ query += "AND r.build_date > '{built_after}' "
formatter['built_after'] = built_after
if built_before:
- query += 'AND r.build_date < "{built_before}" '
+ query += "AND r.build_date < '{built_before}' "
formatter['built_before'] = built_before
results = query_db(query.format_map(formatter))
results = [x for (x,) in results]
@@ -158,11 +158,11 @@ if notify_on_start:
ids = []
pkgs = []
-query1 = '''SELECT id FROM sources WHERE name="{pkg}" AND suite="{suite}"
- AND architecture="{arch}"'''
-query2 = '''SELECT p.date_build_started
+query1 = """SELECT id FROM sources WHERE name='{pkg}' AND suite='{suite}'
+ AND architecture='{arch}'"""
+query2 = """SELECT p.date_build_started
FROM sources AS s JOIN schedule as p ON p.package_id=s.id
- WHERE p.package_id="{id}"'''
+ WHERE p.package_id='{id}'"""
for pkg in packages:
# test whether the package actually exists
result = query_db(query1.format(pkg=pkg, suite=suite, arch=arch))
@@ -214,8 +214,8 @@ log.debug('date_scheduled = ' + date + ' time_delta = ' + str(time_delta))
# a single person can't schedule more than 200 packages in the same day; this
# is actually easy to bypass, but let's give some trust to the Debian people
-query = '''SELECT count(*) FROM manual_scheduler
- WHERE requester = "{}" AND date_request > "{}"'''
+query = """SELECT count(*) FROM manual_scheduler
+ WHERE requester = '{}' AND date_request > '{}'"""
try:
amount = int(query_db(query.format(requester, int(time.time()-86400)))[0][0])
except IndexError: