def login_start(self, username_wg, password_wg, root): self.stop = False #playing gif def loading_gif(speed): gifs = [] for i in range(31): gifs.append( Image.open( os.path.join( os.path.dirname(__file__), "graphics/loading/frame-" + str(i) + ".png"))) gifs = [gif.resize((60, 60)) for gif in gifs] load_widgets = [] while (True): if (self.stop): [elem.destroy() for elem in load_widgets] break for gif in gifs: if (self.stop): [elem.destroy() for elem in load_widgets] break img = ImageTk.PhotoImage(gif) load_widget = Label(root, image=img, borderwidth="0", bg=ui_settings.primary_bg) load_widget.image = img load_widget.grid(row=5, columnspan=3, sticky=W + E) time.sleep(speed) load_widgets.append(load_widget) return ThreadPoolExecutor().submit(loading_gif, 0.02) #login function username = username_wg.get() password = password_wg.get() userdata.username = username userdata.password = password res = login.login_func(username, password) if (res): self.stop = True if (self.remember_name_var.get() == True): with open( os.path.join(os.path.dirname(__file__), "username.txt"), "w") as file: file.write(username_wg.get()) self.root.destroy() else: login_text_wg = Label(root, text="wrong password or username", bg=ui_settings.primary_bg, fg=ui_settings.plain_text_fg) login_text_wg.grid(row=6, columnspan=3) login_text_wg.config(font=self.font_sec, foreground="red") self.stop = True
def main(): apiIntent = "" username, account_id = (-1, -1) while (username == -1 and account_id == -1): username, account_id = login.login_func() name = "" integrate.printOut(int(account_id)) with open( os.path.join(par_dir, "bot-data_analysis-management/data/credentials.csv"), 'r') as file: reader = csv.reader(file, delimiter=',') for row in reader: if (row[1] == username): name = row[0] talk = 0 while (apiIntent != "bye"): stringu = raw_input("User : "******"User Sentiment : " + userSentiment) ai = apiai.ApiAI(CLIENT_ACCESS_TOKEN) request = ai.text_request() request.lang = 'de' # optional, default value equal 'en' request.session_id = "<SESSION ID, UNIQUE FOR EACH USER>" request.query = stringu response = request.getresponse() string = response.read().decode('utf-8') json_obj = json.loads(string) apiIntent = "" try: apiIntent = json_obj["result"]["metadata"]["intentName"] except: apiIntent = "" if (talk == 0): apiResp = "Hello " + name + "! How may I help you?" else: apiResp = json_obj["result"]["fulfillment"]["speech"] #print("Intent name: "+apiIntent) speech.say(apiResp) print("Agent : " + apiResp) talk = talk + 1
def main(): apiIntent="" username, account_id = (-1, -1) while (username == -1 and account_id == -1): username, account_id = login.login_func() name = "" #integrate.printOut(int(account_id)) with open(os.path.join(curr_path, "data/credential.csv")) as file: reader = csv.reader(file, delimiter=',') for row in reader: if (row[1] == username): name = row[0] talk = 0 while(apiIntent!="bye"): stringu=record_voice.now()#raw_input("User : "******"User Sentiment : "+userSentiment) ai = apiai.ApiAI(CLIENT_ACCESS_TOKEN) request = ai.text_request() request.lang = 'de' # optional, default value equal 'en' request.session_id = "<SESSION ID, UNIQUE FOR EACH USER>" request.query = stringu response = request.getresponse() string = response.read().decode('utf-8') json_obj = json.loads(string) apiIntent="" try: apiIntent=json_obj["result"]["metadata"]["intentName"] except: apiIntent = "" if (talk==0): apiResp="Hello "+name+"! How may I help you?" speech.say(apiResp) print("Agent : " + apiResp) else: if(apiIntent=="balance_desc"): os.system("python backend_functions/banking.py balance "+str(account_id)) elif (apiIntent == "transfer"): amount=json_obj["result"]["parameters"]["unit-currency"] if (amount!=""): amount = filter(lambda x: x.isdigit(), amount) elif (amount==""): amount=json_obj["result"]["parameters"]["number"] while(amount==""): speech.say("Please enter the amount") amount=raw_input("Agent : Please enter the amount") amount=filter(lambda x: x.isdigit(), amount) print("python backend_functions/banking.py transaction " + str(account_id) +' "' + str(json_obj["result"]["parameters"]["userName"]) + '" ' + str(amount)) os.system("python backend_functions/banking.py transaction " + str(account_id) +' "'+str(json_obj["result"]["parameters"]["userName"])+'" '+str(amount)) else: apiResp=json_obj["result"]["fulfillment"]["speech"] speech.say(apiResp) print("Agent : "+apiResp) talk=talk+1
print "For new registration Enter 2\n" print "========================" print "========================" user_input = int(raw_input("Enter User Choice:")) print type(user_input), int(user_input) while int(user_input) != 1 and int(user_input) != 2: print "Entered Wrong Choice please enter 1 or 2\n" user_input = int(raw_input("Enter User Choice:")) if int(user_input) == 1: print "Plese Enter user name and password" username = raw_input("Enter user name:") password = raw_input("Enter password") res = login.login_func(username, password) choice = 3 while choice: if res: break else: choice -= 1 username = raw_input("Enter user name:") password = raw_input("Enter password") res = login.login_func(username, password) else: print "You tried max number if times please after 3 mnts" elif int(user_input) == 2: print "Please fill the Registartion Form"
def login(request): s = login_func(request) return s