def login_clicked(event=0): label["text"] = 'Entering room, please wait...' configData = configHandler.getConfig() myRoom = configData['myRoom'] timeout = 15 if room.get(): myRoom = room.get() try: configData['timeout'] = int(configData['timeout']) if 3 <= configData['timeout'] <= 40: timeout = configData['timeout'] except: pass arguments = ( myRoom, configData['myUsername'], configData['myPassword'], configData['myName'], timeout, ) hfuLoginThread = threading.Thread(target=threadHfuLogin, args=(arguments), daemon=True) hfuLoginThread.start() checkStatus()
def global_checkStatus(root): global threadHfuLoginStatus global alfaviewUrl configData = configHandler.getConfig() bandWidth = 'normal' if configData['bandWidth']: bandWidth = configData['bandWidth'] if threadHfuLoginStatus == 0: alfaviewEngine.start(alfaviewUrl, bandWidthUsage=bandWidth, noUpdate=0, skipQuickSetup=1, alfaviewPath='') root.destroy() if threadHfuLoginStatus == 1: msg = ( f'We are sorry to inform you that an error occurred.\n' 'This could either be because you entered wrong information or due to a bug in the app.' ) messagebox.showerror(title='ERROR OCCURRED', message=msg) root.destroy() if threadHfuLoginStatus == 2: #do nothing pass
def main(): if args.configDir == None: if system() == 'Linux': args.configDir = '~/.config/betawatch' elif system() == 'Windows': args.configDir = '%AppData%\\..\\Local\\betawatch\\' elif system() == 'Darwin': args.configDir = '~/Library/Application Support/betawatch' else: args.configDir = '.' if args.config: editConfig(args.configDir) if not args.noUI and args.room == None and args.username == None and args.password == None and args.displayName == None and not args.config: startGUI(args.configDir) config = configHandler.getConfig(args.configDir) if args.room != None: config['myRoom'] = args.room if args.username != None: config['myUsername'] = args.username if args.password != None: config['myPassword'] = args.password if args.displayName != None: config['myName'] = args.displayName if config['myRoom'] == None: config['myRoom'] = input('What room do you want to join?: ') if config['myUsername'] == None: config['myUsername'] = input('Your HFU account username: '******'myPassword'] == None or args.username != None: print('Your password for the HFU account "', config['myUsername'], '": ', sep='', end='', flush=True) config['myPassword'] = getpass('') if config['myName'] == None: config['myName'] = input('What should we call you?: ') openAlfaview(args.room, args.username, args.password, args.displayName)
def editConfig(configDir='.'): config = configHandler.getConfig(configDir) # set room print() print('What room do you want to join by default?') if config['myRoom'] == None: print('Enter value or press ENTER to skip: ', end='') else: print('Enter value or press ENTER to keep current value ("', config['myRoom'], '"): ', sep='', end='') tmp_room = input() if tmp_room != '': config['myRoom'] = tmp_room # set username print() print('Your HFU account username?') if config['myUsername'] == None: print('Enter value or press ENTER to skip: ', end='') else: print('Enter value or press ENTER to keep current value ("', config['myUsername'], '"): ', sep='', end='') tmp_username = input() if tmp_username != '': config['myUsername'] = tmp_username # set password print() if config['myUsername'] == None: print('Your HFU account password?') else: print('Your password for the HFU account "', config['myUsername'], '"?', sep='') if config['myPassword'] == None: print('Enter value or press ENTER to skip: ', end='') else: print('Enter value or press ENTER to keep current value: ', sep='', end='', flush=True) tmp_password = getpass('') if tmp_password != '': config['myPassword'] = tmp_password # set displayName print() print('What should we call you?') if config['myName'] == None: print('Enter value or press ENTER to skip: ', end='') else: print('Enter value or press ENTER to keep current value ("', config['myName'], '"): ', sep='', end='') tmp_displayName = input() if tmp_displayName != '': config['myName'] = tmp_displayName configHandler.setConfig(config, configDir)
def openConfig(parent): myRoom = tk.StringVar() myUsername = tk.StringVar() myPassword = tk.StringVar() myName = tk.StringVar() bandWidth = tk.StringVar() timeout = tk.StringVar() newWindow = tk.Toplevel(parent) newWindow.title("Configuration") newWindow.geometry("250x390") newWindow.resizable(False, False) newWindow.iconbitmap('icon.ico') tk.Label( newWindow, text="Here you can set your HFU credentials\nand configure defaults" ).pack() # create options frame options = ttk.Frame(newWindow) options.pack(padx=10, pady=10, fill='x', expand=True) def setConfig(event=0): timeoutNew = 15 if timeout.get(): timeoutNew = timeout.get() configValues = { 'myRoom': myRoom.get(), 'myUsername': myUsername.get(), 'myPassword': myPassword.get(), 'myName': myName.get(), 'bandWidth': bandWidth.get(), 'timeout': timeoutNew } print(configValues) configHandler.setConfig(configValues) newWindow.destroy() # room form roomForm = ttk.Label(options, text="Default Room:") roomForm.pack(fill='x', expand=True) roomForm = ttk.Entry(options, textvariable=myRoom) roomForm.pack(fill='x', expand=True) roomForm.focus() # username form userForm = ttk.Label(options, text="HFU Username:"******"HFU Password\n(Will be obfuscated and saved in config!):") passForm.pack(fill='x', expand=True) passForm = ttk.Entry(options, textvariable=myPassword, show='*') passForm.pack(fill='x', expand=True) # name form nameForm = ttk.Label(options, text="Name for Alfaview Session:") nameForm.pack(fill='x', expand=True) nameForm = ttk.Entry(options, textvariable=myName) nameForm.pack(fill='x', expand=True) # bandwidth form bandWidthForm = ttk.Label( options, text= "Bandwith option\nnormal / reduced / minimum\n(Leave blank for default 'normal'):" ) bandWidthForm.pack(fill='x', expand=True) bandWidthForm = ttk.Entry(options, textvariable=bandWidth) bandWidthForm.pack(fill='x', expand=True) # timeout form timeoutForm = ttk.Label(options, text="Timout (Leave blank for default of 15)") timeoutForm.pack(fill='x', expand=True) timeoutForm = ttk.Entry(options, textvariable=timeout) timeoutForm.pack(fill='x', expand=True) if configHandler.isConfig(): configData = configHandler.getConfig() roomForm.insert(0, configData['myRoom']) userForm.insert(0, configData['myUsername']) passForm.insert(0, configData['myPassword']) nameForm.insert(0, configData['myName']) bandWidthForm.insert(0, configData['bandWidth']) timeoutForm.insert(0, configData['timeout']) # set button set_button = ttk.Button(options, text="Apply Config", command=setConfig) set_button.pack(fill='x', expand=True, pady=10) # login with ENTER newWindow.bind('<Return>', setConfig)