def get(self, subtask_id): with connection.connect_db_row() as (db): subtasks = db.query("SELECT * FROM subtask_table WHERE id='%s'" % subtask_id) if subtasks: return {'subtask': subtasks[0]} return {'subtask': '[]'}
def get_local(local_key): with connection.connect_db_row() as (db): result = db.query("SELECT value FROM local_table WHERE key='%s'" % local_key) if result: return result[0]['value'] return return
def get(self): global server_port new_url = 'http://%s:%d' % (request.remote_addr, server_port) with connection.connect_db_row() as (db): update_remote_base_url(db, new_url) tags = db.query('SELECT name, version FROM servtag_table') if tags: return { 'tags': [{ 'name': tag['name'], 'version': tag['version'] } for tag in tags if tag] } return {'tags': []} return {'code': 'error'}
def put_subtask_status(subtask_id, status): with connection.connect_db_row() as (db): result = db.query( "SELECT name, args FROM subtask_table WHERE id='%s'" % subtask_id) if result: name = result[0]['name'] args = result[0]['args'] url = '%s/switch/subtask/%s' % (remote_base_url, subtask_id) payload = { 'name': name, 'args': args, 'report_id': '', 'status': status } put_url(url, payload)
def load_remote_base_url_from_local(): global remote_base_url global remote_key try: with connection.connect_db_row() as (db): res = db.query("SELECT value FROM local_table WHERE key='%s'" % remote_key) if res: remote_base_url = res[0]['value'] else: if remote_base_url and len(remote_base_url) > 0: db.execute_and_commit( ['INSERT INTO local_table VALUES (?, ?)'], [[(remote_key, remote_base_url)]]) except: pass
def get(self): with connection.connect_db_row() as (db): subtasks = db.query('SELECT * FROM subtask_table') if subtasks: return {'subtasks': subtasks} return {'subtasks': '[]'}
def get_local(local_key): with connection.connect_db_row() as db: result = db.query("SELECT value FROM local_table WHERE key='%s'" % local_key) return result[0]['value'] if result else None return None