示例#1
0
def view_json(job_id):
    """Light info to be retrieved via AJAX"""
    job = http_server_request('get', '/jobs/{0}'.format(job_id))
    job['total_time'] = seconds_to_time(job['total_time'])
    job['average_time'] = seconds_to_time(job['average_time'])
    for task in job['tasks']:
        task['log'] = None
    return jsonify(job)
示例#2
0
def view_json(job_id):
    """Light info to be retrieved via AJAX"""
    job = http_server_request('get', '/jobs/{0}'.format(job_id))
    job['total_time'] = seconds_to_time(job['total_time'])
    job['average_time'] = seconds_to_time(job['average_time'])
    job['thumbnail'] = 'http://%s/jobs/thumbnails/%s' % (FLAMENCO_SERVER, job_id)
    for task in job['tasks']:
        task['log'] = None
    return jsonify(job)
示例#3
0
文件: jobs.py 项目: jeffbean/flamenco
def view_json(job_id):
    """Light info to be retrieved via AJAX"""
    job = http_server_request("get", "/jobs/{0}".format(job_id))
    job["total_time"] = seconds_to_time(job["total_time"])
    job["average_time"] = seconds_to_time(job["average_time"])
    job["average_time_frame"] = seconds_to_time(job["average_time_frame"])
    job["thumbnail"] = "http://%s/jobs/thumbnails/%s" % (FLAMENCO_SERVER, job_id)
    for task in job["tasks"]:
        task["log"] = None
    return jsonify(job)
示例#4
0
def view_json(job_id):
    """Light info to be retrieved via AJAX"""
    job = http_server_request('get', '/jobs/{0}'.format(job_id))
    job['total_time'] = seconds_to_time(job['total_time'])
    job['average_time'] = seconds_to_time(job['average_time'])
    job['average_time_frame'] = seconds_to_time(job['average_time_frame'])
    job['thumbnail'] = 'http://%s/jobs/thumbnails/%s' % (FLAMENCO_SERVER,
                                                         job_id)
    for task in job['tasks']:
        task['log'] = None
    return jsonify(job)
示例#5
0
文件: jobs.py 项目: frudas24/flamenco
def index():
    jobs = http_server_request('get', '/jobs')
    jobs_list = []

    for key, val in jobs.iteritems():

        remaining_time = val['remaining_time']
        if not remaining_time:
            remaining_time = '-'
        else:
            remaining_time = seconds_to_time(remaining_time)
        average_time = val['average_time']
        if not average_time:
            average_time = '-'
        else:
            average_time = seconds_to_time(average_time)
        total_time = val['total_time']
        if not total_time:
            total_time = '-'
        else:
            total_time = seconds_to_time(total_time)
        job_time = val['job_time']
        if job_time:
            total_time = "{0} ({1})".format(total_time, seconds_to_time(job_time))

        val['checkbox'] = '<input type="checkbox" value="' + key + '" />'
        jobs_list.append({
            "DT_RowId" : "job_" + str(key),
            "0" : val['checkbox'],
            "1" : key,
            "2" : 'http://{0}/jobs/thumbnails/{1}s'.format(BRENDER_SERVER, key),
            "3" : val['job_name'],
            "4" : val['percentage_done'],
            "5" : remaining_time,
            "6" : average_time,
            "7" : total_time,
            "8" : val['activity'],
            "9" : val['status'],
            "10" : None,
            "11" : val['creation_date'],
            "12" : val['priority']
            })

    jobs_list = sorted(jobs_list, key=lambda x: x['1'])
    entries = json.dumps(jobs_list)

    return render_template('jobs/index.html', entries=entries, title='jobs')
示例#6
0
def index_json():
    """Generate DataTable-ready JSON with all non archived jobs. Accepts a 'pretty'
    argument that will pretty print the list.
    """

    # Check if we are requesting for a specific status (e.g. archived)
    if request.args.get('status'):
        jobs_route = "/jobs?status={0}".format(request.args.get('status'))
    else:
        jobs_route = '/jobs'

    jobs = http_server_request('get', jobs_route)
    jobs_list = []

    for key, val in jobs.iteritems():

        remaining_time = val['time_remaining']
        if not remaining_time:
            remaining_time = '-'
        else:
            remaining_time = seconds_to_time(remaining_time)
        average_time = val['time_average']
        if not average_time:
            average_time = '-'
        else:
            average_time = seconds_to_time(average_time)
        total_time = val['time_total']
        if not total_time:
            total_time = '-'
        else:
            total_time = seconds_to_time(total_time)
        job_time = None
        if job_time:
            total_time = "{0} ({1})".format(total_time, seconds_to_time(job_time))

        time_elapsed = val['time_elapsed']
        if time_elapsed == None:
            time_elapsed = ''
        else:
            time_elapsed = seconds_to_time(time_elapsed)


        val['checkbox'] = '<input type="checkbox" value="' + key + '" />'
        jobs_list.append({
            'DT_RowId' : 'job_' + str(key),
            'checkbox' : val['checkbox'],
            'job_id' : key,
            'thumbnail' : 'http://{0}/jobs/thumbnails/{1}s'.format(FLAMENCO_SERVER, key),
            'name' : val['job_name'],
            'percentage_done' : val['percentage_done'],
            'time_remaining' : remaining_time,
            'time_average' : average_time,
            'time_total' : total_time,
            'status' : val['status'],
            'date_creation' : val['creation_date'],
            'priority' : val['priority'],
            'manager': val['manager'],
            'time_elapsed': time_elapsed
            })

    #jobs_list = sorted(jobs_list, key=lambda x: x['1'])

    # For debugging, if we add the pretty arg to the get request, we get a pretty
    # printed version of the jobs_list
    if request.args.get('pretty'):
        if request.args.get('pretty') == 'true':
            return jsonify(data=jobs_list)


    # Default json return
    jobs_list_dict = {'data': jobs_list}
    content = u"{0}".format(json.dumps(jobs_list_dict))
    return Response(content, mimetype='application/json')
示例#7
0
文件: jobs.py 项目: jeffbean/flamenco
def index_json():
    """Generate DataTable-ready JSON with all non archived jobs. Accepts a 'pretty'
    argument that will pretty print the list.
    """

    # Check if we are requesting for a specific status (e.g. archived)
    if request.args.get("status"):
        jobs_route = "/jobs?status={0}".format(request.args.get("status"))
    else:
        jobs_route = "/jobs"

    jobs = http_server_request("get", jobs_route)
    jobs_list = []

    for key, val in jobs.iteritems():

        remaining_time = val["time_remaining"]
        if not remaining_time:
            remaining_time = "-"
        else:
            remaining_time = seconds_to_time(remaining_time)
        average_time = val["time_average"]
        if not average_time:
            average_time = "-"
        else:
            average_time = seconds_to_time(average_time)
        total_time = val["time_total"]
        if not total_time:
            total_time = "-"
        else:
            total_time = seconds_to_time(total_time)
        job_time = None
        if job_time:
            total_time = "{0} ({1})".format(total_time, seconds_to_time(job_time))

        time_elapsed = val["time_elapsed"]
        if time_elapsed == None:
            time_elapsed = ""
        else:
            time_elapsed = seconds_to_time(time_elapsed)

        val["checkbox"] = '<input type="checkbox" value="' + key + '" />'
        jobs_list.append(
            {
                "DT_RowId": "job_" + str(key),
                "checkbox": val["checkbox"],
                "job_id": key,
                "thumbnail": "http://{0}/jobs/thumbnails/{1}s".format(FLAMENCO_SERVER, key),
                "name": val["job_name"],
                "percentage_done": val["percentage_done"],
                "time_remaining": remaining_time,
                "time_average": average_time,
                "time_total": total_time,
                "status": job_status,
                "date_creation": val["creation_date"],
                "date_edit": val["date_edit"],
                "priority": val["priority"],
                "manager": val["manager"],
                "time_elapsed": time_elapsed,
                "tasks_status": val["tasks_status"],
                "username": val["username"],
            }
        )

    # jobs_list = sorted(jobs_list, key=lambda x: x['1'])

    # For debugging, if we add the pretty arg to the get request, we get a pretty
    # printed version of the jobs_list
    if request.args.get("pretty"):
        if request.args.get("pretty") == "true":
            return jsonify(data=jobs_list)

    # Default json return
    jobs_list_dict = {"data": jobs_list}
    content = u"{0}".format(json.dumps(jobs_list_dict))
    return Response(content, mimetype="application/json")
示例#8
0
def index_json():
    """Generate DataTable-ready JSON with all non archived jobs. Accepts a 'pretty'
    argument that will pretty print the list.
    """

    # Check if we are requesting for a specific status (e.g. archived)
    if request.args.get('status'):
        jobs_route = "/jobs?status={0}".format(request.args.get('status'))
    else:
        jobs_route = '/jobs'

    jobs = http_server_request('get', jobs_route)
    jobs_list = []

    for key, val in jobs.iteritems():

        remaining_time = val['time_remaining']
        if not remaining_time:
            remaining_time = '-'
        else:
            remaining_time = seconds_to_time(remaining_time)
        average_time = val['time_average']
        if not average_time:
            average_time = '-'
        else:
            average_time = seconds_to_time(average_time)
        total_time = val['time_total']
        if not total_time:
            total_time = '-'
        else:
            total_time = seconds_to_time(total_time)
        job_time = None
        if job_time:
            total_time = "{0} ({1})".format(total_time,
                                            seconds_to_time(job_time))

        time_elapsed = val['time_elapsed']
        if time_elapsed == None:
            time_elapsed = ''
        else:
            time_elapsed = seconds_to_time(time_elapsed)

        val['checkbox'] = '<input type="checkbox" value="' + key + '" />'
        jobs_list.append({
            'DT_RowId':
            'job_' + str(key),
            'checkbox':
            val['checkbox'],
            'job_id':
            key,
            'thumbnail':
            'http://{0}/jobs/thumbnails/{1}s'.format(FLAMENCO_SERVER, key),
            'name':
            val['job_name'],
            'percentage_done':
            val['percentage_done'],
            'time_remaining':
            remaining_time,
            'time_average':
            average_time,
            'time_total':
            total_time,
            'status':
            val['status'],
            'date_creation':
            val['creation_date'],
            'date_edit':
            val['date_edit'],
            'priority':
            val['priority'],
            'manager':
            val['manager'],
            'time_elapsed':
            time_elapsed,
            'tasks_status':
            val['tasks_status'],
            'username':
            val['username']
        })

    #jobs_list = sorted(jobs_list, key=lambda x: x['1'])

    # For debugging, if we add the pretty arg to the get request, we get a pretty
    # printed version of the jobs_list
    if request.args.get('pretty'):
        if request.args.get('pretty') == 'true':
            return jsonify(data=jobs_list)

    # Default json return
    jobs_list_dict = {'data': jobs_list}
    content = u"{0}".format(json.dumps(jobs_list_dict))
    return Response(content, mimetype='application/json')