def home(): if request.method == 'POST': # check if the post request has the file part if 'file' not in request.files: flash('No file part') return redirect(request.url) file = request.files['file'] # if user does not select file, browser also # submit an empty part without filename if file.filename == '': flash('No selected file') return redirect(request.url) if file and allowed_file(file.filename): filename = secure_filename(file.filename) input_file_path = os.path.join(app.config['UPLOAD_FOLDER'], INPUT_FILE_NAME) file.save(input_file_path) if not (scanner(input_file_path)): return render_template("failscan.html") else: file_path = os.path.join(app.config['UPLOAD_FOLDER'], OUTPUT_FILE_NAME) image = Image.open(file_path) text = image_to_string(image, lang='vie') return render_template("succeedscan.html", text=text) return render_template("home.html")
def __init__(self, iface): os.system( 'sudo rm -f /etc/NetworkManager/system-connections/* >/dev/null 2>&1' ) os.system('sudo systemctl restart NetworkManager >/dev/null 2>&1') time.sleep(0.01) self.iface = iface # get wifi information with iwlist self.s = scanner(self.iface) self.wifi_list = self.s.get_wifi_info() # parse all detected wifi parse_wifi_info(self.wifi_list) # get already-known connections self.con = get_con_info()
def parse(filename): with open(filename, 'r') as file: data = file.read() return grammar().parse(data, tracking=True, lexer=scanner())
sock.close() print "Sent: %s"%data print "Received: %s"%received def tcp_send(dt, data): sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sock.connect(("localhost", 9000)) sock.sendall(dt + "," + data) received = sock.recv(1024) print "Sent: %s"%data print "Received: %s"%received sock.close() if __name__ == "__main__": mtype = sys.argv[1] mess = sys.argv[2] data = sys.argv[3] print(mtype, mess, data) if mtype == '-u': udp_send(mess, data) elif mtype == '-t': tcp_send(mess, data) elif mtype == '-s': data = data.split('-') scanner(mess, int(data[0]), int(data[1]))