def upfile(): file = request.files['video'] elderid = request.values['elderid'] familyid = bind_list.get(elderid) print(file.filename) if file and allowed_file(file.filename): filename = secure_filename(file.filename) filepath = current_app.config['VIDEO_FOLDER'] + '/' + filename.rsplit( '.', 1)[0] if os.path.exists(filepath): delete_file_folder(filepath) os.makedirs(filepath + '/video') file.save(os.path.join(filepath + '/video', filename)) p = subprocess.Popen(current_app.config['BASH_TEST'] + filename.rsplit('.', 1)[0], shell=True) while not p.poll(): gevent.sleep(1) if os.path.isfile(filepath + '/kwsdir/result.xml'): msg[familyid].put('dangercalling') return 'find' with open(filepath + "/decode_dnn/log/decode.1.log") as f: s = f.read() r = re.sub( "[A-Za-z0-9\[\`\~\!\@\#\$\^\&\*\(\)\=\|\{\}\'\:\;\'\,\[\]\.\<\>\/\?\~\@\#\&\*\%\-\_\"\+]", "", s) r = r.strip() r = r.lstrip() klist = Keyword.high_rate_words() for k in r.split(" "): if k in klist: msg[familyid].put('dangercalling') return 'find' return 'notfind'
def complain(): file = request.files['video'] if file and allowed_file(file.filename): filename = secure_filename(file.filename) filepath = current_app.config['VIDEO_FOLDER'] + '/' + filename.rsplit( '.', 1)[0] file.save(os.path.join(filepath, filename)) p = subprocess.Popen(current_app.config['BASH_TEST'] + filename.rsplit('.', 1)[0], shell=True) while not p.poll(): gevent.sleep(1) with open(filepath + "/decode_dnn/log/decode.1.log") as f: s = f.read() r = re.sub( "[A-Za-z0-9\[\`\~\!\@\#\$\^\&\*\(\)\=\|\{\}\'\:\;\'\,\[\]\.\<\>\/\?\~\@\#\&\*\%\-\_\"\+]", "", s) r = r.strip() r = r.lstrip() for k in r.split(" "): if len(k) > 3: Keyword.add(k) with open( current_app.config['VIDEO_FOLDER'] + '/kwsdatadir/raw_keywords.txt', 'w+') as f: for i in Keyword.high_rate_words(): f.write(i.encode('utf8') + '\n') return 'success'