def get_calcs(db, request_get_dict, allowed_users, user_acl_on=False, id=None):
    """
    :param db:
        a :class:`openquake.server.dbapi.Db` instance
    :param request_get_dict:
        a dictionary
    :param allowed_users:
        a list of users
    :param user_acl_on:
        if True, returns only the calculations owned by the user or the group
    :param id:
        if given, extract only the specified calculation
    :returns:
        list of tuples (job_id, user_name, job_status, calculation_mode,
                        job_is_running, job_description)
    """
    # helper to get job+calculation data from the oq-engine database
    filterdict = {}

    if id is not None:
        filterdict['id'] = id

    if 'calculation_mode' in request_get_dict:
        filterdict['calculation_mode'] = request_get_dict.get(
            'calculation_mode')

    if 'is_running' in request_get_dict:
        is_running = request_get_dict.get('is_running')
        filterdict['is_running'] = valid.boolean(is_running)

    if 'relevant' in request_get_dict:
        relevant = request_get_dict.get('relevant')
        filterdict['relevant'] = valid.boolean(relevant)

    if 'limit' in request_get_dict:
        limit = int(request_get_dict.get('limit'))
    else:
        limit = 100

    if 'start_time' in request_get_dict:
        # assume an ISO date string
        time_filter = "start_time >= '%s'" % request_get_dict.get('start_time')
    else:
        time_filter = 1

    if user_acl_on:
        users_filter = "user_name IN (?X)"
    else:
        users_filter = 1

    jobs = db('SELECT * FROM job WHERE ?A AND %s AND %s'
              ' ORDER BY id DESC LIMIT %d'
              % (users_filter, time_filter, limit), filterdict, allowed_users)
    return [(job.id, job.user_name, job.status, job.calculation_mode,
             job.is_running, job.description, job.pid,
             job.hazard_calculation_id, job.size_mb) for job in jobs]
def get_calcs ( db , request_get_dict , allowed_users , user_acl_on = False , id = None ) : filterdict = { } if id is not None : filterdict [ 'id' ] = id if 'calculation_mode' in request_get_dict : filterdict [ 'calculation_mode' ] = request_get_dict . get ( 'calculation_mode' ) if 'is_running' in request_get_dict : is_running = request_get_dict . get ( 'is_running' ) filterdict [ 'is_running' ] = valid . boolean ( is_running ) if 'relevant' in request_get_dict : relevant = request_get_dict . get ( 'relevant' ) filterdict [ 'relevant' ] = valid . boolean ( relevant ) if 'limit' in request_get_dict : limit = int ( request_get_dict . get ( 'limit' ) ) else : limit = 100 if 'start_time' in request_get_dict : time_filter = "start_time >= '%s'" % request_get_dict . get ( 'start_time' ) else : time_filter = 1 if user_acl_on : users_filter = "user_name IN (?X)" else : users_filter = 1 jobs = db ( 'SELECT * FROM job WHERE ?A AND %s AND %s' ' ORDER BY id DESC LIMIT %d' % ( users_filter , time_filter , limit ) , filterdict , allowed_users ) return [ ( job . id , job . user_name , job . status , job . calculation_mode , job . is_running , job . description , job . pid , job . hazard_calculation_id , job . size_mb ) for job in jobs ]
:param db:
        a :class:`openquake.server.dbapi.Db` instance
    :param request_get_dict:
        a dictionary
    :param allowed_users:
        a list of users
    :param user_acl_on:
        if True, returns only the calculations owned by the user or the group
    :param id:
        if given, extract only the specified calculation
    :returns:
        list of tuples (job_id, user_name, job_status, calculation_mode,
                        job_is_running, job_description)