diff --git a/.travis.yml b/.travis.yml index afaa975..b89a103 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,6 +6,9 @@ matrix: - os: osx language: generic +services: + - docker + before_install: - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew update; @@ -20,6 +23,15 @@ before_install: python setup.py install; cd ..; fi + - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then + docker run -d -p 8080:8080 --name token_dispenser matlink/token-dispenser; + docker exec token_dispenser bash -c + "echo $GMAIL_ADDR $GMAIL_PWD > passwords/passwords.txt"; + docker restart token_dispenser; + sed -i 's,^token_url=.*$,token_url=http://localhost:8080/email/gsfid,g' gplaycli.conf; + sed -i 's,^token_url =.*$,token_url="http://localhost:8080/email/gsfid",g' + tests/test_init.py; + fi install: pip install . @@ -27,5 +39,5 @@ script: python -m pytest tests env: global: - - secure: GmiMAlU1OXaMyJBdK4x0zID+6TIaJR8SyVvcCWR7xofa+0/45DW3SfrOG7qHWVBniKwF6BOYKgLbyaNoS94OV58iMk08X9n2ksElv5JUluhVeKUQx3Owh+xy6nzw0949uvcZdXbWf3l4nOrdxE/rbf8NtGzrDcO/UF/9h2PLaP+X5xElsTijy2udbjOH/YNsUzktx11XMVyVPc5d3b43JkN9y8lPq0vPMW4dhAS2eGIsc3MPSMrG84N4oVJ+UQtc84Q6BOBpZMci2BtsLyfu0fFxicV/c1a1URV0S6IQgdS65aPhfODn6NPcrZCJ9VWlB0jW50KUU7y3Q5dRH3BK/bbUo4Cv5iLBL10giGGV7QadkAbBAtZF3ur1JQ6sQ4amNXjwQEpBhbUxEdN71qMI2sH5bMhvLjotoLuv8+roZO+x0VM21PLScYSiIMhuU0Tuahm4zKcNls0BGg13jlMc035cI8FKLwa4BlpxtxjsQebf1/7p7WAONY7tpbRExaFbuCE2JNSxwsFgssF/1tH86BHJbKAGJVbprEOEAxylfzzx6iG01o6/ExZvH+xnn373CHvEw8mMa1ygEst0GXr0EsDu3lfjYxgwuUHqYxQmhDvRYGcNYFPoE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li.py index 9d005fc..2e43c46 100755 --- a/gplaycli/gplaycli.py +++ b/gplaycli/gplaycli.py @@ -23,6 +23,7 @@ import configparser import warnings import json +import time from enum import IntEnum @@ -171,6 +172,7 @@ def retrieve_token(self, force_new=False): server located at self.token_url. """ token, gsfid, device = self.get_cached_token() + self.retrieve_time = time.time() if (token is not None and not force_new and device == self.device_codename): @@ -431,6 +433,11 @@ def connect(self): with warnings.catch_warnings(): warnings.simplefilter('error') try: + if self.token_enable: + now = time.time() + if now - self.retrieve_time < 5: + # Need to wait a bit before loging in with this token + time.sleep(5) self.api.login(email=email, password=password, authSubToken=authsub_token, diff --git a/tests/test_cli.py b/tests/test_cli.py index 70aaa4e..fe8f59d 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -13,7 +13,7 @@ UPDATEAPK=os.path.join("tests", "org.mozilla.focus.20112247.apk") TOKENFILE=os.path.expanduser('~/.cache/gplaycli/token') -RE_APPEND_VERSION=re.compile("^"+TESTAPK.replace('.', '\.')+"-v.[A-z0-9.-]+\.apk$") +RE_APPEND_VERSION=re.compile("^"+TESTAPK.replace('.', r'\.')+r"-v.[A-z0-9.-]+\.apk$") def call(args): proc = sp.run(args.split(), stdout=sp.PIPE, stderr=sp.PIPE)