From 6a7b483192b95abbdf761857417af32de9ac93ef Mon Sep 17 00:00:00 2001 From: Tom Collins Date: Sat, 21 Mar 2015 15:14:54 -0700 Subject: [PATCH 1/2] confirm that PRFlippers and PRBumpers exist before iterating through them --- procgame/game/game.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/procgame/game/game.py b/procgame/game/game.py index 95dc0f0..92358c4 100644 --- a/procgame/game/game.py +++ b/procgame/game/game.py @@ -418,7 +418,8 @@ def enable_flippers(self, enable): #return True """Enables or disables the flippers AND bumpers.""" - for flipper in self.config['PRFlippers']: + if self.config.has_key('PRFlippers'): + for flipper in self.config['PRFlippers']: self.logger.info("Programming flipper %s", flipper) main_coil = self.coils[flipper+'Main'] if self.coils.has_key(flipper+'Hold'): @@ -468,7 +469,8 @@ def enable_alphanumeric_flippers(self, enable): def enable_bumpers(self, enable): - for bumper in self.config['PRBumpers']: + if self.config.has_key('PRBumpers'): + for bumper in self.config['PRBumpers']: switch_num = self.switches[bumper].number coil = self.coils[bumper] From 583256a2e49df5ea74f48bfc3beba1f28ba3dcf9 Mon Sep 17 00:00:00 2001 From: Tom Collins Date: Sun, 29 Nov 2015 10:50:53 -0800 Subject: [PATCH 2/2] logger: don't generate a warning if there isn't a config.yaml in the current path --- procgame/config.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/procgame/config.py b/procgame/config.py index 1c0cdb2..efdcab9 100644 --- a/procgame/config.py +++ b/procgame/config.py @@ -33,14 +33,12 @@ def load(): curr_path = os.path.expanduser('./config.yaml') system_path = os.path.expanduser('~/.pyprocgame/config.yaml') if os.path.exists(curr_path): - path = curr_path + path = curr_path + elif os.path.exists(system_path): + path = system_path else: - logger.warning('pyprocgame configuration not found at %s. Checking %s.' % (curr_path, system_path)) - if os.path.exists(system_path): - path = system_path - else: - logger.warning('pyprocgame configuration not found at %s' % system_path) - return + logger.error('pyprocgame configuration not found at %s or %s' % (curr_path, system_path)) + return logger.info('pyprocgame configuration found at %s' % path) try: values = yaml.load(open(path, 'r'))