Ejemplo n.º 1
0
def get_log(log):
    path = "/log/" + log
    if not logs.exists(path):
        data = "No such log!"
    else:
        data = bz2.decompress(logs.get(path).read())
    if 'plugin' in request.args:
        plugin = request.args.get('plugin')
        data = extract_plugin_log(data, plugin)
        if 'diff' in request.args:
            header = data[:data.find('\n')]
            base = request.args.get('base')
            ticket_id = request.args.get('ticket')
            base_data = bz2.decompress(logs.get(request.args.get('diff')).read())
            base_data = extract_plugin_log(base_data, plugin)
            diff = difflib.unified_diff(base_data.split('\n'), data.split('\n'), base, "%s + #%s" % (base, ticket_id), n=0)
            data = data = '\n'.join(('' if item[0] == '@' else item) for item in diff)
            if not data:
                data = "No change."
            data = header + "\n\n" + data
            
    if 'short' in request.args:
        response = Response(shorten(data), direct_passthrough=True)
    else:
        response = make_response(data)
    response.headers['Content-type'] = 'text/plain'
    return response
Ejemplo n.º 2
0
def get_log(log):
    path = "/log/" + log
    if not logs.exists(path):
        data = "No such log!"
    else:
        data = bz2.decompress(logs.get(path).read())
    if 'plugin' in request.args:
        data = extract_plugin_log(data, request.args.get('plugin'))
    if 'short' in request.args:
        response = Response(shorten(data), direct_passthrough=True)
    else:
        response = make_response(data)
    response.headers['Content-type'] = 'text/plain'
    return response