Repository: PokemonGoF/PokemonGo-Bot

Issue:
KeyError: 'experience' on starting bot
### Expected Behavior

Bot starts
### Actual Behavior

Bot crashes with a key not found
### Your FULL config.json (remove your username, password, gmapkey and any other private info)

http://pastebin.com/sRCNyKN1
### Output when issue occurred

```
[2016-08-30 11:34:06] [PokemonGoBot] [INFO] [login_successful] Login successful.
[2016-08-30 11:34:06] [PokemonGoBot] [INFO] Found encrypt.so! Platform: linux2 encrypt.so directory: /usr/src/app
[2016-08-30 11:34:06] [PokemonGoBot] [INFO] 
[2016-08-30 11:34:08] [       cli] [INFO] 
[2016-08-30 11:34:08] [       cli] [INFO] Ran for 0:00:05
[2016-08-30 11:34:08] [       cli] [INFO] Total XP Earned: 0  Average: 0.00/h
[2016-08-30 11:34:08] [       cli] [INFO] Travelled 0.00km
[2016-08-30 11:34:08] [       cli] [INFO] Visited 0 stops
[2016-08-30 11:34:08] [       cli] [INFO] Encountered 0 pokemon, 0 caught, 0 released, 0 evolved, 0 never seen before ()
[2016-08-30 11:34:08] [       cli] [INFO] Threw 0 pokeballs
[2016-08-30 11:34:08] [       cli] [INFO] Earned 0 Stardust
[2016-08-30 11:34:08] [       cli] [INFO] Hatched eggs 0
[2016-08-30 11:34:08] [       cli] [INFO] 
[2016-08-30 11:34:08] [       cli] [INFO] Highest CP Pokemon: 
[2016-08-30 11:34:08] [       cli] [INFO] Most Perfect Pokemon: 
Traceback (most recent call last):
  File "pokecli.py", line 781, in <module>
    main()
  File "pokecli.py", line 128, in main
    bot = start_bot(bot, config)
  File "pokecli.py", line 87, in start_bot
    bot.start()
  File "/usr/src/app/pokemongo_bot/__init__.py", line 131, in start
    init_inventory(self)
  File "/usr/src/app/pokemongo_bot/inventory.py", line 1326, in init_inventory
    _inventory = Inventory(bot)
  File "/usr/src/app/pokemongo_bot/inventory.py", line 1178, in __init__
    self.refresh()
  File "/usr/src/app/pokemongo_bot/inventory.py", line 1188, in refresh
    i.refresh(inventory)
  File "/usr/src/app/pokemongo_bot/inventory.py", line 128, in refresh
    self.player_stats = self.retrieve_data(inventory)
  File "/usr/src/app/pokemongo_bot/inventory.py", line 144, in retrieve_data
    self.parse(item)
  File "/usr/src/app/pokemongo_bot/inventory.py", line 131, in parse
    self.exp = item['experience']
KeyError: 'experience'

```
### Steps to Reproduce

Created a new account on PTC and put login info on bot. Never used the new created account with official app so even not started tutorial on app.
### Other Information

_OS:_ 
OS X 10.11.6 (El Capitan)

_Branch:_ 
dev

_Git Commit:_ 
56339fba1ba7f77a0275078ea0cf7a73e60c2ed0

_Python Version:_ 
Python 2.7.10

_Any other relevant files/configs (eg: path files)_ 
using docker



Discussion:

Resolving patch:
diff --git a/pokemongo_bot/inventory.py b/pokemongo_bot/inventory.py
--- a/pokemongo_bot/inventory.py
+++ b/pokemongo_bot/inventory.py
@@ -128,11 +128,14 @@ def refresh(self,inventory):
         self.player_stats = self.retrieve_data(inventory)
         
     def parse(self, item):
-        self.exp = item['experience']
-        self.level = item['level']
-        self.next_level_xp = item['next_level_xp']
-        self.pokemons_captured = item['pokemons_captured']
-        self.poke_stop_visits = item['poke_stop_visits']
+        if not item:
+            item = {}
+
+        self.exp = item.get('experience', 0)
+        self.level = item.get('level', 0)
+        self.next_level_xp = item.get('next_level_xp', 0)
+        self.pokemons_captured = item.get('pokemons_captured', 0)
+        self.poke_stop_visits = item.get('poke_stop_visits', 0)
 
     def retrieve_data(self, inventory):
         ret = {}


Test patch: