Skip to content
Snippets Groups Projects
Commit ed056ea1 authored by Julian Rother's avatar Julian Rother
Browse files

Added nlfix option to query to disable newline substitution

parent f5e1df0e
No related branches found
No related tags found
No related merge requests found
...@@ -84,7 +84,7 @@ elif config['DB_ENGINE'] == 'mysql': ...@@ -84,7 +84,7 @@ elif config['DB_ENGINE'] == 'mysql':
db.close() db.close()
return res return res
def query(operation, *params, delim="sep"): def query(operation, *params, delim="sep", nlfix=True):
operation, params = fix_query(operation, params) operation, params = fix_query(operation, params)
cur = get_dbcursor() cur = get_dbcursor()
cur.execute(operation, params) cur.execute(operation, params)
...@@ -106,7 +106,7 @@ def query(operation, *params, delim="sep"): ...@@ -106,7 +106,7 @@ def query(operation, *params, delim="sep"):
if name == delim: if name == delim:
ptr = res[-1][col] = {} ptr = res[-1][col] = {}
continue continue
if type(col) == str: if type(col) == str and nlfix:
col = col.replace('\\n', '\n').replace('\\r', '\r') col = col.replace('\\n', '\n').replace('\\r', '\r')
ptr[name] = col ptr[name] = col
return res return res
......
...@@ -106,7 +106,7 @@ def jobs_ping(id): ...@@ -106,7 +106,7 @@ def jobs_ping(id):
query('UPDATE jobs SET time_finished = ?, status = ?, state = "finished" where id = ?', datetime.now(), status, id) query('UPDATE jobs SET time_finished = ?, status = ?, state = "finished" where id = ?', datetime.now(), status, id)
else: else:
query('UPDATE jobs SET worker = ?, last_ping = ?, status = ?, state = ? where id = ?', hostname, datetime.now(), status, state, id) query('UPDATE jobs SET worker = ?, last_ping = ?, status = ?, state = ? where id = ?', hostname, datetime.now(), status, state, id)
job = query('SELECT * FROM jobs WHERE id = ?', id)[0] job = query('SELECT * FROM jobs WHERE id = ?', id, nlfix=False)[0]
for func in job_handlers.get(job['type'], {}).get(state, []): for func in job_handlers.get(job['type'], {}).get(state, []):
try: try:
func(id, job['type'], json.loads(job['data']), state, json.loads(job['status'])) func(id, job['type'], json.loads(job['data']), state, json.loads(job['status']))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment