Repository: PokemonGoF/PokemonGo-Bot

Issue:
PermaBanned Exception not handled properly
```
2016-08-21 08:18:35,368 [       cli] [INFO] PokemonGO Bot v1.0
2016-08-21 08:18:35,385 [       cli] [INFO] commit: cec90a56e2073c6b2b86bf5e68ededc07a7913f6
2016-08-21 08:18:35,390 [       cli] [INFO] Configuration initialized
2016-08-21 08:18:35,520 [yoyo.migrations] [INFO] Applying pokemongobot
2016-08-21 08:18:35,521 [yoyo.migrations] [INFO]  - applying step 0
2016-08-21 08:18:35,521 [yoyo.migrations] [INFO] Marking pokemongobot applied
2016-08-21 08:18:35,529 [PokemonGoBot] [INFO] [set_start_location] Setting start location.
2016-08-21 08:18:35,530 [PokemonGoBot] [INFO] [x] Coordinates found in passed in location, not geocoding.
2016-08-21 08:18:35,530 [PokemonGoBot] [INFO] [location_found] Location found: 30.160343, -95.464246 (30.160343, -95.464246, 8.0)
2016-08-21 08:18:35,531 [PokemonGoBot] [INFO] [position_update] Now at (30.160343, -95.464246, 8.0)
2016-08-21 08:18:35,531 [PokemonGoBot] [INFO] [login_started] Login procedure started.
2016-08-21 08:18:36,209 [PokemonGoBot] [INFO] [login_successful] Login successful.
2016-08-21 08:18:36,210 [PokemonGoBot] [INFO] Found encrypt.so! Platform: linux2 encrypt.so directory: /home/hazer/PokemonGo-Bot
2016-08-21 08:18:36,210 [PokemonGoBot] [INFO]
Traceback (most recent call last):
  File "pokecli.py", line 677, 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 "/home/hazer/PokemonGo-Bot/pokemongo_bot/metrics.py", line 96, in capture_stats
    response_dict = request.call()
  File "/home/hazer/PokemonGo-Bot/pokemongo_bot/api_wrapper.py", line 256, in call
    if not self.is_response_valid(result, request_callers):
  File "/home/hazer/PokemonGo-Bot/pokemongo_bot/api_wrapper.py", line 202, in is_response_valid
    raise PermaBannedException
pokemongo_bot.api_wrapper.PermaBannedException
```

Tested against a known banned account, looks like I now have 2 banned account, ah well.



Discussion:
Fresh pull made, same issue exists.....

```
2016-08-21 19:35:41,009 [       cli] [INFO] PokemonGO Bot v1.0
2016-08-21 19:35:41,025 [       cli] [INFO] commit: c6ce99ecb89825b5308ea333e26939f864a2232c
2016-08-21 19:35:41,030 [       cli] [INFO] Configuration initialized
2016-08-21 19:35:41,148 [PokemonGoBot] [INFO] [set_start_location] Setting start location.
2016-08-21 19:35:41,149 [PokemonGoBot] [INFO] [x] Coordinates found in passed in location, not geocoding.
2016-08-21 19:35:41,150 [PokemonGoBot] [INFO] [location_found] Location found: 30.160343, -95.464246 (30.160343, -95.464246, 8.0)
2016-08-21 19:35:41,150 [PokemonGoBot] [INFO] [position_update] Now at (30.160343, -95.464246, 8.0)
2016-08-21 19:35:41,151 [PokemonGoBot] [INFO] [login_started] Login procedure started.
2016-08-21 19:35:42,391 [PokemonGoBot] [INFO] [login_successful] Login successful.
2016-08-21 19:35:42,392 [PokemonGoBot] [INFO] Found encrypt.so! Platform: linux2 encrypt.so directory: /home/hazer/PokemonGo-Bot
2016-08-21 19:35:42,392 [PokemonGoBot] [INFO]
Traceback (most recent call last):
  File "pokecli.py", line 685, 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 "/home/hazer/PokemonGo-Bot/pokemongo_bot/metrics.py", line 96, in capture_stats
    response_dict = request.call()
  File "/home/hazer/PokemonGo-Bot/pokemongo_bot/api_wrapper.py", line 260, in call
    if not self.is_response_valid(result, request_callers):
  File "/home/hazer/PokemonGo-Bot/pokemongo_bot/api_wrapper.py", line 206, in is_response_valid
    raise PermaBannedException
pokemongo_bot.api_wrapper.PermaBannedException
```

What commit are you on? 


Resolving patch:
diff --git a/pokecli.py b/pokecli.py
--- a/pokecli.py
+++ b/pokecli.py
@@ -40,7 +40,7 @@
 import subprocess
 from datetime import timedelta
 from getpass import getpass
-from pgoapi.exceptions import NotLoggedInException, ServerSideRequestThrottlingException, ServerBusyOrOfflineException
+from pgoapi.exceptions import NotLoggedInException, ServerSideRequestThrottlingException, ServerBusyOrOfflineException, NoPlayerPositionSetException
 from geopy.exc import GeocoderQuotaExceeded
 
 from pokemongo_bot import inventory
@@ -143,6 +143,7 @@ def get_commit_hash():
                     level='info',
                     formatted='Server busy or offline'
                 )
+                time.sleep(wait_time)
             except ServerSideRequestThrottlingException:
                 bot.event_manager.emit(
                     'api_error',
@@ -151,14 +152,23 @@ def get_commit_hash():
                     formatted='Server is throttling, reconnecting in 30 seconds'
                 )
                 time.sleep(30)
+            except PermaBannedException:
+                bot.event_manager.emit(
+                    'api_error',
+                    sender=bot,
+                    level='info',
+                    formatted='Probably permabanned, Game Over ! Play again at https://club.pokemon.com/us/pokemon-trainer-club/sign-up/'
+                )
+                time.sleep(36000)
+            except NoPlayerPositionSetException:
+                bot.event_manager.emit(
+                    'api_error',
+                    sender=bot,
+                    level='info',
+                    formatted='No player position set'
+                )
+                time.sleep(wait_time)
 
-    except PermaBannedException:
-         bot.event_manager.emit(
-            'api_error',
-            sender=bot,
-            level='info',
-            formatted='Probably permabanned, Game Over ! Play again at https://club.pokemon.com/us/pokemon-trainer-club/sign-up/'
-         )
     except GeocoderQuotaExceeded:
         raise Exception("Google Maps API key over requests limit.")
     except SIGINTRecieved:


Test patch: