def renderMonitorStatus(self, db_result, machine_name, request): if len(db_result) == 0: request.setResponseCode(404) request.write('No entry for %s' % machine_name) request.finish() elif len(db_result) == 1: reg_epoch = db_result[0][0] payload = json.dumps( { REGISTRATION_EPOCH : reg_epoch } ) request.setHeader(HTTP_HEADER_CONTENT_TYPE, JSON_MIME_TYPE) request.write(payload) request.finish() else: log.msg('Error: Got multiple results for monitor status (should not happen)', system='sgas.MonitorResource') log.msg('Database result: %s' % str(db_result), system='sgas.MonitorResource') request.setResponseCode(500) request.write('Internal error in monitor resource (got multiple results)') request.finish()
def renderMonitorStatus(self, db_result, machine_name, request): if len(db_result) == 0: request.setResponseCode(404) request.write('No entry for %s' % machine_name) request.finish() elif len(db_result) == 1: reg_epoch = db_result[0][0] payload = json.dumps({REGISTRATION_EPOCH: reg_epoch}) request.setHeader(HTTP_HEADER_CONTENT_TYPE, JSON_MIME_TYPE) request.write(payload) request.finish() else: log.msg( 'Error: Got multiple results for monitor status (should not happen)', system='sgas.MonitorResource') log.msg('Database result: %s' % str(db_result), system='sgas.MonitorResource') request.setResponseCode(500) request.write( 'Internal error in monitor resource (got multiple results)') request.finish()
def gotDatabaseResult(rows): records = queryrowrp.buildDictRecords(rows, query_args) payload = json.dumps(records) request.setHeader(HTTP_HEADER_CONTENT_TYPE, JSON_MIME_TYPE) request.write(payload) request.finish()
def insertDone(result): request.write(json.dumps(result)) request.finish()
def gotDatabaseResult(rows): payload = json.dumps(rows) request.setHeader(HTTP_HEADER_CONTENT_TYPE, JSON_MIME_TYPE) request.write(payload) request.finish()