def del_all_samples(application, folder): logging.info('Visited del all sample for user ' + application + ' ' + folder) user = db.get_user(current_user.id) if user['role'] != 'admin': return 'You should be an admin' cur_user = session['user_to_review'] bucket_name = config[application]['bucket'] files = db.get_files(application, folder, cur_user) for i in range(len(files)): filename = files[i]['filename'] fn_1 = filename fn_2 = filename.replace('.json', '.' + config[application]["image_ext"]) #print(fn_1,fn_2) try: s3.Object(bucket_name, folder + '/' + fn_1).delete() db.delete_file(application, folder, fn_1) s3.Object(bucket_name, folder + '/' + fn_2).delete() db.delete_file(application, folder, fn_2) except botocore.exceptions.ClientError as e: logging.error(bucket_name + ' ' + folder + ' ' + fn_1 + ' ' + fn_2 + ' were not deleted') return redirect('/review/' + application)
def process(db_file, input_dir, output_dir): rows = get_files(db_file) for row in rows: id = row[0] title = row[1] pos = row[2] new_title = fix_title(title) # print(id, pos, title, new_title) input_file = input_dir + "/" + id + ".mp4" output_file = output_dir + "/" + str(pos) + "-" + new_title + ".mp3" print(input_file, output_file) convert(input_file, output_file)
def get_duplicates(): dupes = {} keys = db.get_duplicate_hashes() for k in keys: dupes[k] = db.get_files(k.decode()) # TEST PRINT print("HASH: {}".format(k.decode())) for f in dupes[k]: print(f) return dupes
def review_get(application): logging.info('Visited review') user = db.get_user(current_user.id) if user['role'] != 'admin': return 'You should be an admin' names, ids = db.get_all_users() ids.insert(0, 'all users') if request.method == 'POST': session['user_to_review'] = request.form['select_user'] files = [] if session.get('user_to_review') is not None: cur_user = session['user_to_review'] if not cur_user == 'all users': files_ = db.get_files(application, config[application]['output'], cur_user) else: files_ = db.get_files(application, config[application]['output'], ext='.json') for i in range(len(files_)): files.append(files_[i]['filename']) else: cur_user = '******' return render_template('review_choose_user.html', users=ids, application=application, cur_user=cur_user, files=files, output=config[application]['output'], log_in_or_out='out')
def get_user_files(username): return db.get_files(username)