def main(self): kb = KBHit() # needed for windows to handle keyboard interrupt print('Hit ESC to exit') try: #time.sleep(1) #self.request_port_mapping() time.sleep(0.5) self.set_pin_mode(13, AsipClient.OUTPUT) time.sleep(0.5) self.set_pin_mode(2, AsipClient.INPUT_PULLUP) time.sleep(0.5) except Exception as e: sys.stdout.write( "Exception: caught {} in setting pin mode".format(e)) while True: if kb.kbhit(): c = kb.getch() if ord(c) == 27: # ESC kb.set_normal_term() break try: self.digital_write(13, 1) time.sleep(1.25) self.digital_write(13, 0) time.sleep(1.25) except Exception as e: sys.stdout.write( "Exception: caught {} in digital_write".format(e))
def run(self): """Run the CPU.""" self._running = True old_time = time() kb = KBHit() while self._running: # trigger timer interrupt every second (approx) new_time = time() if new_time - old_time > 1: self.interrupt(TIMER_INTERRUPT) old_time = new_time # trigger keyboard interrupt on keypress if kb.kbhit(): c = kb.getch() if ord(c[0]) == 27: # ESC self._running = False break self.ram_write(KEY_BUFFER, ord(c[0])) self.interrupt(KEYBOARD_INTERRUPT) self.check_interrupts() # process instruction at program counter self.IR = self.ram_read(self.PC) if self.IR & ALU_MASK: self.alu(ALU[self.IR], self.OP_A, self.OP_B) else: OPCODES[self.IR](self) # adjust program counter if necessary if not self.IR & 0b10000: self.PC += (1 + (self.IR >> 6)) kb.set_normal_term()
def main(self): if os.name == 'nt': kb = KBHit() # needed for windows to handle keyboard interrupt sys.stdout.write('Hit ESC to exit\n') try: time.sleep(0.5) self.asip.set_pin_mode(13, self.asip.OUTPUT) time.sleep(0.5) except Exception as e: sys.stdout.write( "Exception caught while setting pin mode: {}\n".format(e)) self.thread_killer() sys.exit(1) while True: if os.name == 'nt': if kb.kbhit(): c = kb.getch() if ord(c) == 27: # ESC kb.set_normal_term() break try: self.asip.digital_write(13, self.asip.HIGH) time.sleep(1.25) self.asip.digital_write(13, self.asip.LOW) time.sleep(1.25) except (KeyboardInterrupt, Exception) as e: sys.stdout.write( "Caught exception in main loop: {}\n".format(e)) self.thread_killer() sys.exit()
def __init__(self): coloroma_init(autoreset=False) self.__score = 0 self.__last_level_score = 0 self.__ticks = 0 self.__level_ticks = 0 self.__level = 1 self.__lives_used = 0 self.__paddle = Paddle() self.__bricks_broken = 0 self.__balls = [Ball(paddle=self.__paddle)] self.__cnt_active_balls = 0 self.__cnt_active_bricks = 100 self.__game_status = GAME_END self.__powerups = [] self.__kb = KBHit() self.__explode_ids = [x for x in range(8, 14)] self.__explode_nbrs_ids = [7, 14, 28, 29, 30, 31, 32, 33] self.__brick_structure_y_fall = 0 self.__fall_bricks = 0 self.__bullets = [] self.__ufo = Ufo() self.__ufo_bombs = [] self.__ufo_bricks = [] self.__map_position_to_bricks = [] clear_terminal_screen() self._draw_bricks() self._loop()
def waitForInput(running_flag, threads): kb = KBHit() while True: if kb.kbhit(): c = kb.getch() if ord(c) == 27: # ESC break e.sleep(0.1) kb.set_normal_term() socket.stop()
def __init__(self): self.cross_platform = CrossplatformFunctions() self.cross_platform.resize_screen() self.keyboard = KBHit() self.space = DeepSpace() self.blue_racer = BlueRacer(39, 60, '#', self.space) self.loop = asyncio.get_event_loop() self.loop.run_until_complete(self.start())
def game_round(self, position): # set round speed and guess speed = 1. / (1 + position) guess = -1 stop = False # turn on GPIO pins for i in pinList[position:]: GPIO.setup(i, GPIO.OUT) GPIO.output(i, GPIO.HIGH) # turn on correct guesses for i in pinList[0:position]: GPIO.output(i, GPIO.LOW) #start kbhit kb = KBHit() # start loop while True: for i in pinList[position:]: GPIO.output(i, GPIO.LOW) # check keypress if kb.kbhit(): c = kb.getch() if ord(c) != 27: stop = True guess = pinList.index(i) - 1 break time.sleep(speed) # check keypress if stop: break pinList.reverse() for i in pinList[0:len(pinList) - position]: GPIO.output(i, GPIO.HIGH) if kb.kbhit(): c = kb.getch() if ord(c) != 27: stop = True guess = len(pinList) - (pinList.index(i) + 1) pinList.reverse() time.sleep(speed) if stop: break pinList.reverse() # check results print guess print position return (guess == position)
def __init__(self, keys: str, mode: str = 'hotkey', window=None): self.mode = mode self.window = window self.shot_job = None self.battle_job = self.visit_room_job = self.cork_shop_job = self.monitor_job = Job( ) self.kb = KBHit() self.positions = [Position(_id) for _id in range(1, 10)] self.keys = [ f'z+{i}' for i in (list(range(1, 10)) if mode == 'hotkey' else []) + list(keys) ] self.add_hotkey()
def __init__(self): self._moveit_wrapper = MoveitWrapper() self._moveit_wrapper.init_moveit_commander() rospy.init_node('grasp_player') self._moveit_wrapper.setup() self._kin = boris_kinematics(root_link="left_arm_base_link") self._boris = BorisRobot(moveit_wrapper=self._moveit_wrapper) self._scene = self._moveit_wrapper.scene() self._planning_frame = self._moveit_wrapper.robot().get_planning_frame( ) self._tf_buffer = tf2_ros.Buffer() self._listener = tf2_ros.TransformListener(self._tf_buffer) self._br = tf.TransformBroadcaster() self._scene.remove_world_object("table") self.add_table() self._solution = None self._grasp_waypoints = [] self._pre_grasp_plan = None self._pre_grasp_plan2 = None self._grasp_arm_joint_path = None self._grasp_hand_joint_path = None self._post_grasp_plan = None self._grasp_service_client = GraspServiceClient() self._boris.set_control_mode(mode="joint_impedance", limb_name="left_arm") self._arm_traj_generator = MinJerkTrajHelper() self._hand_traj_generator = MinJerkTrajHelper() self._pre_grasp_traj_generator = MinJerkTrajHelper() self._post_grasp_traj_generator = MinJerkTrajHelper() self._scan_waypoints = np.load( "/home/earruda/Projects/boris_ws/src/boris-robot/boris_tools/scripts/scan_waypoints2.npy" ) self._kbhit = KBHit()
def main(): # Import the utilities helper module import argparse sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..")) import utilities # Parse arguments parser = argparse.ArgumentParser() parser.add_argument("--proportional_gain", type=float, help="proportional gain used in control loop", default=2.0) args = utilities.parseConnectionArguments(parser) # Create connection to the device and get the router with utilities.DeviceConnection.createTcpConnection(args) as router: with utilities.DeviceConnection.createUdpConnection( args) as router_real_time: kbhit = KBHit() example = GripperLowLevelExample(router, router_real_time, args.proportional_gain) print( "Press keys '0' to '9' to change gripper position. Press ESC to quit." ) while True: if kbhit.kbhit(): ch = kbhit.getch() if ord(ch) == 27: break elif ch >= '0' and ch <= '9': target_position = (float(ch) + 1) * 10.0 print("Going to position %i" % (target_position)) example.Goto(target_position) print("Target reached") time.sleep(0.2) example.Cleanup()
def console_run(program_file: str, autorun_file: Optional[str] = None, init_str: str = ''): vm = Virtual8080() vm.io = AltairWithTerminal() with open(program_file, 'rb') as pf: program = pf.read() vm.load(program) if autorun_file is not None: init_buffer = init_str with open(autorun_file, 'r') as af: for line in af.readlines(): init_buffer += line.replace('\n', '\r') vm.io.input_buffer = init_buffer.encode(encoding='ascii') kb = KBHit() try: vm.halted = False while not vm.halted: ch = vm.io.output_char if ch != -1 and ch != 13: print(bytes([ch]).decode(encoding='ascii'), end='', flush=True) vm.io.output_char = -1 if kb.kbhit(): ch = ord(kb.getch()) if ch == 10: vm.io.input_buffer += bytes([13, 0]) elif ch == 27: # Break on ESC vm.io.input_buffer += bytes([3]) else: vm.io.input_buffer += bytes([ch]) vm.step() finally: kb.set_normal_term()
import colorama as cl import numpy as np from pawn import Pawn, Bullet, Character from gamerule import Gamerule from obstacles import Firebeam, Magnet, Boss_Enemy, Solid_Objects from kbhit import KBHit from powerups import Speed_Boost from collections import deque from coins import Coin from screen import Screen cl.init() BG_BLUE = cl.Back.BLUE BG_GREEN = cl.Back.GREEN _KBHIT = KBHit() ObjNumber = 3 TERM_SCREEN = Screen() SCREEN_DIM = TERM_SCREEN.get_dim() GROUND_SIZE = [SCREEN_DIM[0] - int(SCREEN_DIM[0] * 0.1), 0] GAMERULE = Gamerule(0.3) speed_boost = 0 game_score = 0 object_score = 0 pawns = {
if __name__ == "__main__": ########################################################## " Visualization by using rviz" import rospy, tf from point_cloud_publisher import PointCloudPublisher # roscore = subprocess.Popen('roscore', shell=True) # atexit.register(roscore.kill) # time.sleep(2) # rviz = subprocess.Popen('rviz', shell=True) # atexit.register(rviz.kill) # time.sleep(2) keyboard = KBHit() print("Initializing node... ") rospy.init_node('bullet_point_cloud') pcl_node = PointCloudPublisher() #pcl_node.run_thread() br = tf.TransformBroadcaster() ########################################################## simulation = BulletSimulation(0.01) simulation.reset() image_getter = ImageGetter(simulation.get_id()) image_getter.getImage()
def main(): # Decorative purpose. init() # Nope, this is not the real otog.cf password XD. mydb = mysql.connector.connect( host="localhost", user="******", passwd="00000000", # Original for otog.cf was : # passwd='0000', database="OTOG", ) myCursor = mydb.cursor(buffered=True) # for keybord interupt. print(ogogi + "Grader started. Waiting for submission...") kb = KBHit() while True: # Looking for keyboard interupt. if kb.kbhit(): if kb.getch() == ":": # Do functions. print(ogogi + "Keyboard interupted. Entering command mode.") kb.set_normal_term() # Command mode while True: cmd, args = cmdMode.run() # Shutdown signal if cmd == abb.INCMD["SHUTDOWN"]: # Good-bye message print(ogogi + "Bye") exit(0) elif cmd == abb.INCMD["RELOAD"]: # Reload modules in args for e in args: if e == "grader": print( abb.error + "'grader' itself cannot be reloaded. Please restart the program manually." ) try: importlib.reload(importlib.import_module(e)) except: print(abb.error + "'" + e + "' cannot be reloaded.") elif cmd == abb.INCMD["EXIT"]: break kb.set_kbhit_term() print(ogogi + "Command mode exited. Continue waiting for submission.") myCursor.execute("SELECT * FROM Result WHERE status = 0 ORDER BY time") submission = myCursor.fetchone() if submission != None: print(abb.bold + Fore.GREEN + "\t--> recieved.\n" + Style.RESET_ALL) print( str(datetime.datetime.now().strftime("[ %d/%m/%y %H:%M:%S ]")) + " -----------------------------" ) myCursor.execute( "SELECT * FROM Problem WHERE id_Prob = " + str(submission[3]) ) probInfo = myCursor.fetchone() # Submit result sql = "UPDATE Result SET result = %s, score = %s, timeuse = %s, status = 1, errmsg = %s WHERE idResult = %s" val = onRecieved(submission, probInfo, mydb) myCursor.execute(sql, val) print("---------------------------------------------------") print("\n" + ogogi + "Finished grading session. Waiting for the next one.") mydb.commit() time.sleep(config.gradingInterval)
if s == 'n': register( id='FrozenLake-v3', entry_point='gym.envs.toy_text:FrozenLakeEnv', kwargs={'map_name' : '4x4', 'is_slippery': False} ) env = gym.make('FrozenLake-v3') # is_slippery False break elif s == 'y': env = gym.make('FrozenLake-v0') # is_slippery True break env.reset() env.render() # Show the initial board key = KBHit() while True: action = key.getarrow() if action not in [0, 1, 2, 3]: print("Game aborted!") break 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
def main(): def setup_logging(): print("setup_logging") logging.basicConfig( format= "%(asctime)s [%(threadName)-12.12s] [%(levelname)-5.5s] %(message)s", handlers=[ logging.FileHandler("./zero_one.log"), logging.StreamHandler(sys.stdout) ], level=logging.INFO) def destroy_logging(): print("destroy_logging") # Start the main program here print('Testing UI ...') setup_logging() st = 0 tick = 0 try: app_ui = ui.get_ui_instance() command = None app_ui.led_flash(ui.Led.LED_RED, 0.1) this_directory = os.path.dirname(os.path.realpath(__file__)) binary_path = os.path.join(this_directory, "fadecandy/bin/fcserver-osx") config_path = os.path.join(this_directory, "fadecandy/bin/test-rig_config.json") fcserver = display.FCServer(binary_path, config_path) print(fcserver) d1 = display.Display() print(d1) while command != ui.Commands.Quit: print('. ') time.sleep(0.1) command = app_ui.get_command() button = app_ui.get_button() if button != None: if button == Button.BUTTON_1: print('BUTTON_1') print('fcserver setup', fcserver.setup()) elif button == Button.BUTTON_2: print('BUTTON_2') fcserver.test() elif button == Button.BUTTON_3: print('BUTTON_3') raise ZeroOneException('Critical failure - user bored', 4) # if _ui.test_button(Button.BUTTON_3): # _ui.led_on(ui.Led.LED_AMBER) # else: # _ui.led_off(ui.Led.LED_AMBER) # tick = tick+1 # if tick > 20: # print('Queue:', _ui.get_button()) # tick = 0 if command == ui.Commands.Test: print('TEST') if st == 0: pass if st == 1: pass print(app_ui) st = st + 1 if st == 2: st = 0 app_ui.shutdown() # Flush the keyboard here # TODO : is this even needed anymore kb = KBHit() kb.flush() except KeyboardInterrupt as ex: print("Aborted") except ZeroOneException as ex: print("\n>>> EXCEPTION : {} <<<\n".format(ex.message)) logging.error(ex.message, exc_info=True) app_ui.display_exception(ex.error_code) finally: app_ui.shutdown() fcserver.shutdown() destroy_logging() print('Done!')
def run(self): kb = KBHit() selectedData = [] dataToAverage = [] print('Hit ESC to exit') while True: if kb.kbhit(): c = kb.getch() if ord(c) == 27: # ESC kb.set_normal_term() print "Quitting!" os._exit(0) now = time.time() due = now - self.parent.offset search_from = self.parent.index - 1 if search_from == -1: search_from = self.parent.buffer_size - 1 timestamp = 0 nextTimestamp = 0 self.waitForNewData = 0.5 self.parent.mutex.acquire() lastjvalue = 0 dataArray = [] for theid in range(self.parent.channel_count): data = self.parent.outbuffers[int(theid)][self.parent.index] for i in range(search_from, search_from - self.parent.buffer_size, -1): j = i if i >= 0 else i + self.parent.buffer_size timestamp = self.parent.timestamp_buffer[j] if timestamp is not None and timestamp <= due: data = self.parent.outbuffers[int(theid)][j] lastjvalue = j if (j < self.parent.buffer_size - 2): nextTimestamp = self.parent.timestamp_buffer[j + 1] else: nextTimestamp = self.parent.timestamp_buffer[0] break if data is not None: dataArray.append(data) #print "data array: ", dataArray for f in config.streams: stream = f['stream'] if len(dataArray) > stream: #print "stream = ", stream, dataArray[stream] if 'scale' in f: dataArray[stream] = self.format.scale( dataArray[stream], f['scale']) if 'type' in f and f['type'] == int: #msgString += str(int(dataArray[stream])) selectedData.append(int(dataArray[stream])) else: #msgString += str(dataArray[stream]) selectedData.append(dataArray[stream]) if len(selectedData) == len(config.streams): self.sendMessage(selectedData) selectedData = [] if timestamp is not None and nextTimestamp is not None: waitTime = nextTimestamp - timestamp if waitTime > 0: time.sleep(waitTime) else: print "timing out waiting for new data - time < 0" time.sleep(self.waitForNewData) else: print "timing out waiting for new data - time or nextTime is None" time.sleep(self.waitForNewData) self.parent.mutex.release()
def main(): random.seed(time.time()) # Initialise colorama init() # Clear screen print(chr(27) + '[2j') print('\033c') print('\x1bc') # Get terminal size (ncols, nlines) = shutil.get_terminal_size() # Initialise screen screen = Window(0, 1, ncols, nlines - 1, f"{config.bkgd} ") # Initialise keyboard kb = KBHit() # Create and draw the paddle paddle = Paddle(((ncols - 1) - config.paddle["dim"][0]) // 2, nlines - 4, screen) last_update = 0 start = time.time() score = 0 lives = 3 curr_level = 1 # List to store shooters shooters = [None, None] while curr_level <= 3: # Create and draw bricks boss = None if curr_level == 1: bricks, powerups = levels.level_one(screen) elif curr_level == 2: bricks, powerups = levels.level_two(screen) elif curr_level == 3: bricks, powerups = levels.level_three(screen) boss = Boss(ncols // 2, 5, screen) else: sys.exit() if lives == 0: break while lives: # Reset paddle location paddle.x = ((ncols - 1) - config.paddle["dim"][0]) // 2 paddle.powerup = None # Create and draw the ball balls = [ Ball(random.randrange(paddle.x, paddle.x + paddle.width), nlines - 5, list(config.ball["speed"]), 1, screen) ] # List to store bullets bullets = [] shoot_paddle = [0] # List to store bombs bombs = [] tick = 0 while len(balls): if (time.time() - last_update > config.tick_interval): tick += 1 for i in range(ncols): print(f"{Cursor.POS(1+i, 1)}{Back.BLACK} ", end='') statusline = f"{Cursor.POS(1, 1)}Level: {curr_level} " statusline += f"Score: {score} " statusline += f"Time: {int(time.time() - start)} " statusline += f"Lives: {lives} " statusline += f"Shoot Paddle: {int(shoot_paddle[0] * config.tick_interval)} " if boss: statusline += "Boss Health: [" for i in range(0, boss.health, 10): statusline += "•" for i in range(0, 100 - boss.health, 10): statusline += " " statusline += "]" print(statusline, end='') last_update = time.time() change_level = False direction = 0 if kb.kbhit(): c = kb.getch() if ord(c) == 27: sys.exit(0) if c == 'a': direction = -1 elif c == 'd': direction = 1 elif c == ' ': # Activate balls for ball in balls: ball.paused = False elif c == '1' or c == '2' or c == '3': curr_level = int(c) if curr_level != 3 else 4 change_level = True break # Create new bullets if needed shoot_paddle[0] = max(0, shoot_paddle[0] - 1) if shoot_paddle[0] and shoot_paddle[0] % config.bullet[ "rate"] == 0: bullets.append( Bullet(max(paddle.x, 0), paddle.y, config.bullet["speed"], screen)) bullets.append( Bullet( min(paddle.x + paddle.width, screen.get_screen_size()[1] - 1), paddle.y, config.bullet["speed"], screen)) # Create bomb if needed if boss and tick % config.bomb["rate"] == 0: bombs.append( Bomb(boss.x + 5, boss.y + 3, config.bomb["speed"], screen)) # Create shooters if needed if shoot_paddle[0] and not shooters[0]: shooters[0] = Object(paddle.x, paddle.y - 1, 1, 1, config.paddle["color"], screen) if shoot_paddle[0] and not shooters[1]: shooters[1] = Object(paddle.x + paddle.width - 1, paddle.y - 1, 1, 1, config.paddle["color"], screen) # Create brick layer on boss level if health is 50 if boss and boss.health == 80 and not boss.done[0]: bricks.append([]) brick_count = screen.get_screen_size()[1] // \ (config.brick["dim"][0] + 5) for i in range(brick_count): bricks[1].append( Brick(i * (config.brick["dim"][0] + 5), 9, 1, screen)) boss.done[0] = True # Create brick layer on boss level if health is 20 if boss and boss.health == 20 and not boss.done[1]: brick_count = screen.get_screen_size()[1] // \ (config.brick["dim"][0] + 5) bricks.append([]) for i in range(brick_count): bricks[2].append( Brick(i * (config.brick["dim"][0] + 5), 13, 1, screen)) boss.done[1] = True # Clear screen screen.clear() # Move the paddle paddle.move(direction, balls) # Move the powerups to_delete = [] for powerup in powerups: object = None if powerup.type == "paddle": object = paddle elif powerup.type == "ball": object = balls else: object = shoot_paddle if not powerup.move(paddle, object, tick): to_delete.append(powerup) powerups = [ powerup for powerup in powerups if powerup not in to_delete ] # Move the ball to_delete = [] for ball in balls: delete, d_score = ball.move(bricks, paddle, boss) if not delete: to_delete.append(ball) score += d_score balls = [ball for ball in balls if ball not in to_delete] # Delete shooters if powerup is over if shoot_paddle[0] == 0: shooters = [None, None] # Move the bullets to_delete = [] for bullet in bullets: delete, d_score = bullet.move(bricks) if not delete: to_delete.append(bullet) score += d_score bullets = [ bullet for bullet in bullets if bullet not in to_delete ] # Move the bombs to_delete = [] lose_life = False for bomb in bombs: delete, lose_life = bomb.move(paddle) if not delete: to_delete.append(bomb) if lose_life: break if lose_life: break bombs = [bomb for bomb in bombs if bomb not in to_delete] # Move the boss if boss: boss.move(paddle.x + paddle.width // 2) # Move the shooter if shooters[0]: shooters[0].x = paddle.x if shooters[1]: shooters[1].x = paddle.x + paddle.width - 1 # Update bricks for layer in bricks: for brick in layer: brick.rainbow(tick) # Don't move bricks on boss level if curr_level < 3: brick.move(tick) if brick.y + brick.height > paddle.y: sys.exit() brick.update() # Update paddle paddle.update() # Update shooters for shooter in shooters: if shooter: shooter.update() # Update powerups for powerup in powerups: powerup.update() # Update ball for ball in balls: ball.update() # Update bullets for bullet in bullets: bullet.update() # Update bombs for bomb in bombs: bomb.update() # Boss update if boss: boss.update() screen.draw() # Check if all breackable bricks are broken on non boss levels if curr_level < 3: change_level = True for layer in bricks: for brick in layer: if brick._strength != 4: change_level = False break if not change_level: break else: if boss.health <= 0: change_level = True if change_level: curr_level += 1 break if change_level: break lives -= 1
from spectrogram import full_bpm_to_data, HEART_AV_ROOT, NormalizedSpectrograms, NormalizedSubjectSplitSpectrograms, getVideoSpectrograms from get_heartrates import get_interesting_heartrates from keras.callbacks import EarlyStopping from kbhit import KBHit import numpy as np import code import random import learnLib from numpy.lib.stride_tricks import as_strided as ast kb = KBHit() def repeat_n_times(a, n): return np.repeat(np.reshape(a, (-1, 1, 1)), n, axis=1) #these two functions from: http://www.johnvinyard.com/blog/?p=268 def norm_shape(shape): ''' Normalize numpy array shapes so they're always expressed as a tuple, even for one-dimensional shapes. Parameters shape - an int, or a tuple of ints Returns a shape tuple ''' try:
def main(argv): print('ZeroOneController running ...') # Set up the logging setup_logging() logging.info('ZeroOneController running ...') # Get the UI instance app_ui = ui.get_ui_instance() command = None app_ui.led_flash(ui.Led.LED_AMBER, 0.2) # Read the config file config_file = './config.ini' try: opts, args = getopt.getopt(argv, "hc:", ["config="]) except getopt.GetoptError: print('ZeroOneController.py --config <configfile>') raise ZeroOneException() for opt, arg in opts: if opt in ('-c', '--config'): config_file = arg this_directory = os.path.dirname(os.path.realpath(__file__)) # Test the config file exists print('Using config from', config_file) # TODO : This should check absolute path # os.path.isabs() if os.path.exists(config_file) == False: raise ZeroOneException( "Config file {0} does not exist".format(config_file)) else: # TODO : This should catch the json.decoder.JSONDecodeError exception with open(config_file) as cf: data = json.load(cf) config_fadecandy = data['Fadecandy'] config_emulator = data['DisplayEmulator'] config_options = data['Options'] ide_mode = False if 'Ide_mode' in config_options: if config_options['Ide_mode'] != 0: ide_mode = True this_directory = os.path.dirname(os.path.realpath(__file__)) # Now create a display object app_display = display.Display(config_fadecandy, config_emulator) app_display.setup() app_effects = effect.EffectController() image_cycler = effect.ImageCycler(config_options['ImagePath']) try: if ide_mode == True: image_filename = '/Users/colind/Documents/Projects/ZeroOne/ZeroOne/Controller/images/RGBW.png' print(image_filename) zo_image = ZO_Image() zo_image.load_from_file(image_filename) print(zo_image) # zo_image.image.show() app_display.update_display(zo_image.test_image()) else: while command != ui.Commands.Quit: print('. ') time.sleep(0.05) # Check if we're running in the IDE mode or not if ide_mode == False: command = app_ui.get_command() button = app_ui.get_button() else: command, button = get_ide_mode_command_and_button() # Process the incoming commands if button != None: if button == Button.BUTTON_1: print('BUTTON_1') app_display.clear_display() elif button == Button.BUTTON_2: print('BUTTON_2') image_file = image_cycler.get_next_file() print('Processing ', image_file) img = ZO_Image() img.load_from_file(image_file) app_display.update_display(img.image) elif button == Button.BUTTON_3: print('BUTTON_3') try: kb = KBHit() kb.flush() except: pass except KeyboardInterrupt: print('Exiting ...') except ZeroOneException as ex: print("\n>>> EXCEPTION : {} <<<\n".format(ex.message)) logging.error(ex.message, exc_info=True) app_ui.display_exception(ex.error_code) finally: app_ui.shutdown() app_display.shutdown() logging.info('Done!') destroy_logging() print('Done!')