Commit f29bdf80 authored by Jérome Perrin's avatar Jérome Perrin

proxy: don't print on the console

Instead of printing when passed log=True, always log at DEBUG level,
application can decide what to do with these logs.
parent 7467ef4c
...@@ -28,8 +28,6 @@ ...@@ -28,8 +28,6 @@
# #
############################################################################## ##############################################################################
from __future__ import print_function
from lxml import etree from lxml import etree
import random import random
import string import string
...@@ -121,14 +119,13 @@ def partitiondict2partition(partition): ...@@ -121,14 +119,13 @@ def partitiondict2partition(partition):
return slap_partition return slap_partition
def execute_db(table, query, args=(), one=False, db_version=None, log=False, db=None): def execute_db(table, query, args=(), one=False, db_version=None, db=None):
if not db: if not db:
db = g.db db = g.db
if not db_version: if not db_version:
db_version = DB_VERSION db_version = DB_VERSION
query = query % (table + db_version,) query = query % (table + db_version,)
if log: app.logger.debug(query)
print(query)
try: try:
cur = db.execute(query, args) cur = db.execute(query, args)
except: except:
...@@ -189,7 +186,7 @@ def _upgradeDatabaseIfNeeded(): ...@@ -189,7 +186,7 @@ def _upgradeDatabaseIfNeeded():
columns = ', '.join(row.keys()) columns = ', '.join(row.keys())
placeholders = ':'+', :'.join(row.keys()) placeholders = ':'+', :'.join(row.keys())
query = 'INSERT INTO %s (%s) VALUES (%s)' % ('%s', columns, placeholders) query = 'INSERT INTO %s (%s) VALUES (%s)' % ('%s', columns, placeholders)
execute_db(table, query, row, log=True) execute_db(table, query, row)
g.db.commit() g.db.commit()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment