Skip to content

Commit

Permalink
Only catch things that inherit from Exception. Try to prevent Keyboar…
Browse files Browse the repository at this point in the history
…dError from being swallowed. (#1270)
  • Loading branch information
cwild authored and fredrik-hellmangroup committed Jul 27, 2016
1 parent 01de69f commit f0a77f9
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 11 deletions.
7 changes: 3 additions & 4 deletions pokemongo_bot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ def current_inventory(self):

if item_id in items_stock:
items_stock[item_id] = item_count
except:
except Exception:
continue
return items_stock

Expand Down Expand Up @@ -433,7 +433,7 @@ def _set_starting_position(self):
logger.log('GeoPosition: {}'.format(self.position))
logger.log('')
has_position = True
except:
except Exception:
logger.log('[x] The location given in the config could not be parsed. Checking for a cached location.')
pass

Expand Down Expand Up @@ -461,12 +461,11 @@ def _set_starting_position(self):

has_position = True
return
except:
except Exception:
if(has_position == False):
sys.exit(
"No cached Location. Please specify initial location.")
logger.log('[x] Parsing cached location failed, try to use the initial location...')
pass

def _get_pos_by_name(self, location_name):
# Check if the given location is already a coordinate.
Expand Down
6 changes: 3 additions & 3 deletions pokemongo_bot/cell_workers/evolve_all_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def work(self):
for pokemon in evolve_list:
try:
self._execute_pokemon_evolve(pokemon, cache)
except:
except Exception:
pass
id_list2 = self.count_pokemon_inventory()
release_cand_list_ids = list(Set(id_list2) - Set(id_list1))
Expand Down Expand Up @@ -133,7 +133,7 @@ def _sort_by_cp_iv(self, inventory_items):
pokemons1.append(v)
else:
pokemons2.append(v)
except:
except Exception:
pass

## Sort larger CP pokemons by IV, tie breaking by CP
Expand Down Expand Up @@ -285,7 +285,7 @@ def _compute_iv(self, pokemon):
for individual_stat in iv_stats:
try:
total_IV += pokemon[individual_stat]
except:
except Exception:
pokemon[individual_stat] = 0
continue
pokemon_potential = round((total_IV / 45.0), 2)
Expand Down
2 changes: 1 addition & 1 deletion pokemongo_bot/cell_workers/initial_transfer_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def get_pokemon_potential(self, pokemon_data):
for individual_stat in iv_stats:
try:
total_iv += pokemon_data[individual_stat]
except:
except Exception:
continue
return round((total_iv / 45.0), 2)

Expand Down
4 changes: 2 additions & 2 deletions pokemongo_bot/cell_workers/pokemon_catch_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def work(self):
for individual_stat in iv_stats:
try:
total_IV += pokemon['pokemon_data'][individual_stat]
except:
except Exception:
pokemon['pokemon_data'][individual_stat] = 0
continue

Expand Down Expand Up @@ -404,4 +404,4 @@ def create_encounter_api_call(self):
self.api.disk_encounter(encounter_id=encounter_id, fort_id=fort_id,
player_latitude=player_latitude, player_longitude=player_longitude)

return self.api.call()
return self.api.call()
2 changes: 1 addition & 1 deletion pokemongo_bot/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
lcd = lcd.lcd()
# Change this to your i2c address
lcd.set_addr(0x23)
except:
except Exception:
lcd = False

def log(string, color = 'white'):
Expand Down

0 comments on commit f0a77f9

Please sign in to comment.