Repository: PokemonGoF/PokemonGo-Bot

Issue:
[MASTER] Error spinning pokestop
### Actual Behavior

[2016-07-26 12:35:42] [#] PokeStop on cooldown. Time left: 5.15 minutes
[2016-07-26 12:35:44] [#] Found fort bf7f4467e41b4039b13883553327bbbc.16 at distance 0.08km
[2016-07-26 12:35:44] [#] Need to move closer to Pokestop
[2016-07-26 12:35:44] [#] Walking from (-6.123799, 106.834561) to (-6.124769, 106.834192) for approx. 28.00 seconds
[2016-07-26 12:36:36] [#] Finished walking
[2016-07-26 12:36:36] [#] Arrived at Pokestop
[2016-07-26 12:36:39] [#] Now at Pokestop: Mini Turtle Statue - Spinning...
[2016-07-26 12:36:41] [+] Loot:
[2016-07-26 12:36:41] [+] 50 xp
[2016-07-26 12:36:41] [+] 1x Pokeball (Total: 18)
[2016-07-26 12:36:42] [+] 2x Razz Berry (Total: 147)
[2016-07-26 12:36:42] [#] PokeStop on cooldown. Time left: 5.16 minutes
[2016-07-26 12:36:44] [#] Found fort ebd6b7a5be514c8aafaaacb52bcc1922.16 at distance 0.13km
[2016-07-26 12:36:44] [#] Need to move closer to Pokestop
[2016-07-26 12:36:44] [#] Walking from (-6.124769, 106.834192) to (-6.123268, 106.834349) for approx. 41.00 seconds
[2016-07-26 12:37:57] [#] Finished walking
[2016-07-26 12:37:58] [#] Arrived at Pokestop
[2016-07-26 12:38:00] [#] Now at Pokestop: Ocean Ecopark - Ancol - Spinning...
Traceback (most recent call last):
  File "pokecli.py", line 220, in <module>
    main()
  File "pokecli.py", line 211, in main
    bot.take_step()
  File "C:\pogomap\PokemonGo-Bot\pokemongo_bot__init__.py", line 36, in take_step
    self.stepper.take_step()
  File "C:\pogomap\PokemonGo-Bot\pokemongo_bot\stepper.py", line 62, in take_step
    self._work_at_position(position[0], position[1], position[2], True)
  File "C:\pogomap\PokemonGo-Bot\pokemongo_bot\stepper.py", line 139, in _work_at_position
    self.bot.work_on_cell(cell, position, pokemon_only)
  File "C:\pogomap\PokemonGo-Bot\pokemongo_bot__init__.py", line 96, in work_on_cell
    hack_chain = worker.work()
  File "C:\pogomap\PokemonGo-Bot\pokemongo_bot\cell_workers\seen_fort_worker.py", line 51, in work
    if spin_details['result'] == 1:
KeyError: 'result'
### Steps to Reproduce

here is config :

{
    "auth_service": "google",
    "username": "",
    "password": "",
    "location": "",
    "gmapkey": "",
    "max_steps": 2,
    "mode": "all",
    "walk": 4.16,
    "debug": false,
    "test": false,
    "initial_transfer": 1,
    "location_cache": true,
    "distance_unit": "km",
    "item_filter": "101,102,103,104,201",
    "evolve_all": "NONE"
}

run bot about 10 minutes and error occured
### Other Information

OS: WIN 10 64bit
Git Commit: (run 'git log -n 1 --pretty=format:"%H"' and paste it here)



Discussion:
is this always at the same place?

I'm having the same issues, 
[2016-07-26 15:52:40] [#] Arrived at Pokestop
[2016-07-26 15:52:44] [#] Now at Pokestop: Unknown - Spinning...
Traceback (most recent call last):
  File "pokecli.py", line 220, in <module>
    main()
  File "pokecli.py", line 211, in main
    bot.take_step()
  File "F:\Games\pogo\PokemonGo-Bot2\pokemongo_bot__init__.py", line 37, in take_step
    self.stepper.take_step()
  File "F:\Games\pogo\PokemonGo-Bot2\pokemongo_bot\stepper.py", line 62, in take_step
    self._work_at_position(position[0], position[1], position[2], True)
  File "F:\Games\pogo\PokemonGo-Bot2\pokemongo_bot\stepper.py", line 139, in _work_at_position
    self.bot.work_on_cell(cell, position, pokemon_only)
  File "F:\Games\pogo\PokemonGo-Bot2\pokemongo_bot__init__.py", line 127, in work_on_cell
    hack_chain = worker.work()
  File "F:\Games\pogo\PokemonGo-Bot2\pokemongo_bot\cell_workers\seen_fort_worker.py", line 51, in work
    if spin_details['result'] == 1:
KeyError: 'result'

after I re run, it's fine

edited:
I re-run, it's fine on first pokestop, next pokestop has same error

**Other Information**
I've tried it on same location on 34.008096, -118.49908 three times
and it keeps happen

Also happens on Dev Branch:
[10:58:14] Arrived at Pokestop
[10:58:17] Now at Pokestop: Unknown - Spinning...
Traceback (most recent call last):
  File "pokecli.py", line 236, in <module>
    main()
  File "pokecli.py", line 227, in main
    bot.take_step()
  File "/home/lelmac/asd/PokemonGo-Bot/pokemongo_bot/**init**.py", line 40, in take_step
    self.work_on_cell(cell, location)
  File "/home/lelmac/asd/PokemonGo-Bot/pokemongo_bot/**init**.py", line 211, in work_on_cell
    hack_chain = worker.work()
  File "/home/lelmac/asd/PokemonGo-Bot/pokemongo_bot/cell_workers/seen_fort_worker.py", line 50, in work
    if spin_details['result'] == 1:
KeyError: 'result'

Some problem here,

`[2016-07-26 16:29:19] [#] Now at Pokestop: Unknown - Spinning...`
`Traceback (most recent call last):`
  `File "pokecli.py", line 220, in <module>`
    `main()`
  `File "pokecli.py", line 211, in main`
    `bot.take_step()`
  `File "/opt/PokemonGo-Bot/pokemongo_bot/__init__.py", line 36, in take_step`
    `self.stepper.take_step()`
  `File "/opt/PokemonGo-Bot/pokemongo_bot/stepper.py", line 62, in take_step`
    `self._work_at_position(position[0], position[1], position[2], True)`
  `File "/opt/PokemonGo-Bot/pokemongo_bot/stepper.py", line 139, in _work_at_position`
    `self.bot.work_on_cell(cell, position, pokemon_only)`
  `File "/opt/PokemonGo-Bot/pokemongo_bot/__init__.py", line 96, in work_on_cell`
    `hack_chain = worker.work()`
  `File "/opt/PokemonGo-Bot/pokemongo_bot/cell_workers/seen_fort_worker.py", line 51, in work`
    `if spin_details['result'] == 1:`
`KeyError: 'result'`

Same issue here too

Try reinstalling `pgoapi` by removing `pgoapi` and running `pip install -r requirements.txt`

trying **tstumm** solution, still happening on same spot

Same here, i have the same issue always on the unknow spinning


Resolving patch:
diff --git a/pokemongo_bot/cell_workers/seen_fort_worker.py b/pokemongo_bot/cell_workers/seen_fort_worker.py
--- a/pokemongo_bot/cell_workers/seen_fort_worker.py
+++ b/pokemongo_bot/cell_workers/seen_fort_worker.py
@@ -47,7 +47,8 @@ def work(self):
                 'FORT_SEARCH' in response_dict['responses']:
 
             spin_details = response_dict['responses']['FORT_SEARCH']
-            if spin_details['result'] == 1:
+            spin_result = spin_details.get('result', -1)
+            if spin_result == 1:
                 logger.log("Loot: ", 'green')
                 experience_awarded = spin_details.get('experience_awarded',
                                                       False)
@@ -105,9 +106,9 @@ def work(self):
                         'PokeStops you are indeed softbanned. Please try again '
                         'in a few hours.')
                     raise RuntimeError(message)
-            elif spin_details['result'] == 2:
+            elif spin_result == 2:
                 logger.log("[#] Pokestop out of range")
-            elif spin_details['result'] == 3:
+            elif spin_result == 3:
                 pokestop_cooldown = spin_details.get(
                     'cooldown_complete_timestamp_ms')
                 if pokestop_cooldown:
@@ -115,9 +116,11 @@ def work(self):
                     logger.log('PokeStop on cooldown. Time left: ' + str(
                         format_time((pokestop_cooldown / 1000) -
                                     seconds_since_epoch)))
-            elif spin_details['result'] == 4:
+            elif spin_result == 4:
                 logger.log("Inventory is full, switching to catch mode...", 'red')
                 self.config.mode = 'poke'
+            else:
+                logger.log("Unknown spin result: " + str(spin_result), 'red')
 
             if 'chain_hack_sequence_number' in response_dict['responses'][
                     'FORT_SEARCH']:


Test patch: