Beispiel #1
0
def parse_tasks():
    database = parse_db()
    tasks = request.args.getlist('t')
    if tasks and tasks[0].isdigit():
        all_tasks = d.list_tasks(database)
        tasks = [all_tasks[int(t)] for t in tasks]
    return tasks
Beispiel #2
0
def db_connector():
    tasks = idb.list_tasks()
    print "available tasks: ", len(tasks)
    task_num = int(raw_input("which task number to choose: "))
    available_choice = idb.describe_tasks([tasks[task_num]])
    available_name = [k.split()[0] for k in available_choice]
    available_type = [k.split()[1] for k in available_choice]
    print "==========================================================="
    print "available choices:"
    print "\n".join(i for i in available_choice)
    print "==========================================================="
    while 1:
        x = raw_input("choose a x axis name: ")
        if x in available_name:
            break
        print err_msg['choose axis']
    while 1:
        y = raw_input("choose a y axis name: ")
        if y in available_name:
            break
        print err_msg['choose axis']
    filt_list = []
    filt_name_list = []
    cur_choice = None
    print "==========================================================="
    while 1:
        while 1:
            cur_choice = raw_input("choose filter name (enter empty string to exit): ")
            if (cur_choice in available_name) or (cur_choice == ""):
                break
            print err_msg['choose axis']
        if cur_choice == '':
            break
        filt_name_list.append(cur_choice)
        cur_type = available_type[available_name.index(cur_choice)]
        fname = cur_choice
        fmethod = filter_method[cur_type]
        param_range = idb.describe_param(cur_choice + ' ' + cur_type, tasks[task_num])
        print "available range: ", param_range
        frange = None
        if len(param_range) == 1:
            print "set range to: ", param_range
            frange = param_range
        else:
            cur_range = raw_input("choose range: in the form of \"attr1 attr2 ...\" ")
            choice_fields = cur_range.split()
            if fmethod == 'BETWEEN' and choice_fields != []:
                frange = (float(choice_fields[0]), float(choice_fields[1]))
            elif fmethod == 'IN' and choice_fields != []:
                frange = choice_fields
            elif choice_fields == []:
                print "set range to: ", param_range
                frange = param_range
            else:
                print err_msg['choose method']
        filt_list.append(idb.Task_filter(fname, fmethod, frange))
    data = idb.retrieve_data(x, y, filt_list, tasks[task_num])
    return {"data": data, "filt_name_list": filt_name_list, "x": x, "y": y}
def get_view():
    database = parse_db()
    print(real_db(database))
    tasks = {task_name for (task_name) in d.list_tasks(real_db(database))}
    queried_tasks = parse_tasks()
    x = y = filters = ""
    # only pass other argument values if valid tasks selected
    if queried_tasks:
        x = request.args.get('x')
        y = request.args.get('y')
        (temp, filters) = parse_filters(verbose=True)

    return render_template('viewer.html',
                           database=database,
                           tasks=tasks,
                           queried_tasks=queried_tasks,
                           queried_x=x,
                           queried_y=y,
                           filters=filters)
def get_view():
    database = parse_db()
    print(real_db(database))
    tasks = {task_name for (task_name) in d.list_tasks(real_db(database))}
    queried_tasks = parse_tasks()
    x = y = filters = ""
    # only pass other argument values if valid tasks selected
    if queried_tasks:
        x = request.args.get('x')
        y = request.args.get('y') 
        (temp, filters) = parse_filters(verbose=True)
        

    return render_template('viewer.html',
                            database=database,
                            tasks=tasks,
                            queried_tasks=queried_tasks,
                            queried_x = x,
                            queried_y = y,
                            filters = filters)
def get_tasks():
    return jsonify({'tasks':d.list_tasks(database)})
def get_view():
    tasks = {task_name: task_context for (task_name, task_context) in [t.split('|',1) for t in d.list_tasks(database)]}
    queried_tasks = parse_tasks()
    x = y = filters = ""
    # only pass other argument values if valid tasks selected
    if queried_tasks:
        x = request.args.get('x')
        y = request.args.get('y') 
        (temp, filters) = parse_filters(verbose=True)
        

    return render_template('viewer.html',
                            tasks=tasks,
                            queried_tasks=queried_tasks,
                            queried_x = x,
                            queried_y = y,
                            filters = filters)
def get_tasks():
    database = parse_db()
    return jsonify({'tasks': d.list_tasks(database), 'database': database})
def get_tasks():
    database = parse_db()
    return jsonify({'tasks':d.list_tasks(database), 'database':database})
def db_connector():
    tasks = idb.list_tasks()
    print "available tasks: ", len(tasks)
    task_num = int(raw_input("which task number to choose: "))
    available_choice = idb.describe_tasks([tasks[task_num]])
    available_name = [k.split()[0] for k in available_choice]
    available_type = [k.split()[1] for k in available_choice]
    print "==========================================================="
    print "available choices:"
    print "\n".join(i for i in available_choice)
    print "==========================================================="
    while 1:
        x = raw_input("choose a x axis name: ")
        if x in available_name:
            break
        print err_msg['choose axis']
    while 1:
        y = raw_input("choose a y axis name: ")
        if y in available_name:
            break
        print err_msg['choose axis']
    filt_list = []
    filt_name_list = []
    cur_choice = None
    print "==========================================================="
    while 1:
        while 1:
            cur_choice = raw_input(
                "choose filter name (enter empty string to exit): ")
            if (cur_choice in available_name) or (cur_choice == ""):
                break
            print err_msg['choose axis']
        if cur_choice == '':
            break
        filt_name_list.append(cur_choice)
        cur_type = available_type[available_name.index(cur_choice)]
        fname = cur_choice
        fmethod = filter_method[cur_type]
        param_range = idb.describe_param(cur_choice + ' ' + cur_type,
                                         tasks[task_num])
        print "available range: ", param_range
        frange = None
        if len(param_range) == 1:
            print "set range to: ", param_range
            frange = param_range
        else:
            cur_range = raw_input(
                "choose range: in the form of \"attr1 attr2 ...\" ")
            choice_fields = cur_range.split()
            if fmethod == 'BETWEEN' and choice_fields != []:
                frange = (float(choice_fields[0]), float(choice_fields[1]))
            elif fmethod == 'IN' and choice_fields != []:
                frange = choice_fields
            elif choice_fields == []:
                print "set range to: ", param_range
                frange = param_range
            else:
                print err_msg['choose method']
        filt_list.append(idb.Task_filter(fname, fmethod, frange))
    data = idb.retrieve_data(x, y, filt_list, tasks[task_num])
    return {"data": data, "filt_name_list": filt_name_list, "x": x, "y": y}
Beispiel #10
0
def db_connector():
    tasks = idb.list_tasks()
    print "available tasks: "
    for i in range(len(tasks)):
        print "[" + str(i) + "]: ", tasks[i]
    task_num = int(raw_input("which task to choose (input the index): "))
    available_choice = idb.describe_tasks([tasks[task_num]])
    available_name = [k.raw()[0] for k in available_choice]
    available_type = [k.raw()[1] for k in available_choice]
    print "==========================================================="
    print "available choices:"
    print "\n".join(i for i in available_choice)
    print "==========================================================="
    while 1:
        x = raw_input("choose a x axis name: ")
        if x in available_name:
            break
        print err_msg["choose axis"]
    while 1:
        y = raw_input("choose a y axis name: ")
        if y in available_name:
            break
        print err_msg["choose axis"]
    filt_list = []
    filt_name_list = []
    cur_choice = None
    print "==========================================================="
    while 1:
        while 1:
            cur_choice = raw_input(
                "choose filter name (enter empty string to exit): ")
            if (cur_choice in available_name) or (cur_choice == ""):
                break
            print err_msg["choose axis"]
        if cur_choice == "":
            break
        filt_name_list.append(cur_choice)
        cur_type = available_type[available_name.index(cur_choice)]
        fname = cur_choice
        fmethod = filter_method[cur_type]
        param_range = idb.describe_param(cur_choice + " " + cur_type, "range",
                                         tasks[task_num])
        print "available range: ", param_range
        frange = None
        if len(param_range) == 1:
            print "set range to: ", param_range
            frange = param_range
        else:
            cur_range = raw_input(
                'choose range: in the form of "attr1 attr2 ... (enter empty string to select all values)" '
            )
            choice_fields = cur_range.raw()
            if fmethod == "BETWEEN" and choice_fields != []:
                frange = (float(choice_fields[0]), float(choice_fields[1]))
            elif fmethod == "IN" and choice_fields != []:
                frange = choice_fields
            elif choice_fields == []:
                print "set range to: ", param_range
                frange = param_range
            else:
                print err_msg["choose method"]
        # filt_list.append(idb.Task_filter(fname, fmethod, frange))
        filt_list.append(frange[1])
    filt_list = [item for sublist in filt_list for item in sublist]
    print "------"
    print filt_list
    data = idb.retrieve_data(x, y, filt_list, [tasks[task_num]])[1]
    return {"data": data, "filt_name_list": filt_name_list, "x": x, "y": y}
Beispiel #11
0
def get_tasks():
    database = parse_db()
    return jsonify({"tasks": d.list_tasks(database), "database": database})