Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def run(self):
while True:
self.draw_main_page()
if self.test_mode:
self.mainwin.close()
logging.info("Test finished. Bye bye")
break
pressed_key = readchar.readkey()
if pressed_key not in COMMANDS:
logging.warn("key %s can not be recognized" %
repr(pressed_key))
continue
# else
cmd = COMMANDS[pressed_key]
if cmd == 'ABORT':
self.mainwin.close()
raise KeyboardInterrupt
elif cmd == 'QUIT':
self.mainwin.close()
logging.info("Bye bye")
break
if args.reset_type == 0:
dev_serial.rts = 0
dev_serial.dtr = 1
time.sleep(0.5)
# Let go of the reset.
dev_serial.dtr = 0
# Start the serial reader thread.
serial_reader_thread = threading.Thread(target=serial_reader_main,
args=(dev_serial, ))
serial_reader_thread.setDaemon(True)
serial_reader_thread.start()
# Read user input.
while True:
key = readchar.readkey()
# Break on CTRL-C.
if key == readchar.key.CTRL_C:
break
if key == readchar.key.ENTER:
dev_serial.write('\r\n')
else:
dev_serial.write(key)
print()
call(['clear'])
puts(colored.cyan('Available commands (press any key to exit)'))
puts(' enter - Connect to your selection')
puts(' crtl+c | q - Quit sshmenu')
puts(' k (up) - Move your selection up')
puts(' j (down) - Move your selection down')
puts(' h - Show help menu')
puts(' c - Create new connection')
puts(' d - Delete connection')
puts(' e - Edit connection')
puts(' + (plus) - Move connection up')
puts(' - (minus) - Move connection down')
# Hang until we get a keypress
readchar.readkey()
def play(self, test_mode=True, shuffle=False):
self.test_mode = test_mode
self.shuffle = shuffle
self.start()
while True:
pressed_key = readchar.readkey()
if pressed_key not in COMMANDS:
logging.warn("key %s can not be recognized" %
repr(pressed_key))
continue
# else
cmd = COMMANDS[pressed_key]
if cmd == 'ABORT':
self.abort()
elif cmd == 'QUIT':
logging.info("quit current play")
break
elif cmd == 'PREVIOUS':
self.previous()
#Only for Python 2.7
#Very Important!!!!!!!!!
import readchar
while True:
key = readchar.readkey()
if key == "w":
print("up")
elif key == "s":
print("down")
elif key == "a":
print("left")
elif key == "d":
print("right")
elif key == "z":
print("exiting")
break
"""
is_yes = default_is_yes
is_selected = enter_empty_confirms
current_message = ''
yn_prompt = f' ({yes_text[0]}/{no_text[0]}) ' if char_prompt else ': '
print()
while True:
yes = is_yes and is_selected
no = not is_yes and is_selected
print('\033[K'
f'{selected_prefix if yes else deselected_prefix}{yes_text}')
print('\033[K'
f'{selected_prefix if no else deselected_prefix}{no_text}')
print('\033[3A\r\033[K'
f'{question}{yn_prompt}{current_message}', end='', flush=True)
keypress = readchar.readkey()
if keypress in DefaultKeys.down or keypress in DefaultKeys.up:
is_yes = not is_yes
is_selected = True
current_message = yes_text if is_yes else no_text
elif keypress in DefaultKeys.delete:
if current_message:
current_message = current_message[:-1]
elif keypress in DefaultKeys.interrupt:
raise KeyboardInterrupt
elif keypress in DefaultKeys.confirm:
if is_selected:
break
elif keypress in '\t':
if is_selected:
current_message = yes_text if is_yes else no_text
else:
'\x1b[B' : DOWN,
'\x1b[C' : RIGHT,
'\x1b[D' : LEFT
}
register(
id='FrozenLake-v3',
entry_point='gym.envs.toy_text:FrozenLakeEnv',
kwargs={'map_name' : '4x4', 'is_slippery': False}
)
env = gym.make('FrozenLake-v3')
env.render()
while True:
key = readchar.readkey()
if key not in arrow_keys.keys():
print("Game aborted!")
break
action = arrow_keys[key]
state, reward, done, info = env.step(action)
env.render()
print("State: ", state, "Action: ", action, "Reward: ", reward, "Info: ", info)
if done:
print("Finished with reward", reward)
break
print("-To EXIT the program, type... 5")
choice=raw_input("Type now.")
key="t"
if choice=="1":
print(" ^ ")
print(" (O)------W------(0) ")
print(" [----------------] ")
print("<-A [----------------] D ->")
print(" [----------------] ")
print(" (0)------S------(0) ")
print(" ")
print("Hold WASD to move. C stops. Z goes back to main menu")
key=readchar.readkey() #choose "hold down key" steering mode
elif choice=="2":
print(" ^ ")
print(" (O)------W------(0) ")
print(" [----------------] ")
print("<-A [----------------] D ->")
print(" [----------------] ")
print(" (0)------S------(0) ")
print(" ")
print("Control with WASD. Hit enter to go. C stops. Z goes back to main menu")
key=raw_input("Enter command or press z and it return to exit") #choose hit "enter" steering mode
elif choice=="3":
auto()
elif choice=="4":