commit bef9ab4e44e7c3f4d9239712089014649799327f Author: hiro hiro@torproject.org Date: Wed May 22 17:40:23 2019 +0200
Update db scripts and updates --- gettor/parse/email.py | 1 + gettor/services/email/sendmail.py | 2 +- gettor/utils/db.py | 4 ++-- scripts/add_lins_to_db | 2 +- scripts/create_db | 16 ++++++++-------- 5 files changed, 13 insertions(+), 12 deletions(-)
diff --git a/gettor/parse/email.py b/gettor/parse/email.py index d79a375..6518946 100644 --- a/gettor/parse/email.py +++ b/gettor/parse/email.py @@ -209,6 +209,7 @@ class EmailParser(object): id=request['id'], command=request['command'], platform=request['platform'], + language=request['language'], service=request['service'], date=now_str, status="ONHOLD", diff --git a/gettor/services/email/sendmail.py b/gettor/services/email/sendmail.py index f18b335..a350909 100644 --- a/gettor/services/email/sendmail.py +++ b/gettor/services/email/sendmail.py @@ -164,7 +164,7 @@ class Sendmail(object):
log.info("Getting links for {}.".format(platform)) links = yield self.conn.get_links( - platform=platform, status="ACTIVE" + platform=platform, language=language, status="ACTIVE" )
# build message diff --git a/gettor/utils/db.py b/gettor/utils/db.py index 99ae081..8d65f45 100644 --- a/gettor/utils/db.py +++ b/gettor/utils/db.py @@ -41,14 +41,14 @@ class SQLite3(object): log.msg("Database error: {}".format(error)) return None
- def new_request(self, id, command, service, platform, date, status): + def new_request(self, id, command, service, platform, language, date, status): """ Perform a new request to the database """ query = "INSERT INTO requests VALUES(?, ?, ?, ?, ?, ?)"
return self.dbpool.runQuery( - query, (id, command, platform, service, date, status) + query, (id, command, platform, language, service, date, status) ).addCallback(self.query_callback).addErrback(self.query_errback)
def get_requests(self, status, command, service): diff --git a/scripts/add_lins_to_db b/scripts/add_lins_to_db index e8e89f2..b979498 100755 --- a/scripts/add_lins_to_db +++ b/scripts/add_lins_to_db @@ -102,7 +102,7 @@ def main(): for l in languages: release_link = releases.get(k).replace("en-US", l) c.execute( - "INSERT INTO links(link, platform, arch, version, provider, status)" + "INSERT INTO links(link, platform, language, arch, version, provider, status)" "VALUES ('%s', '%s', '64', '%s', '%s', 'ACTIVE')" %(providers.get(p) + release_link, k, version, p))
diff --git a/scripts/create_db b/scripts/create_db index d332c27..7f8cc11 100755 --- a/scripts/create_db +++ b/scripts/create_db @@ -83,15 +83,15 @@ def main(): c.execute("DROP TABLE IF EXISTS stats") c.execute( "CREATE TABLE requests(id TEXT, command TEXT, platform TEXT," - " service TEXT, date TEXT, status TEXT)" + " language TEXT, service TEXT, date TEXT, status TEXT)" ) c.execute( - "CREATE TABLE links(link TEXT, platform TEXT, arch TEXT," - " version TEXT, provider TEXT, status TEXT)" + "CREATE TABLE links(link TEXT, platform TEXT, language TEXT," + " arch TEXT, version TEXT, provider TEXT, status TEXT)" ) c.execute( - "CREATE TABLE stats(num_requests NUMBER, platform TEXT, " - "command TEXT, service TEXT, date TEXT)" + "CREATE TABLE stats(num_requests NUMBER, platform TEXT," + " language TEXT, command TEXT, service TEXT, date TEXT)" ) print("Database {} created.".format(abs_filename)) elif args.clear: @@ -116,17 +116,17 @@ def main(): c.execute("DROP TABLE IF EXISTS stats") c.execute( "CREATE TABLE requests(id TEXT, command TEXT, " - "platform TEXT, service TEXT, date TEXT, status TEXT," + "platform TEXT, language TEXT, service TEXT, date TEXT, status TEXT," "PRIMARY KEY(id, date))" ) c.execute( - "CREATE TABLE links(link TEXT, platform TEXT, " + "CREATE TABLE links(link TEXT, platform TEXT, language TEXT," "arch TEXT, version TEXT, provider TEXT, status TEXT," "PRIMARY KEY(platform, arch, version, provider, status))" ) c.execute( "CREATE TABLE stats(date TEXT PRIMARY KEY, " - "num_requests INTEGER, platform TEXT, command TEXT, " + "num_requests INTEGER, platform TEXT, language TEXT, command TEXT, " "service TEXT)" ) print("New database {} created.".format(abs_filename))
tor-commits@lists.torproject.org