Ejemplo n.º 1
0
def add_to_selection(msg):
    '''
    Add file from selected list
    '''
    filepath = measure_path_from_name(msg['file'])
    ret = add_file_selected(filepath)
    old_list = user_files_selected()
    socketio.emit('update_selection',json.dumps({'files':old_list,'err':int(ret)}))
Ejemplo n.º 2
0
def select_from_folder(msg):
    '''
    Select all the files in a folder.
    '''
    #relative_path = os.path.join(msg['path'], msg['folder'])
    relative_path = msg['folder']
    ret = True
    for root, dirs, files in os.walk(os.path.join(app.config["GLOBAL_MEASURES_PATH"],relative_path), topdown=False):
        for name in files:
            if name.endswith('.h5'):
                ret = ret and add_file_selected(measure_path_from_name(name))
    socketio.emit('update_selection',json.dumps({'files':user_files_selected(),'err':int(ret)}))
Ejemplo n.º 3
0
def remove_from_selection(msg):
    '''
    Remove file from selected list
    '''
    old_list = user_files_selected()
    filepath = measure_path_from_name(msg['file'])
    if filepath in old_list:

        ret = remove_file_selected(filepath)
        old_list = user_files_selected()
        socketio.emit('update_selection',json.dumps({'files':old_list,'err':int(ret)}))
    else:
        print_warning('cannot remove %s from selected list, not found'%filepath)
Ejemplo n.º 4
0
def add_source_file(msg):
    print("Adding %s to file source (permanent? %s) for user %s"%(msg['file'], msg['permanent'], current_user.username))
    if msg['group'] == '':
        gr = None
    else:
        gr = msg['group']
    try:
        file_path = measure_path_from_name(msg['file'])
        add_file_source(file_path, msg['permanent'], gr)
        result = 1
    except ValueError:
        print_warning("Database error, cannot add file %s to source"%msg['file'])
        result = 0
    socketio.emit('explore_add_source_done',json.dumps({'file':str(msg['file']),'result':result}))
Ejemplo n.º 5
0
def send_selection_update_file_list(msg):
    file_req = msg['file']
    path = measure_path_from_name(file_req)
    plots = get_associated_plots([path])['plots'][0]
    ret = []
    for i in range(len(plots['path'])):
        ret.append([
            plots['path'][i],
            plots['kind'][i],
            plots['timestamp'][i],
            plots['comment'][i],
        ])
    # print(ret)

    socketio.emit('update_selection_plot_list',json.dumps({'items':ret}))