def getUrlPrompt(sname=""): ''' Copy a service's URL to the clipboard ''' if sname == "": inc = 0 sname = getUserInput("Enter service name: ") while (not checkIfServiceExists(sname)) and inc < 2: print("Service not found.") sname = getUserInput("Enter service name: ") if inc >= 2: # three strikes; you're out print("Returning to menu") showMenu() else: if not checkIfServiceExists(sname): print("Service not found.") return False clipboard(getServiceData(sname, 'serviceUrl'), True, True) return True
def getUserNameOffline(sname=""): ''' Similar to menu.py's get username function, but pulls from local JSON file instead ''' sname = sname if sname else getUserInput("Enter service name: ") inc = 0 while (not getServiceDataOffline(sname)) and inc < 2: print("Service not found.") sname = getUserInput("Enter service name: ") inc += 1 if inc >= 2: # three strikes; you're out print("Returning to menu") handleOfflineMenu() username = getServiceDataOffline(sname)['serviceUserName'] clipboard(username, False, True) return True