Repository: PokemonGoF/PokemonGo-Bot

Issue:
Crash on Last dev (Using Move To Map)
### Expected Behavior

Dont Crash
### Actual Behavior

> 2016-08-08 08:33:20,403 [IncubateEggs] [INFO] [next_egg_incubates] Next egg incubates in 0.87 km
> 2016-08-08 08:33:28,263 [MoveToMapPokemon] [INFO] [move_to_map_pokemon_teleport_to] Teleporting to Shellder. (0.28km)
> 2016-08-08 08:33:28,264 [MoveToMapPokemon] [INFO] [move_to_map_pokemon_encounter] Encountered Pokemon: Shellder
> 2016-08-08 08:33:31,309 [       cli] [INFO]
> 2016-08-08 08:33:31,310 [       cli] [INFO] Ran for 0:00:20
> 2016-08-08 08:33:31,313 [       cli] [INFO] Total XP Earned: 0  Average: 0.00/h
> 2016-08-08 08:33:31,314 [       cli] [INFO] Travelled 0.00km
> 2016-08-08 08:33:31,315 [       cli] [INFO] Visited 0 stops
> 2016-08-08 08:33:31,315 [       cli] [INFO] Encountered 1 pokemon, 0 caught, 0 released, 0 evolved, 0 never seen before
> 2016-08-08 08:33:31,316 [       cli] [INFO] Threw 0 pokeballs
> 2016-08-08 08:33:31,316 [       cli] [INFO] Earned 0 Stardust
> 2016-08-08 08:33:31,317 [       cli] [INFO]
> 2016-08-08 08:33:31,317 [       cli] [INFO] Highest CP Pokemon:
> 2016-08-08 08:33:31,317 [       cli] [INFO] Most Perfect Pokemon:
> Traceback (most recent call last):
>   File "pokecli.py", line 503, in <module>
>     main()
>   File "pokecli.py", line 89, in main
>     bot.tick()
>   File "/home/raul/PokemonGo-Bot/pokemongo_bot/**init**.py", line 434, in tick
>     if worker.work() == WorkerResult.RUNNING:
>   File "/home/raul/PokemonGo-Bot/pokemongo_bot/cell_workers/move_to_map_pokemon.py", line 255, in work
>     return self.snipe(pokemon)
>   File "/home/raul/PokemonGo-Bot/pokemongo_bot/cell_workers/move_to_map_pokemon.py", line 214, in snipe
>     self._teleport_back()
>   File "/home/raul/PokemonGo-Bot/pokemongo_bot/cell_workers/move_to_map_pokemon.py", line 339, in _teleport_back
>     data={'last_lat': last_position[0], 'last_lon': last_position[1]}
>   File "/home/raul/PokemonGo-Bot/pokemongo_bot/base_task.py", line 27, in emit_event
>     data=data
>   File "/home/raul/PokemonGo-Bot/pokemongo_bot/event_manager.py", line 61, in emit
>     formatted_msg = formatted.format(*_data)
> KeyError: 'last_long'
> 2016-08-08 08:33:31,416 [sentry.errors] [ERROR] Sentry responded with an error: 'ascii' codec can't decode byte 0x9c in position 1: ordinal not in range(128) (url: https://app.getsentry.com/api/90254/store/)
> Traceback (most recent call last):
>   File "/usr/local/lib/python2.7/dist-packages/raven/transport/threaded.py", line 174, in send_sync
>     super(ThreadedHTTPTransport, self).send(data, headers)
>   File "/usr/local/lib/python2.7/dist-packages/raven/transport/http.py", line 47, in send
>     ca_certs=self.ca_certs,
>   File "/usr/local/lib/python2.7/dist-packages/raven/utils/http.py", line 66, in urlopen
>     return opener.open(url, data, timeout)
>   File "/usr/local/lib/python2.7/dist-packages/future/backports/urllib/request.py", line 494, in open
>     response = self._open(req, data)
>   File "/usr/local/lib/python2.7/dist-packages/future/backports/urllib/request.py", line 512, in _open
>     '_open', req)
>   File "/usr/local/lib/python2.7/dist-packages/future/backports/urllib/request.py", line 466, in _call_chain
>     result = func(_args)
>   File "/usr/local/lib/python2.7/dist-packages/raven/utils/http.py", line 46, in https_open
>     return self.do_open(ValidHTTPSConnection, req)
>   File "/usr/local/lib/python2.7/dist-packages/future/backports/urllib/request.py", line 1284, in do_open
>     h.request(req.get_method(), req.selector, req.data, headers)
>   File "/usr/lib/python2.7/httplib.py", line 1001, in request
>     self._send_request(method, url, body, headers)
>   File "/usr/lib/python2.7/httplib.py", line 1035, in _send_request
>     self.endheaders(body)
>   File "/usr/lib/python2.7/httplib.py", line 997, in endheaders
>     self._send_output(message_body)
>   File "/usr/lib/python2.7/httplib.py", line 848, in _send_output
>     msg += message_body
> UnicodeDecodeError: 'ascii' codec can't decode byte 0x9c in position 1: ordinal not in range(128)
> 2016-08-08 08:33:31,430 [sentry.errors.uncaught] [ERROR] [u"KeyError: 'last_long'", u'  File "pokecli.py", line 503, in <module>', u'  File "pokecli.py", line 89, in main', u'  File "pokemongo_bot/__init__.py", line 434, in tick', u'  File "pokemongo_bot/cell_workers/move_to_map_pokemon.py", line 255, in work', u'  File "pokemongo_bot/cell_workers/move_to_map_pokemon.py", line 214, in snipe', u'  File "pokemongo_bot/cell_workers/move_to_map_pokemon.py", line 339, in _teleport_back', u'  File "pokemongo_bot/base_task.py", line 27, in emit_event', u'  File "pokemongo_bot/event_manager.py", line 61, in emit']
> `
### Steps to Reproduce

`./run.sh`



Discussion:

Resolving patch:
diff --git a/pokemongo_bot/cell_workers/move_to_map_pokemon.py b/pokemongo_bot/cell_workers/move_to_map_pokemon.py
--- a/pokemongo_bot/cell_workers/move_to_map_pokemon.py
+++ b/pokemongo_bot/cell_workers/move_to_map_pokemon.py
@@ -335,7 +335,7 @@ def _teleport_back(self):
         self.emit_event(
             'move_to_map_pokemon_teleport_back',
             formatted=('Teleporting back to previous location ({last_lat}, '
-                       '{last_long})'),
+                       '{last_lon})'),
             data={'last_lat': last_position[0], 'last_lon': last_position[1]}
         )
         self.bot.api.set_position(last_position[0], last_position[1], 0)


Test patch: