def update_password_and_reconnect(hostname): """ Prompts the user to update their password and reconnect to the target device :param hostname: Hostname of the device to connect to. """ if yesno('Authentication failed, would you like to update your password?', default=True): from trigger import tacacsrc tacacsrc.update_credentials(hostname) if yesno('\nReconnect to %s?' % hostname, default=True): # Replaces the current process w/ same pid os.execl(sys.executable, sys.executable, *sys.argv)
def update_password_and_reconnect(hostname): """ Prompts the user to update their password and reconnect to the target device :param hostname: Hostname of the device to connect to. """ if yesno('Authentication failed, would you like to update your password?', default=True): from trigger import tacacsrc tacacsrc.update_credentials(hostname) if yesno('\nReconnect to %s?' % hostname, default=True): # Replaces the current process w/ same pid args = [sys.argv[0]] for arg in ('-o', '--oob'): if arg in sys.argv: idx = sys.argv.index(arg) args.append(sys.argv[idx]) break args.append(hostname) os.execl(sys.executable, sys.executable, *args)