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_param_desc(): tasks = parse_tasks() param = request.args.get('p') mode = request.args.get('m', 'range') # by default give ranges, overriden if param is text try: (param_type, param_val) = d.describe_param(param, mode, tasks, database) except ValueError as e: return jsonify({'status': 'Parameter value error: {}'.format(e)}) return jsonify({'status': 'OK', 'tasks':tasks, 'param': param, 'type': param_type, 'val': param_val})
def get_param_desc(): database = parse_db() tasks = parse_tasks() param = request.args.get('p') mode = request.args.get('m', 'range') # by default give ranges, overriden if param is text try: (param_type, param_val) = d.describe_param(param, mode, tasks, real_db(database)) except ValueError as e: return jsonify({'status': 'Parameter value error: {}'.format(e)}) return jsonify({'status': 'OK', 'database':database, 'tasks':tasks, 'param': param, 'type': param_type, 'val': param_val})
def get_param_desc(): database = parse_db() tasks = parse_tasks() param = request.args.get("p") mode = request.args.get("m", "range") # by default give ranges, overriden if param is text try: (param_type, param_val) = d.describe_param(param, mode, tasks, real_db(database)) except ValueError as e: return jsonify({"status": "Parameter value error: {}".format(e)}) return jsonify( { "status": "OK", "database": database, "tasks": tasks, "param": param, "type": param_type, "val": param_val, } )
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 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}