Repository: PokemonGoF/PokemonGo-Bot

Issue:
NoPlayerPositionSetException() after re-logging in
### Expected Behavior

Metrics should be shown after re-login
### Actual Behavior

NoPlayerPositionSetException() after re-logging in
### Output when issue occurred

```
2016-08-20 15:18:23,154 [PokemonGoBot] [INFO] [api_error] Session stale, re-logging in.
2016-08-20 15:18:23,171 [PokemonGoBot] [INFO] [login_started] Login procedure started.
Traceback (most recent call last):
  File "pokecli.py", line 674, in <module>
    main()
  File "pokecli.py", line 176, in main
    report_summary(bot)
  File "pokecli.py", line 211, in report_summary
    metrics.capture_stats()
  File "pokemongo_bot\metrics.py", line 84, in capture_stats
    response_dict = request.call()
  File "pokemongo_bot\api_wrapper.py", line 217, in call
    if not self.can_call():
  File "pokemongo_bot\api_wrapper.py", line 118, in can_call
    raise NoPlayerPositionSetException()
pgoapi.exceptions.NoPlayerPositionSetException
```
### Steps to Reproduce

Get a stale session
### Other Information

OS: 
Windows 10
Branch: 
dev
Git Commit: 
cc3b4c92b94b9e6b8f23f08eae93189a82d5cfd0
Python Version: 
2.7



Discussion:
Confirmed here, there's a double exception during the summary report, original exception is : 

>   File "./pokecli.py", line 677, in <module>
>     main()
>   File "./pokecli.py", line 118, in main
>     bot.tick()
>   File "./pokemongo_bot/**init**.py", line 538, in tick
>     self.check_session(self.position[0:2])
>   File "./pokemongo_bot/**init**.py", line 690, in check_session
>     self.login()
>   File "./pokemongo_bot/**init**.py", line 714, in login
>     str(self.config.password)):
>   File "./pokemongo_bot/api_wrapper.py", line 77, in login
>     ret_value = PGoApi.login(self, *args)
>   File "pgobot/src/pgoapi/pgoapi/pgoapi.py", line 179, in login
>     response = self.app_simulation_login()
>   File "pgobot/src/pgoapi/pgoapi/pgoapi.py", line 156, in app_simulation_login
>     response = request.call()
>   File "pgobot/src/pgoapi/pgoapi/pgoapi.py", line 215, in call
>     raise NoPlayerPositionSetException()
> pgoapi.exceptions.NoPlayerPositionSetException

Looking at the code, it seems the altitude is missing after the relog, I'll check out if I can fix that.


Resolving patch:
diff --git a/pokemongo_bot/__init__.py b/pokemongo_bot/__init__.py
--- a/pokemongo_bot/__init__.py
+++ b/pokemongo_bot/__init__.py
@@ -535,7 +535,7 @@ def tick(self):
         self.tick_count += 1
 
         # Check if session token has expired
-        self.check_session(self.position[0:2])
+        self.check_session(self.position)
 
         for worker in self.workers:
             if worker.work() == WorkerResult.RUNNING:
@@ -667,6 +667,7 @@ def _setup_logging(self):
             format='%(asctime)s [%(name)10s] [%(levelname)s] %(message)s'
         )
     def check_session(self, position):
+
         # Check session expiry
         if self.api._auth_provider and self.api._auth_provider._ticket_expire:
 
@@ -686,7 +687,7 @@ def check_session(self, position):
                     formatted='Session stale, re-logging in.'
                 )
                 self.api = ApiWrapper(config=self.config)
-                self.api.set_position(*self.position) 
+                self.api.set_position(*position)
                 self.login()
                 self.api.activate_signature(self.get_encryption_lib())
 


Test patch: