From f7ce16ebe769a26e5acf4d838dd92ae291b6b1a7 Mon Sep 17 00:00:00 2001 From: Matlink Date: Sat, 13 Oct 2018 19:09:34 +0200 Subject: [PATCH 1/7] Change google account --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index afaa975..f650f9f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -27,5 +27,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+xnn373CHvEw8mMa1ygEst0GXr0EsDu3lfjYxgwuUHqYxQmhDvRYGcNYFPoE789wJpaTnntzskftc0tVKCMTvEzs3aZ4mGdMbXgQKyVy1i7vDxdumY= - - secure: tQz3MAaNgzFifN1LzWwZbsDS6DqmAOBtsv6VZGkkLOkoF9wL9CxAsXPG5BMJ2MHlDaq4vjOE8OCT0HMNbALCXDq7SzE08w1HgZ8Fe+RBZdWNYclr5dKOLQaDayhvqXapgobS4eiv+oQ6ugU5CS7SSj2V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whpmMosedPqHi2qpTg9bD7rM17+7AdzNCQu8n4/+EU+HYDkuOhD73KqzZ9K+cTeoc9PUikNC4haTcstnlMNUworzGjaHR/EOKD8L4dpInXdI5a1vqzkB9+J1BFC307HF8XhEdGrmSkMx78TndNKJXJIUP+PD4= + - secure: Br5cN6c+98tv0kc1mmYNT7uKlHLzqoDxoxjjhTRYdFYojS6k2T8ZNFTvBCSyQCuytNV9A1GllTHLkjnV1+LB5uirrvh7ZYlDqw4DNSqVwHdcYi2dR676GoGV/Rq3l4vXiLpy2zFnLX/Cr95wPZZjShme6+pp9i5Pa2DzjlUm4XhXDkZpBX6Bh/aa1eUembCsIxLULSRtm7P/2tjJJ2eKM43QOxcSqxrSeZXYDVet7WZv+EuvhorZUFoc95pwtTlzOur0X2uB/Tysr9MeEvXSdTmt9iRA0ftw2smLds14cOoPqsYNeag8dkqJorkigU+10llGr+P2duBsDLe8odBDJvZWoR+WkE0RcYing9Z4MOHvYxhg1nvpKuADqdsUeO8hfscw/cdHzZYOLfsnkNp5j2DhfMwCHPQ2Zuaa/841u2ameemz7q/eB7XT2CAma5z5qY8nbDm0XmbNF+4TwUO/NRsNT+czSodLH/x/UWo78HZci9206AJfC8OQvBT81MaDKCRHyb708sj/vigS3Vmuq4c3FOYcFKT9Hssjo4xDPfv9NrydufvEZkxv24QK8CVQbc/QZGM14188AVYwYfrF6lOhOD8BKEwVE8ToAqeVtblGk4wyPiBUweT+MQgGXdWTOyXLyA0HVLd/HUw3Q6NyhtOzy1xilgXzr+zNi6cULXU= From 6cbe96e4527add234fac4c07831c0772ae6a5f75 Mon Sep 17 00:00:00 2001 From: Matlink Date: Sat, 13 Oct 2018 23:30:47 +0200 Subject: [PATCH 2/7] :bug: Add five seconds sleep before loging in with fresh token --- gplaycli/gplaycli.py | 7 +++++++ tests/test_cli.py | 4 ++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/gplaycli/gplaycli.py b/gplaycli/gplaycli.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..922076a 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -84,9 +84,9 @@ def test_another_device(device='hammerhead'): call("gplaycli -vd %s -dc %s" % (TESTAPK, device)) assert os.path.isfile("%s.apk" % TESTAPK) -def test_download_additional_files(apk='com.mapswithme.maps.pro', device='angler'): +def test_download_additional_files(apk='com.codigames.dungeon', device='angler'): call("gplaycli -d %s -a -dc %s" % (apk, device)) assert os.path.isfile("%s.apk" % apk) files = [f for f in os.listdir() if os.path.isfile(f)] assert any([f.endswith('%s.obb' % apk) and f.startswith('main') for f in files]) - assert any([f.endswith('%s.obb' % apk) and f.startswith('patch') for f in files]) + # assert any([f.endswith('%s.obb' % apk) and f.startswith('patch') for f in files]) From 58384af51092dd3a262a934c345562a20cca7678 Mon Sep 17 00:00:00 2001 From: Matlink Date: Sun, 14 Oct 2018 19:51:48 +0200 Subject: [PATCH 3/7] docker --- .travis.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.travis.yml b/.travis.yml index f650f9f..8693915 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,11 @@ before_install: python setup.py install; cd ..; fi + - 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 install: pip install . From 7770c635af7ceb9ef93390971c92b4b89fa38c5f Mon Sep 17 00:00:00 2001 From: Matlink Date: Sun, 14 Oct 2018 20:23:35 +0200 Subject: [PATCH 4/7] Try to come back to mapswithme --- tests/test_cli.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_cli.py b/tests/test_cli.py index 922076a..70aaa4e 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -84,9 +84,9 @@ def test_another_device(device='hammerhead'): call("gplaycli -vd %s -dc %s" % (TESTAPK, device)) assert os.path.isfile("%s.apk" % TESTAPK) -def test_download_additional_files(apk='com.codigames.dungeon', device='angler'): +def test_download_additional_files(apk='com.mapswithme.maps.pro', device='angler'): call("gplaycli -d %s -a -dc %s" % (apk, device)) assert os.path.isfile("%s.apk" % apk) files = [f for f in os.listdir() if os.path.isfile(f)] assert any([f.endswith('%s.obb' % apk) and f.startswith('main') for f in files]) - # assert any([f.endswith('%s.obb' % apk) and f.startswith('patch') for f in files]) + assert any([f.endswith('%s.obb' % apk) and f.startswith('patch') for f in files]) From f683f363002d142f7f7ef1570ba4d43f13252872 Mon Sep 17 00:00:00 2001 From: Matlink Date: Sun, 14 Oct 2018 20:43:38 +0200 Subject: [PATCH 5/7] Disable docker for OSX --- .travis.yml | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index 8693915..58c5e9e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -23,11 +23,13 @@ before_install: python setup.py install; cd ..; fi - - 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 + - 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 . From 361752a423a634c4f56351801e834f164acca227 Mon Sep 17 00:00:00 2001 From: Matlink Date: Sun, 14 Oct 2018 20:48:12 +0200 Subject: [PATCH 6/7] :bug: Fix sed error --- .travis.yml | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index 58c5e9e..b89a103 100644 --- a/.travis.yml +++ b/.travis.yml @@ -24,12 +24,14 @@ before_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 + 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 . From a46cbc820780e4719251643bea3e8505074c8134 Mon Sep 17 00:00:00 2001 From: Matlink Date: Sun, 14 Oct 2018 21:22:54 +0200 Subject: [PATCH 7/7] :bug: Raw string for re --- tests/test_cli.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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)