Exemplo n.º 1
0
def return_component_roles(project_key, component):
    project_key = str(project_key).lower()
    component = str(component).lower()
    log.trace(log, ("GET /%s/%s" % (project_key, component)))
    result = query_database(project_key, component)
    if result == False or result == "":
        abort(404)
    else:
        return result
Exemplo n.º 2
0
def query_database(project_key, component):
    log.trace(log, "Enter query_database.")
    try:
        db = sql.connect(path_to_db)
        c = db.cursor()
        result = c.execute('SELECT * FROM roletable WHERE project_key = ? AND component = ?;', (project_key, component))
        return result.fetchone()
    except:
        log.error(log, ("An exception occurred trying to look up values for %s and %s." % (project_key, component)))
        return False
Exemplo n.º 3
0
def not_found():
    log.warning(log, "Returning 404.")
    return "No results found."
Exemplo n.º 4
0
    try:
        db = sql.connect(path_to_db)
        c = db.cursor()
        result = c.execute('SELECT * FROM roletable WHERE project_key = ? AND component = ?;', (project_key, component))
        return result.fetchone()
    except:
        log.error(log, ("An exception occurred trying to look up values for %s and %s." % (project_key, component)))
        return False

@app.route('/<project_key>/<component>')
def return_component_roles(project_key, component):
    project_key = str(project_key).lower()
    component = str(component).lower()
    log.trace(log, ("GET /%s/%s" % (project_key, component)))
    result = query_database(project_key, component)
    if result == False or result == "":
        abort(404)
    else:
        return result

@app.errorhandler(404)
def not_found():
    log.warning(log, "Returning 404.")
    return "No results found."

if __name__ == '__main__':
    log.loggingLevel = logging_level
    log.logFilePath = log_file_path
    log.information(log, "Starting JPR.")
    app.run()