From 5f0781c831f957aaeca3cd934123b85d8d10c8ea Mon Sep 17 00:00:00 2001 From: surfaace Date: Thu, 28 Jul 2016 11:02:58 +0200 Subject: [PATCH 1/2] fixed transfer worker api crash try catch exception to prevent bot from crashing --- pokemongo_bot/cell_workers/pokemon_transfer_worker.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/pokemongo_bot/cell_workers/pokemon_transfer_worker.py b/pokemongo_bot/cell_workers/pokemon_transfer_worker.py index fd30f3bd2f..771acf665a 100644 --- a/pokemongo_bot/cell_workers/pokemon_transfer_worker.py +++ b/pokemongo_bot/cell_workers/pokemon_transfer_worker.py @@ -37,10 +37,13 @@ def work(self): def _release_pokemon_get_groups(self): pokemon_groups = {} - self.api.get_player().get_inventory() - inventory_req = self.api.call() - inventory_dict = inventory_req['responses']['GET_INVENTORY'][ - 'inventory_delta']['inventory_items'] + try: + self.api.get_player().get_inventory() + inventory_req = self.api.call() + inventory_dict = inventory_req['responses']['GET_INVENTORY'][ + 'inventory_delta']['inventory_items'] + except KeyError: + return pokemon_groups user_web_inventory = 'web/inventory-%s.json' % (self.config.username) with open(user_web_inventory, 'w') as outfile: From e5c0c8fdd81c360194aa9b5e78baf40df24aa30b Mon Sep 17 00:00:00 2001 From: surfaace Date: Thu, 28 Jul 2016 11:54:33 +0200 Subject: [PATCH 2/2] better cach error method --- .../cell_workers/pokemon_transfer_worker.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/pokemongo_bot/cell_workers/pokemon_transfer_worker.py b/pokemongo_bot/cell_workers/pokemon_transfer_worker.py index 771acf665a..a2b5627661 100644 --- a/pokemongo_bot/cell_workers/pokemon_transfer_worker.py +++ b/pokemongo_bot/cell_workers/pokemon_transfer_worker.py @@ -37,13 +37,13 @@ def work(self): def _release_pokemon_get_groups(self): pokemon_groups = {} - try: - self.api.get_player().get_inventory() - inventory_req = self.api.call() - inventory_dict = inventory_req['responses']['GET_INVENTORY'][ - 'inventory_delta']['inventory_items'] - except KeyError: + self.api.get_player().get_inventory() + inventory_req = self.api.call() + + if inventory_req.get('responses', False) is False: return pokemon_groups + + inventory_dict = inventory_req['responses']['GET_INVENTORY']['inventory_delta']['inventory_items'] user_web_inventory = 'web/inventory-%s.json' % (self.config.username) with open(user_web_inventory, 'w') as outfile: