Find file
Fetching contributors…
Cannot retrieve contributors at this time
52 lines (37 sloc) 1.25 KB
#!/usr/bin/env python
# This Source Code Form is subject to the terms of the Mozilla Public License,
# v. 2.0. If a copy of the MPL was not distributed with this file, You can
# obtain one at
import bottle
import logging
import sqlite3
import stoneridge
conn = None # Persistent connection for sqlite file
def get_next():
cur = conn.cursor()
cur.execute('SELECT id, config FROM runs WHERE done = ? ORDER BY id ASC '
'LIMIT 1', (False,))
res = cur.fetchall()
if res:
id_, config = res[0]
logging.debug('Found entry %s' % (config,))
cur.execute('UPDATE runs SET done = ? WHERE id = ?', (True, id_))
logging.debug('No entries waiting')
config = ''
logging.debug('Returning %s' % (config,))
return config
def daemon():
global conn
dbfile = stoneridge.get_config('mqproxy', 'db')
conn = sqlite3.connect(dbfile)
port = stoneridge.get_config_int('mqproxy', 'port')'', port=port)
def main():
parser = stoneridge.DaemonArgumentParser()