Fix #10, raise excpetion rather than sys.exit()

Signed-off-by: Domenico Iezzi <domenico.iezzi.201@gmail.com>
This commit is contained in:
Domenico Iezzi 2017-10-13 17:00:10 +02:00
parent afe654111e
commit d4fb3eba91

View File

@ -8,7 +8,6 @@ from Crypto.Cipher import PKCS1_OAEP
from clint.textui import progress from clint.textui import progress
import requests import requests
import sys
import base64 import base64
import itertools import itertools
@ -178,10 +177,9 @@ class GooglePlayAPI(object):
ac2dmToken = params["auth"] ac2dmToken = params["auth"]
elif "error" in params: elif "error" in params:
if "NeedsBrowser" in params["error"]: if "NeedsBrowser" in params["error"]:
print("\nsecurity check is needed, try to visit\n" raise LoginError("Security check is needed, try to visit "
"https://accounts.google.com/b/0/DisplayUnlockCaptcha\n" "https://accounts.google.com/b/0/DisplayUnlockCaptcha "
"if you use 2FA it is recommended to setup an app specific password\n") "to unlock, or setup an app-specific password")
sys.exit(1)
raise LoginError("server says: " + params["error"]) raise LoginError("server says: " + params["error"])
else: else:
raise LoginError("Auth token not found.") raise LoginError("Auth token not found.")