print("Hint: If your keyboard can't be set to bootloader mode automatically, plug it in while pressing the bootloader key to do so manually.")
print(" You can find more infos about this here: https://github.com/qmk/qmk_firmware/tree/master/keyboards/ps2avrGB#setting-the-board-to-bootloader-mode")
attempts=12# 60 seconds
found=False
forattemptinrange(1,attempts+1):
print("Searching for keyboard in bootloader mode (%i/%i) ... "%(attempt,attempts),end='')
ifcheckForKeyboardInBootloaderMode():
print('Found',end='\n\n')
flashKeyboard(sys.argv[1])
found=True
break
else:
print('Nothing.',end='')
ifattempt!=attempts:# no need to wait on the last attempt
print(' Sleeping 5 seconds.',end='')
time.sleep(5)
# print a newline
print()
ifnotfound:
print("Couldn't find a flashable keyboard. Aborting.")