gplaycli-3.29/ 0000775 0000000 0000000 00000000000 13630713124 0013253 5 ustar 00root root 0000000 0000000 gplaycli-3.29/.github/ 0000775 0000000 0000000 00000000000 13630713124 0014613 5 ustar 00root root 0000000 0000000 gplaycli-3.29/.github/ISSUE_TEMPLATE.md 0000664 0000000 0000000 00000000735 13630713124 0017325 0 ustar 00root root 0000000 0000000 I WON'T ANSWER IF YOU DON'T PROVIDE SUCH DETAILS. COPY-PASTING IS NOT ENOUGH, I'M NOT A JEDI (YET).
Please provide those informations:
- [ ] Operating System (ie Ubuntu 16.04)
- [ ] Python version when running `gplaycli` (should be 3+)
- [ ] GPlayCli version via `gplaycli -v`
- [ ] The way you installed `gplaycli`: `git clone`, `git clone and setup.py`, `pip install gplaycli`, `apt install gplaycli`, ...
- [ ] The authentication method: (own) credentials or (own) token.
gplaycli-3.29/.github/workflows/ 0000775 0000000 0000000 00000000000 13630713124 0016650 5 ustar 00root root 0000000 0000000 gplaycli-3.29/.github/workflows/debianpackage.yml 0000664 0000000 0000000 00000001656 13630713124 0022141 0 ustar 00root root 0000000 0000000 name: Debian package
on:
push:
tags:
- '*'
branches:
- dev
jobs:
deb:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install dependencies
run: |
sudo sed -i 's/bionic/disco/g' /etc/apt/sources.list
sudo apt update
sudo apt install -y wget build-essential python3-{pyaxmlparser,setuptools} dpkg-dev debhelper dh-python fakeroot
wget http://ftp.debian.org/debian/pool/main/g/googleplay-api/python3-gpapi_0.4.4-1_all.deb
sudo dpkg -i python3-gpapi_0.4.4-1_all.deb || sudo apt -f install -y
echo "::set-env name=VERSION::$(head -n1 debian/changelog | cut -d' ' -f2 | sed 's/.*(\(.*\))/\1/')"
- name: Build Debian package
run: sudo make deb
- name: Upload deb file
uses: actions/upload-artifact@v1
with:
name: gplaycli_${{env.VERSION}}_all.deb
path: packages/gplaycli_${{env.VERSION}}_all.deb gplaycli-3.29/.github/workflows/pythonpackage.yml 0000664 0000000 0000000 00000001410 13630713124 0022224 0 ustar 00root root 0000000 0000000 name: Python package
on: [push]
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
python-version: [3.8]
os: [ubuntu-latest, windows-latest, macos-latest]
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install pytest
python -m pip install .
- name: Test with pytest
env:
GMAIL_ADDR: ${{ secrets.GMAIL_ADDR }}
GMAIL_PWD: ${{ secrets.GMAIL_PWD }}
run: |
python tests/config-edit.py gplaycli.conf
python -m pytest tests gplaycli-3.29/.gitignore 0000664 0000000 0000000 00000000014 13630713124 0015236 0 ustar 00root root 0000000 0000000 *.pyc
*.swp
gplaycli-3.29/LICENSE.md 0000664 0000000 0000000 00000001437 13630713124 0014664 0 ustar 00root root 0000000 0000000 #GPlay-Cli
==========
Copyleft (C) 2015 Matlink
Hardly based on GooglePlayDownloader https://framagit.org/tuxicoman/googleplaydownloader
Copyright (C) 2013 Tuxicoman
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License along with this program. If not, see .
gplaycli-3.29/Makefile 0000664 0000000 0000000 00000001272 13630713124 0014715 0 ustar 00root root 0000000 0000000 SHELL := /bin/bash
PYTHON=$(shell which python3)
GPG=$(shell which gpg2)
TWINE=$(PYTHON) -m twine
VERSION=$(shell $(PYTHON) setup.py --version)
GPGID=186BB3CA
source:
$(PYTHON) setup.py sdist
sign:
$(GPG) --detach-sign --default-key $(GPGID) -a dist/gplaycli-$(VERSION).tar.gz
publish: clean source sign
$(TWINE) upload dist/gplaycli-$(VERSION).tar.gz dist/gplaycli-$(VERSION).tar.gz.asc
clean:
$(PYTHON) setup.py clean
rm -rf build/ MANIFEST dist gplaycli.egg-info debian/{gplaycli,python-module-stampdir} debian/gplaycli.{debhelper.log,postinst.debhelper,prerm.debhelper,substvars} *.tar.gz* deb_dist setup.cfg
find . -name '*.pyc' -delete
deb:
mkdir -p packages
bash debian/build.sh gplaycli-3.29/README.md 0000664 0000000 0000000 00000012047 13630713124 0014536 0 ustar 00root root 0000000 0000000 # gplaycli [](https://github.com/matlink/gplaycli/actions) 
GPlayCli is a command line tool to search, install, update Android applications from the Google Play Store.
$ usage: gplaycli [-h] [-V] [-v] [-s SEARCH] [-d AppID [AppID ...]] [-y] [-l FOLDER] [-P] [-av] [-a] [-F FILE]
[-u FOLDER] [-f FOLDER] [-dc DEVICE_CODENAME] [-t] [-tu TOKEN_URL] [-ts TOKEN_STR] [-g GSF_ID]
[-c CONF_FILE] [-p] [-L]
A Google Play Store Apk downloader and manager for command line
optional arguments:
-h, --help show this help message and exit
-V, --version Print version number and exit
-v, --verbose Be verbose
-s SEARCH, --search SEARCH
Search the given string in Google Play Store
-d AppID [AppID ...], --download AppID [AppID ...]
Download the Apps that map given AppIDs
-y, --yes Say yes to all prompted questions
-l FOLDER, --list FOLDER
List APKS in the given folder, with details
-P, --paid Also search for paid apps
-av, --append-version
Append versionstring to APKs when downloading
-a, --additional-files
Enable the download of additional files
-F FILE, --file FILE Load packages to download from file, one package per line
-u FOLDER, --update FOLDER
Update all APKs in a given folder
-f FOLDER, --folder FOLDER
Where to put the downloaded Apks, only for -d command
-dc DEVICE_CODENAME, --device-codename DEVICE_CODENAME
The device codename to fake
-t, --token Instead of classical credentials, use the tokenize version
-tu TOKEN_URL, --token-url TOKEN_URL
Use the given tokendispenser URL to retrieve a token
-ts TOKEN_STR, --token-str TOKEN_STR
Supply token string by yourself, need to supply GSF_ID at the same time
-g GSF_ID, --gsfid GSF_ID
Supply GSF_ID by yourself, need to supply token string at the same time
-c CONF_FILE, --config CONF_FILE
Use a different config file than gplaycli.conf
-p, --progress Prompt a progress bar while downloading packages
-L, --log Enable logging of apps status in separate logging files
Credentials
===========
## Warning
Token authentication is currently out of order since the default token dispenser instance has probably been blacklisted from Google servers.
By default, gplaycli fetches a token from a token dispenser server located at https://matlink.fr/token/email/gsfid to login in Google Play. If you want to use another token dispenser server, change its URL in the configuration file (depends on the way you installed it). If you want to use your own Google credentials, put
token=False
in the config file and type in your credentials in
gmail_address=
gmail_password=
variables.
Changelog
=========
See https://github.com/matlink/gplaycli/releases for releases and changelogs
Installation
============
Pip
---
- Best way to install it is using pip3: `pip3 install gplaycli` or `pip3 install gplaycli --user` if you are non-root
- Cleanest way is using virtualenv: `virtualenv gplaycli; cd gplaycli; source bin/activate`, then either `pip3 install gplaycli` or `git clone https://github.com/matlink/gplaycli && pip3 install ./gplaycli/`. Make sure `virtualenv` is initialized with Python 3. If it's not, use `virtualenv -p python3`.
Debian installation
--------------------
Releases are available here https://github.com/matlink/gplaycli/releases/ as debian packages. Or click this link for automated builds . If you prefer not to use debian packaging, check the following method.
Requirements
----------
Works on GNU/Linux or Windows with `pip` and Python 3. First of all, ensure these packages are installed on your system :
- python3-dev package -> `apt-get install python3-dev`
- libffi package -> `apt-get install libffi-dev`
- libssl-dev -> `apt-get install libssl-dev` (for pypi's `cryptography` compilation)
- python (>=3)
Then, you need to install it with some needed libraries using either `pip3 install gplaycli` or `python3 setup.py install` after cloning it, then it will be available with `gplaycli` command. If you don't want to install it, only install requirements with `pip3 install -r requirements.txt` and use it as it.
If you want to use your own Google credentials, simply change them in the `gplaycli.conf` file with your own settings.
If you plan to use it with F-Droid-server, remember that fdroidserver needs Java (more precisely the 'jar' command) to work.
Uninstall
=========
Use `pip uninstall gplaycli`, and remove conf with `rm -rf /etc/gplaycli`. Should be clean, except python dependencies for gplaycli.
gplaycli-3.29/debian/ 0000775 0000000 0000000 00000000000 13630713124 0014475 5 ustar 00root root 0000000 0000000 gplaycli-3.29/debian/build.sh 0000664 0000000 0000000 00000002410 13630713124 0016125 0 ustar 00root root 0000000 0000000 #!/bin/bash
set -e
src_version=$(python3 setup.py --version)
package_version=1
software_name=$(python3 setup.py --name)
BUILD_DIRECTORIES="dist ${software_name}.egg-info"
function clean_build_directories {
echo "--- Cleaning Build Directories ---"
for directory in ${BUILD_DIRECTORIES}; do
if [ -d ${directory} ]; then
rm -rf ${directory}
fi
done
}
function build_python_package {
echo "--- Building Python Package ---"
echo -e "[install]\nprefix=/\ninstall-scripts=/usr/bin" > setup.cfg
python3 setup.py sdist --formats=gztar
}
function build_debian_package {
echo "--- Building Debian Package ---"
mv dist/${software_name}-${src_version}.tar.gz dist/${software_name}_${src_version}.orig.tar.gz
tar -C dist -xvf dist/${software_name}_${src_version}.orig.tar.gz
mv dist/${software_name}-${src_version} dist/${software_name}_${src_version}
cp -r debian dist/${software_name}_${src_version}/debian
(cd dist/${software_name}_${src_version}/ && dpkg-buildpackage -us -uc)
mv dist/${software_name}_${src_version}-${package_version}_all.deb packages/
cp dist/${software_name}_${src_version}.orig.tar.gz packages/
}
clean_build_directories
build_python_package
build_debian_package
clean_build_directories gplaycli-3.29/debian/changelog 0000664 0000000 0000000 00000005032 13630713124 0016347 0 ustar 00root root 0000000 0000000 gplaycli (3.29-1) unstable; urgency=medium
* New upstream release.
* Use new way of authenticate on Google Play
* Fix lots of authentication errors
* Fix token dispenser errors
-- Matlink Mon, 7 Mar 2020 00:13:00 +0000
gplaycli (3.28-1) unstable; urgency=low
* New upstream release.
-- Matlink Mon, 23 Feb 2020 00:07:00 +0000
gplaycli (3.27-1) unstable; urgency=low
* New upstream release.
-- Matlink Mon, 10 Feb 2020 10:00:00 +0000
gplaycli (3.26-1) unstable; urgency=low
* New upstream release.
-- Matlink Mon, 09 Sep 2019 10:00:00 +0000
gplaycli (3.25+ds-1) unstable; urgency=low
* New upstream release.
-- Andres Salomon Wed, 17 Oct 2018 21:42:29 +0000
gplaycli (3.24+ds-1) unstable; urgency=low
* New upstream release.
* Upload to unstable now that protobuf has been updated (closes: #903718).
* Add build-dep versioning to python3-gpapi.
-- Andres Salomon Sat, 13 Oct 2018 18:34:21 +0000
gplaycli (3.23+ds-1) experimental; urgency=low
* New upstream release.
* Replace androguard dependency with python3-pyaxmlparser.
* Clean up a bunch of lintian warnings.
* Remove the apk from the copyright file, and repack the
orig.tar.gz without any extra apks.
* Add python3-crypto dependency.
-- Andres Salomon Fri, 06 Jul 2018 07:44:46 +0000
gplaycli (3.22-1) experimental; urgency=low
* New upstream release.
* Refresh debian/patches.
* Transition package to Python 3 (closes: #895792).
* Switch packaging away from quilt (and refresh single patch).
* Update debian/copyright for duckduckgo apk distributed in
the source package, and for the removal of gpapi from this package.
-- Andres Salomon Fri, 27 Apr 2018 21:49:14 -0700
gplaycli (0.2.10-1) unstable; urgency=medium
* New upstream release (closes: #871828)
* Add myself as a co-maintainer.
* Drop part of fix-config-install patch; keeping only the setup.py bit.
* Clean up *egg-info after build.
* Handle renaming of config file via maintscript.
-- Andres Salomon Wed, 30 Aug 2017 22:31:26 +0000
gplaycli (0.2.1-1) unstable; urgency=medium
* New upstream release.
-- Matlink Tue, 20 Dec 2016 15:40:55 +0100
gplaycli (0.1.2+git15~g20f65ca-1) unstable; urgency=low
* Initial release. (Closes: #810722)
-- Matlink (Matlink - Sysadmin matlink.fr) Mon, 24 Aug 2015 21:38:29 +0200
gplaycli-3.29/debian/compat 0000664 0000000 0000000 00000000002 13630713124 0015673 0 ustar 00root root 0000000 0000000 9
gplaycli-3.29/debian/control 0000664 0000000 0000000 00000001545 13630713124 0016105 0 ustar 00root root 0000000 0000000 Source: gplaycli
Section: utils
Priority: optional
Maintainer: Matlink
Uploaders: Andres Salomon
Build-Depends: debhelper (>= 9.0~),
dh-python,
python3,
python3-setuptools,
python3-pyaxmlparser,
python3-matlink-gpapi (>= 0.4.4.4)
Standards-Version: 4.1.0
Homepage: https://github.com/matlink/gplaycli
Package: gplaycli
Architecture: all
Depends: ${python3:Depends},
${misc:Depends},
python3-crypto
Recommends: fdroidserver, dummydroid
Description: Google Play downloader command line interface
GPlayCli is a command line tool to search, install, update Android
applications from the Google Play Store. The main goal was to be
able to run this script with a cronjob, in order to automatically
update an F-Droid server instance.
gplaycli-3.29/debian/copyright 0000664 0000000 0000000 00000001671 13630713124 0016435 0 ustar 00root root 0000000 0000000 Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: gplaycli
Upstream-Contact: Matlink (Matlink - Sysadmin matlink.fr)
Source: https://github.com/matlink/gplaycli
Files: *
Copyright: 2015-2020, Matlink
2013, Tuxicoman
License: AGPL-3
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Affero General Public License for more details.
.
You should have received a copy of the GNU Affero General Public
License along with this program. If not, see
.
gplaycli-3.29/debian/gbp.conf 0000664 0000000 0000000 00000000057 13630713124 0016116 0 ustar 00root root 0000000 0000000 [DEFAULT]
pristine-tar = True
sign-tags = True
gplaycli-3.29/debian/rules 0000664 0000000 0000000 00000001021 13630713124 0015544 0 ustar 00root root 0000000 0000000 #!/usr/bin/make -f
include /usr/share/dpkg/default.mk
%:
dh $@ --with python3 --buildsystem=pybuild
override_dh_auto_install:
dh_auto_install
override_dh_clean:
dh_clean
rm -rf GPlayCli.egg-info/
COMMIT_TO_DOWNLOAD = 0.2.10
newtarball = new$(COMMIT_TO_DOWNLOAD).tar.gz
get-orig-source:
wget --continue -O $(newtarball) \
https://github.com/matlink/gplaycli/archive/$(COMMIT_TO_DOWNLOAD).tar.gz
mk-origtargz \
--rename \
--repack \
--exclude-file debian \
--exclude-file ext_libs/androguard \
$(newtarball)
gplaycli-3.29/debian/watch 0000664 0000000 0000000 00000000277 13630713124 0015534 0 ustar 00root root 0000000 0000000 version=3
opts=uversionmangle=s/(rc|a|b|c)/~$1/,pgpsigurlmangle=s/$/.asc/,dversionmangle=s/\.ds// \
https://pypi.debian.net/GPlayCli/GPlayCli-(.+)\.(?:zip|tgz|tbz|txz|(?:tar\.(?:gz|bz2|xz)))
gplaycli-3.29/gplaycli.conf 0000664 0000000 0000000 00000000301 13630713124 0015720 0 ustar 00root root 0000000 0000000 [Credentials]
gmail_address=
gmail_password=
#keyring_service=gplaycli
token=True
token_url=https://matlink.fr/token
[Cache]
token=~/.cache/gplaycli/token
[Locale]
locale=en_GB
timezone=CEST
gplaycli-3.29/gplaycli/ 0000775 0000000 0000000 00000000000 13630713124 0015057 5 ustar 00root root 0000000 0000000 gplaycli-3.29/gplaycli/__init__.py 0000664 0000000 0000000 00000000000 13630713124 0017156 0 ustar 00root root 0000000 0000000 gplaycli-3.29/gplaycli/__main__.py 0000664 0000000 0000000 00000000104 13630713124 0017144 0 ustar 00root root 0000000 0000000 from gplaycli.gplaycli import *
if __name__ == '__main__':
main()
gplaycli-3.29/gplaycli/gplaycli.py 0000775 0000000 0000000 00000056465 13630713124 0017260 0 ustar 00root root 0000000 0000000 #! /usr/bin/env python3
# -*- coding: utf-8 -*-
"""
GPlay-Cli
Copyleft (C) 2015 Matlink
Hardly based on GooglePlayDownloader https://framagit.org/tuxicoman/googleplaydownloader
Copyright (C) 2013 Tuxicoman
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General
Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any
later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
details.
You should have received a copy of the GNU Affero General Public License along with this program. If not,
see .
"""
import os
import sys
import site
import json
import enum
import logging
import argparse
import requests
import configparser
from gpapi.googleplay import GooglePlayAPI, LoginError, RequestError
from google.protobuf.message import DecodeError
from pkg_resources import get_distribution, DistributionNotFound
from pyaxmlparser import APK
from . import util
from . import hooks
try:
import keyring
HAVE_KEYRING = True
except ImportError:
HAVE_KEYRING = False
try:
__version__ = '%s [Python%s] ' % (get_distribution('gplaycli').version, sys.version.split()[0])
except DistributionNotFound:
__version__ = 'unknown: gplaycli not installed (version in setup.py)'
logger = logging.getLogger(__name__) # default level is WARNING
handler = logging.StreamHandler()
handler.setFormatter(logging.Formatter("[%(levelname)s] %(message)s"))
logger.addHandler(handler)
logger.propagate = False
class ERRORS(enum.IntEnum):
"""
Contains constant errors for Gplaycli
"""
SUCCESS = 0
TOKEN_DISPENSER_AUTH_ERROR = 5
TOKEN_DISPENSER_SERVER_ERROR = 6
KEYRING_NOT_INSTALLED = 10
CANNOT_LOGIN_GPLAY = 15
class GPlaycli:
"""
Object which handles Google Play connection
search and download.
GPlaycli can be used as an API with parameters
token_enable, token_url, config and with methods
retrieve_token(), connect(),
download(), search().
"""
def __init__(self, args=None, config_file=None):
# no config file given, look for one
if config_file is None:
# default local user configs
cred_paths_list = [
os.getcwd(),
os.path.join(site.USER_BASE, 'etc', 'gplaycli'),
os.path.join(sys.prefix, 'local', 'etc', 'gplaycli'),
os.path.join('/etc', 'gplaycli')
]
for filepath in cred_paths_list:
if os.path.isfile(os.path.join(filepath, 'gplaycli.conf')):
config_file = os.path.join(filepath, 'gplaycli.conf')
break
if config_file is None:
logger.warn("No configuration file gplaycli.conf found at %s, using default values" % cred_paths_list)
self.api = None
self.token_passed = False
config = configparser.ConfigParser()
if config_file:
config.read(config_file)
self.gmail_address = config.get('Credentials', 'gmail_address', fallback=None)
self.gmail_password = config.get('Credentials', 'gmail_password', fallback=None)
self.token_enable = config.getboolean('Credentials', 'token', fallback=True)
self.token_url = config.get('Credentials', 'token_url', fallback='https://matlink.fr/token/email/gsfid')
self.keyring_service = config.get('Credentials', 'keyring_service', fallback=None)
self.tokencachefile = os.path.expanduser(config.get("Cache", "token", fallback="token.cache"))
self.yes = config.getboolean('Misc', 'accept_all', fallback=False)
self.verbose = config.getboolean('Misc', 'verbose', fallback=False)
self.append_version = config.getboolean('Misc', 'append_version', fallback=False)
self.progress_bar = config.getboolean('Misc', 'progress', fallback=False)
self.logging_enable = config.getboolean('Misc', 'enable_logging', fallback=False)
self.addfiles_enable = config.getboolean('Misc', 'enable_addfiles', fallback=False)
self.device_codename = config.get('Device', 'codename', fallback='bacon')
self.locale = config.get("Locale", "locale", fallback="en_GB")
self.timezone = config.get("Locale", "timezone", fallback="CEST")
if not args: return
# if args are passed, override defaults
if args.yes is not None:
self.yes = args.yes
if args.verbose is not None:
self.verbose = args.verbose
if self.verbose:
logger.setLevel(logging.INFO)
logger.info('GPlayCli version %s', __version__)
logger.info('Configuration file is %s', config_file)
if args.append_version is not None:
self.append_version = args.append_version
if args.progress is not None:
self.progress_bar = args.progress
if args.update is not None:
self.download_folder = args.update
if args.log is not None:
self.logging_enable = args.log
if args.device_codename is not None:
self.device_codename = args.device_codename
logger.info('Device is %s', self.device_codename)
if args.additional_files is not None:
self.addfiles_enable = args.additional_files
if args.token is not None:
self.token_enable = args.token
if self.token_enable is not None:
if args.token_url is not None:
self.token_url = args.token_url
if (args.token_str is not None) and (args.gsfid is not None):
self.token = args.token_str
self.gsfid = args.gsfid
self.token_passed = True
elif args.token_str is None and args.gsfid is None:
pass
else:
raise TypeError("Token string and GSFID have to be passed at the same time.")
if self.logging_enable:
self.success_logfile = "apps_downloaded.log"
self.failed_logfile = "apps_failed.log"
self.unavail_logfile = "apps_not_available.log"
########## Public methods ##########
def retrieve_token(self, force_new=False):
"""
Return a token. If a cached token exists,
it will be used. Else, or if force_new=True,
a new token is fetched from the token-dispenser
server located at self.token_url.
"""
self.token, self.gsfid, self.gmail_address = self.get_cached_token()
if (self.token is not None and not force_new):
logger.info("Using cached token.")
self.gsfid = hex(self.api.checkin(self.gmail_address, self.token))[2:]
return
logger.info("Retrieving token ...")
logger.info("Token URL is %s", self.token_url)
email_url = '/'.join([self.token_url, 'email'])
response = requests.get(email_url)
if response.status_code == 200:
self.gmail_address = response.text
else:
logger.error("Cannot retrieve email address from token dispenser")
raise ERRORS.TOKEN_DISPENSER_SERVER_ERROR
token_url = '/'.join([self.token_url, 'token/email', self.gmail_address])
response = requests.get(token_url)
if response.status_code == 200:
self.token = response.text
self.gsfid = hex(self.api.checkin(self.gmail_address, self.token))[2:]
logger.info("Email: %s", self.gmail_address)
logger.info("Token: %s", self.token)
logger.info("GsfId: %s", self.gsfid)
self.write_cached_token(self.token, self.gsfid, self.gmail_address)
else:
logger.error("Token dispenser server error: %s", response.status_code)
raise ERRORS.TOKEN_DISPENSER_SERVER_ERROR
@hooks.connected
def download(self, pkg_todownload):
"""
Download apks from the pkg_todownload list
pkg_todownload -- list either of app names or
of tuple of app names and filepath to write them
Example: ['org.mozilla.focus','org.mozilla.firefox'] or
[('org.mozilla.focus', 'org.mozilla.focus.apk'),
('org.mozilla.firefox', 'download/org.mozilla.firefox.apk')]
"""
success_downloads = []
failed_downloads = []
unavail_downloads = []
# case where no filenames have been provided
for index, pkg in enumerate(pkg_todownload):
if isinstance(pkg, str):
pkg_todownload[index] = [pkg, None]
# remove whitespaces before and after package name
pkg_todownload[index][0] = pkg_todownload[index][0].strip()
# Check for download folder
download_folder = self.download_folder
if not os.path.isdir(download_folder):
os.makedirs(download_folder, exist_ok=True)
# BulkDetails requires only one HTTP request
# Get APK info from store
details = list()
for pkg in pkg_todownload:
try:
detail = self.api.details(pkg[0])
details.append(detail)
except RequestError as request_error:
failed_downloads.append((pkg, request_error))
if any([d is None for d in details]):
logger.info("Token has expired while downloading. Retrieving a new one.")
self.refresh_token()
details = self.api.bulkDetails([pkg[0] for pkg in pkg_todownload])
for position, (detail, item) in enumerate(zip(details, pkg_todownload)):
packagename, filename = item
if filename is None:
if self.append_version:
filename = "%s-v.%s.apk" % (detail['docid'], detail['details']['appDetails']['versionString'])
else:
filename = "%s.apk" % detail['docid']
logger.info("%s / %s %s", 1+position, len(pkg_todownload), packagename)
# Download
try:
if detail['offer'][0]['checkoutFlowRequired']:
method = self.api.delivery
else:
method = self.api.download
data_iter = method(packagename, expansion_files=self.addfiles_enable)
success_downloads.append(packagename)
except IndexError as exc:
logger.error("Error while downloading %s : this package does not exist, "
"try to search it via --search before",
packagename)
unavail_downloads.append((item, exc))
continue
except Exception as exc:
logger.error("Error while downloading %s : %s", packagename, exc)
failed_downloads.append((item, exc))
continue
filepath = os.path.join(download_folder, filename)
#if file exists, continue
if self.append_version and os.path.isfile(filepath):
logger.info("File %s already exists, skipping.", filename)
continue
additional_data = data_iter['additionalData']
splits = data_iter['splits']
total_size = int(data_iter['file']['total_size'])
chunk_size = int(data_iter['file']['chunk_size'])
try:
with open(filepath, "wb") as fbuffer:
bar = util.progressbar(expected_size=total_size, hide=not self.progress_bar)
for index, chunk in enumerate(data_iter['file']['data']):
fbuffer.write(chunk)
bar.show(index * chunk_size)
bar.done()
if additional_data:
for obb_file in additional_data:
obb_filename = "%s.%s.%s.obb" % (obb_file["type"], obb_file["versionCode"], data_iter["docId"])
obb_filename = os.path.join(download_folder, obb_filename)
obb_total_size = int(obb_file['file']['total_size'])
obb_chunk_size = int(obb_file['file']['chunk_size'])
with open(obb_filename, "wb") as fbuffer:
bar = util.progressbar(expected_size=obb_total_size, hide=not self.progress_bar)
for index, chunk in enumerate(obb_file["file"]["data"]):
fbuffer.write(chunk)
bar.show(index * obb_chunk_size)
bar.done()
if splits:
for split in splits:
split_total_size = int(split['file']['total_size'])
split_chunk_size = int(split['file']['chunk_size'])
with open(split['name'], "wb") as fbuffer:
bar = util.progressbar(expected_size=split_total_size, hide=not self.progress_bar)
for index, chunk in enumerate(split["file"]["data"]):
fbuffer.write(chunk)
bar.show(index * split_chunk_size)
bar.done()
except IOError as exc:
logger.error("Error while writing %s : %s", packagename, exc)
failed_downloads.append((item, exc))
success_items = set(success_downloads)
failed_items = set([item[0] for item, error in failed_downloads])
unavail_items = set([item[0] for item, error in unavail_downloads])
to_download_items = set([item[0] for item in pkg_todownload])
self.write_logfiles(success_items, failed_items, unavail_items)
self.print_failed(failed_downloads + unavail_downloads)
return to_download_items - failed_items
@hooks.connected
def search(self, search_string, free_only=True, include_headers=True):
"""
Search the given string search_string on the Play Store.
search_string -- the string to search on the Play Store
free_only -- True if only costless apps should be searched for
include_headers -- True if the result table should show column names
"""
try:
results = self.api.search(search_string)
except IndexError:
results = []
if not results:
logger.info("No result")
return
all_results = []
if include_headers:
# Name of the columns
col_names = ["Title", "Creator", "Size", "Downloads", "Last Update", "AppID", "Version", "Rating"]
all_results.append(col_names)
# Compute results values
for doc in results:
for cluster in doc["child"]:
for app in cluster["child"]:
# skip that app if it not free
# or if it's beta (pre-registration)
if ('offer' not in app # beta apps (pre-registration)
or free_only
and app['offer'][0]['checkoutFlowRequired'] # not free to download
):
continue
details = app['details']['appDetails']
detail = [app['title'],
app['creator'],
util.sizeof_fmt(int(details['installationSize']))
if int(details['installationSize']) > 0 else 'N/A',
details['numDownloads'],
details['uploadDate'],
app['docid'],
details['versionCode'],
"%.2f" % app["aggregateRating"]["starRating"]
]
all_results.append(detail)
# Print a nice table
col_width = []
for column_indice in range(len(all_results[0])):
col_length = max([len("%s" % row[column_indice]) for row in all_results])
col_width.append(col_length + 2)
for result in all_results:
for indice, item in enumerate(result):
out = "".join(str(item).strip().ljust(col_width[indice]))
try:
print(out, end='')
except UnicodeEncodeError:
out = out.encode('utf-8', errors='replace')
print(out, end='')
print()
return all_results
########## End public methods ##########
########## Internal methods ##########
def connect(self):
"""
Connect GplayCli to the Google Play API.
If self.token_enable=True, the token from
self.retrieve_token is used. Else, classical
credentials are used. They might be stored
into the keyring if the keyring package
is installed.
"""
self.api = GooglePlayAPI(locale=self.locale, timezone=self.timezone, device_codename=self.device_codename)
if self.token_enable:
self.retrieve_token()
return self.connect_token()
else:
ok, err = self.connect_credentials()
if ok:
self.token = self.api.authSubToken
self.gsfid = self.api.gsfId
return ok, err
def connect_token(self):
if self.token_passed:
logger.info("Using passed token to connect to API")
else:
logger.info("Using auto retrieved token to connect to API")
try:
self.api.login(authSubToken=self.token, gsfId=int(self.gsfid, 16))
except (ValueError, IndexError, LoginError, DecodeError, SystemError, RequestError):
logger.info("Token has expired or is invalid. Retrieving a new one...")
self.retrieve_token(force_new=True)
self.connect()
return True, None
def connect_credentials(self):
logger.info("Using credentials to connect to API")
if self.gmail_password:
logger.info("Using plaintext password")
password = self.gmail_password
elif self.keyring_service and HAVE_KEYRING:
password = keyring.get_password(self.keyring_service, self.gmail_address)
elif self.keyring_service and not HAVE_KEYRING:
logger.error("You asked for keyring service but keyring package is not installed")
return False, ERRORS.KEYRING_NOT_INSTALLED
else:
logger.error("No password found. Check your configuration file.")
return False, ERRORS.CANNOT_LOGIN_GPLAY
try:
self.api.login(email=self.gmail_address, password=password)
except LoginError as e:
logger.error("Bad authentication, login or password incorrect (%s)", e)
return False, ERRORS.CANNOT_LOGIN_GPLAY
return True, None
def get_cached_token(self):
"""
Retrieve a cached token, gsfid and device if exist.
Otherwise return None.
"""
try:
cache_dic = json.loads(open(self.tokencachefile).read())
token = cache_dic['token']
gsfid = cache_dic['gsfid']
address = cache_dic['address']
except (IOError, ValueError, KeyError) as e: # cache file does not exists or is corrupted
print(e)
token = None
gsfid = None
address = None
logger.info('Cache file does not exists or is corrupted')
return token, gsfid, address
def write_cached_token(self, token, gsfid, address):
"""
Write the given token, gsfid and device
to the self.tokencachefile file.
Path and file are created if missing.
"""
cachedir = os.path.dirname(self.tokencachefile)
if not cachedir:
cachedir = os.getcwd()
# creates cachedir if not exists
if not os.path.exists(cachedir):
os.makedirs(cachedir, exist_ok=True)
with open(self.tokencachefile, 'w') as tcf:
tcf.write(json.dumps({'token' : token,
'gsfid' : gsfid,
'address' : address}))
def prepare_analyse_apks(self):
"""
Gather apks to further check for update
"""
list_of_apks = util.list_folder_apks(self.download_folder)
if not list_of_apks:
return
logger.info("Checking apks ...")
to_update = self.analyse_local_apks(list_of_apks, self.download_folder)
return self.prepare_download_updates(to_update)
@hooks.connected
def analyse_local_apks(self, list_of_apks, download_folder):
"""
Analyse apks in the list list_of_apks
to check for updates and download updates
in the download_folder folder.
"""
list_apks_to_update = []
package_bunch = []
version_codes = []
unavail_items = []
UNAVAIL = "This app is not available in the Play Store"
for filename in list_of_apks:
filepath = os.path.join(download_folder, filename)
logger.info("Analyzing %s", filepath)
apk = APK(filepath)
packagename = apk.package
package_bunch.append(packagename)
version_codes.append(util.vcode(apk.version_code))
# BulkDetails requires only one HTTP request
# Get APK info from store
details = self.api.bulkDetails(package_bunch)
for detail, packagename, filename, apk_version_code in zip(details, package_bunch, list_of_apks, version_codes):
# this app is not in the play store
if not detail:
unavail_items.append(((packagename, filename), UNAVAIL))
continue
store_version_code = detail['details']['appDetails']['versionCode']
# Compare
if apk_version_code < store_version_code:
# Add to the download list
list_apks_to_update.append([packagename, filename, apk_version_code, store_version_code])
self.write_logfiles(None, None, [item[0][0] for item in unavail_items])
self.print_failed(unavail_items)
return list_apks_to_update
def prepare_download_updates(self, list_apks_to_update):
"""
Ask confirmation before updating apks
"""
if not list_apks_to_update:
print("Everything is up to date !")
return False
pkg_todownload = []
# Ask confirmation before downloading
print("The following applications will be updated :")
for packagename, filename, apk_version_code, store_version_code in list_apks_to_update:
print("%s Version : %s -> %s" % (filename, apk_version_code, store_version_code))
pkg_todownload.append([packagename, filename])
if not self.yes:
print("Do you agree?")
return_value = input('y/n ?')
if self.yes or return_value == 'y':
logger.info("Downloading ...")
downloaded_packages = self.download(pkg_todownload)
return_string = ' '.join(downloaded_packages)
print("Updated: %s" % return_string)
return True
@staticmethod
def print_failed(failed_downloads):
"""
Print/log failed downloads from failed_downloads
"""
# Info message
if not failed_downloads:
return
else:
message = "A few packages could not be downloaded :\n"
for pkg, exception in failed_downloads:
package_name, filename = pkg
if filename is not None:
message += "%s : %s\n" % (filename, package_name)
else:
message += "%s\n" % package_name
message += "%s\n" % exception
logger.error(message)
def write_logfiles(self, success, failed, unavail):
"""
Write success failed and unavail list to
logfiles
"""
if not self.logging_enable:
return
for result, logfile in [(success, self.success_logfile), (failed, self.failed_logfile), (unavail, self.unavail_logfile)]:
if not result:
continue
with open(logfile, 'w') as _buffer:
for package in result:
print(package, file=_buffer)
########## End internal methods ##########
def main():
"""
Main function.
Parse command line arguments
"""
parser = argparse.ArgumentParser(description="A Google Play Store Apk downloader and manager for command line")
parser.add_argument('-V', '--version', help="Print version number and exit", action='store_true')
parser.add_argument('-v', '--verbose', help="Be verbose", action='store_true')
parser.add_argument('-s', '--search', help="Search the given string in Google Play Store", metavar="SEARCH")
parser.add_argument('-d', '--download', help="Download the Apps that map given AppIDs", metavar="AppID", nargs="+")
parser.add_argument('-y', '--yes', help="Say yes to all prompted questions", action='store_true')
parser.add_argument('-l', '--list', help="List APKS in the given folder, with details", metavar="FOLDER")
parser.add_argument('-P', '--paid', help="Also search for paid apps", action='store_true', default=False)
parser.add_argument('-av', '--append-version', help="Append versionstring to APKs when downloading", action='store_true')
parser.add_argument('-a', '--additional-files', help="Enable the download of additional files", action='store_true', default=False)
parser.add_argument('-F', '--file', help="Load packages to download from file, one package per line", metavar="FILE")
parser.add_argument('-u', '--update', help="Update all APKs in a given folder", metavar="FOLDER")
parser.add_argument('-f', '--folder', help="Where to put the downloaded Apks, only for -d command", metavar="FOLDER", nargs=1, default=['.'])
parser.add_argument('-dc', '--device-codename', help="The device codename to fake", choices=GooglePlayAPI.getDevicesCodenames(), metavar="DEVICE_CODENAME")
parser.add_argument('-t', '--token', help="Instead of classical credentials, use the tokenize version", action='store_true', default=None)
parser.add_argument('-tu', '--token-url', help="Use the given tokendispenser URL to retrieve a token", metavar="TOKEN_URL")
parser.add_argument('-ts', '--token-str', help="Supply token string by yourself, need to supply GSF_ID at the same time", metavar="TOKEN_STR")
parser.add_argument('-g', '--gsfid', help="Supply GSF_ID by yourself, need to supply token string at the same time", metavar="GSF_ID")
parser.add_argument('-c', '--config', help="Use a different config file than gplaycli.conf", metavar="CONF_FILE", nargs=1)
parser.add_argument('-p', '--progress', help="Prompt a progress bar while downloading packages", action='store_true')
parser.add_argument('-L', '--log', help="Enable logging of apps status in separate logging files", action='store_true', default=False)
if len(sys.argv) < 2:
sys.argv.append("-h")
args = parser.parse_args()
if args.version:
print(__version__)
return
cli = GPlaycli(args, args.config)
if args.list:
print(util.list_folder_apks(args.list))
if args.update:
cli.prepare_analyse_apks()
return
if args.search:
cli.verbose = True
cli.search(args.search, not args.paid)
if args.file:
args.download = util.load_from_file(args.file)
if args.download is not None:
if args.folder is not None:
cli.download_folder = args.folder[0]
cli.download(args.download)
if __name__ == '__main__':
main()
gplaycli-3.29/gplaycli/hooks.py 0000664 0000000 0000000 00000000503 13630713124 0016552 0 ustar 00root root 0000000 0000000 def connected(function):
"""
Decorator that checks the api status
before doing any request
"""
def check_connection(self, *args, **kwargs):
if self.api is None or self.api.authSubToken is None:
ok, err = self.connect()
if not ok:
exit(err)
return function(self, *args, **kwargs)
return check_connection
gplaycli-3.29/gplaycli/util.py 0000664 0000000 0000000 00000006445 13630713124 0016417 0 ustar 00root root 0000000 0000000 import os
import sys
import math
import time
def sizeof_fmt(num):
if not num:
return "00.00KB"
log = int(math.log(num, 1024))
return "%.2f%s" % (num/(1024**log), ['B ','KB','MB','GB','TB'][log])
def load_from_file(filename):
return [package.strip('\r\n') for package in open(filename).readlines()]
def list_folder_apks(folder):
"""
List apks in the given folder
"""
list_of_apks = [filename for filename in os.listdir(folder) if filename.endswith(".apk")]
return list_of_apks
def vcode(string_vcode):
"""
return integer of version
base can be 10 or 16
"""
base = 10
if string_vcode.startswith('0x'):
base = 16
return int(string_vcode, base)
### progress bar ###
""" copyright https://github.com/kennethreitz/clint """
class progressbar(object):
def __init__(self, label='', width=32, hide=None, empty_char=' ',
filled_char='#', expected_size=None, every=1, eta_interval=1,
eta_sma_window=9, stream=sys.stderr, bar_template='%s[%s%s] %s/%s - %s %s/s\r'):
self.label = label
self.width = width
self.hide = hide
# Only show bar in terminals by default (better for piping, logging etc.)
if hide is None:
try:
self.hide = not stream.isatty()
except AttributeError: # output does not support isatty()
self.hide = True
self.empty_char = empty_char
self.filled_char = filled_char
self.expected_size = expected_size
self.every = every
self.start = time.time()
self.ittimes = []
self.eta = 0
self.etadelta = time.time()
self.etadisp = self.format_time(self.eta)
self.last_progress = 0
self.eta_interval = eta_interval
self.eta_sma_window = eta_sma_window
self.stream = stream
self.bar_template = bar_template
self.speed = 0
if (self.expected_size):
self.show(0)
def show(self, progress, count=None):
if count is not None:
self.expected_size = count
if self.expected_size is None:
raise Exception("expected_size not initialized")
self.last_progress = progress
if (time.time() - self.etadelta) > self.eta_interval:
self.etadelta = time.time()
self.ittimes = (self.ittimes[-self.eta_sma_window:]
+ [-(self.start - time.time()) / (progress+1)])
self.eta = (sum(self.ittimes) / float(len(self.ittimes))
* (self.expected_size - progress))
self.etadisp = self.format_time(self.eta)
self.speed = 1 / (sum(self.ittimes) / float(len(self.ittimes)))
x = int(self.width * progress / self.expected_size)
if not self.hide:
if ((progress % self.every) == 0 or # True every "every" updates
(progress == self.expected_size)): # And when we're done
self.stream.write(self.bar_template % (
self.label, self.filled_char * x,
self.empty_char * (self.width - x), sizeof_fmt(progress),
sizeof_fmt(self.expected_size), self.etadisp, sizeof_fmt(self.speed)))
self.stream.flush()
def done(self):
self.elapsed = time.time() - self.start
elapsed_disp = self.format_time(self.elapsed)
if not self.hide:
# Print completed bar with elapsed time
self.stream.write(self.bar_template % (
self.label, self.filled_char * self.width,
self.empty_char * 0, sizeof_fmt(self.last_progress),
sizeof_fmt(self.expected_size), elapsed_disp, sizeof_fmt(self.speed)))
self.stream.write('\n')
self.stream.flush()
@staticmethod
def format_time(seconds):
return time.strftime('%H:%M:%S', time.gmtime(seconds))
gplaycli-3.29/requirements.txt 0000664 0000000 0000000 00000000032 13630713124 0016532 0 ustar 00root root 0000000 0000000 gpapi>=0.4.4
pyaxmlparser
gplaycli-3.29/setup.py 0000664 0000000 0000000 00000001361 13630713124 0014766 0 ustar 00root root 0000000 0000000 from setuptools import setup
import os
import sys
with open("README.md", "r") as fh:
long_description = fh.read()
setup(name='gplaycli',
version='3.29',
description='GPlayCli, a Google play downloader command line interface',
long_description=long_description,
long_description_content_type="text/markdown",
author="Matlink",
author_email="matlink@matlink.fr",
url="https://github.com/matlink/gplaycli",
license="AGPLv3",
entry_points={
'console_scripts': [
'gplaycli = gplaycli.gplaycli:main',
],
},
packages=[
'gplaycli',
],
package_dir={
'gplaycli': 'gplaycli',
},
data_files=[
['etc/gplaycli', ['gplaycli.conf']],
],
install_requires=[
'matlink-gpapi>=0.4.4.4',
'pyaxmlparser',
],
)
gplaycli-3.29/tests/ 0000775 0000000 0000000 00000000000 13630713124 0014415 5 ustar 00root root 0000000 0000000 gplaycli-3.29/tests/config-edit.py 0000664 0000000 0000000 00000000452 13630713124 0017160 0 ustar 00root root 0000000 0000000 import os
import sys
addr = os.environ['GMAIL_ADDR']
pwd = os.environ['GMAIL_PWD']
filename = sys.argv[1]
config = open(filename).read()
config = config.replace('gmail_address=', 'gmail_address=' + addr).replace('gmail_password=', 'gmail_password=' + pwd)
print(config, file=open(filename, 'w')) gplaycli-3.29/tests/test_cli.py 0000664 0000000 0000000 00000005036 13630713124 0016601 0 ustar 00root root 0000000 0000000 import os
import sys
import hashlib
import pytest
import subprocess as sp
import re
import json
ENC = sys.getdefaultencoding()
ERR = 'replace'
TESTAPK='org.mozilla.focus'
UPDATEAPK=os.path.join("tests", "org.mozilla.focus.20112247.apk")
TOKENFILE=os.path.expanduser('~/.cache/gplaycli/token')
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)
print(proc.stdout.decode(ENC, ERR), file=sys.stdout)
print(proc.stderr.decode(ENC, ERR), file=sys.stderr)
return proc
def nblines(comp_proc):
return len(comp_proc.stdout.decode(ENC, ERR).splitlines(True))
def download_apk(append_version = False):
if append_version:
call("gplaycli -av -vd %s" % TESTAPK)
else:
call("gplaycli -vd %s" % TESTAPK)
def checksum(apk):
return hashlib.sha256(open(apk, 'rb').read()).hexdigest()
def test_download():
if os.path.isfile(TOKENFILE):
os.remove(TOKENFILE)
download_apk()
assert os.path.isfile("%s.apk" % TESTAPK)
def test_download_version():
if os.path.isfile(TOKENFILE):
os.remove(TOKENFILE)
download_apk(append_version = True)
found = False
for f in os.listdir():
if RE_APPEND_VERSION.match(f):
found = True
if not found:
pytest.fail("Could not find package with version appended")
def test_alter_token():
cache_dict = json.loads(open(TOKENFILE).read())
cache_dict['token'] = ' ' + cache_dict['token'][1:]
with open(TOKENFILE, 'w') as outfile:
print(json.dumps(cache_dict), file=outfile)
download_apk()
assert os.path.isfile("%s.apk" % TESTAPK)
def test_update(apk=UPDATEAPK):
before = checksum(apk)
call("gplaycli -vyu tests")
after = checksum(apk)
assert after != before
def test_search(string='fire'):
c = call("gplaycli -s %s" % (string))
assert c.returncode == 0
def test_search2(string='com.yogavpn'):
c = call("gplaycli -s %s" % string)
assert c.returncode == 0
assert nblines(c) >= 0
def test_search3(string='com.yogavpn'):
c = call("gplaycli -s %s" % (string))
assert c.returncode == 0
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'):
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])
gplaycli-3.29/tests/test_init.py 0000664 0000000 0000000 00000002116 13630713124 0016771 0 ustar 00root root 0000000 0000000 import sys
import os
sys.path.insert(0, os.path.abspath('.'))
from gplaycli import gplaycli
gpc = gplaycli.GPlaycli()
token_url = "https://matlink.fr/token"
def test_default_settings():
assert gpc.yes == False
assert gpc.verbose == False
assert gpc.progress_bar == False
assert gpc.device_codename == 'bacon'
def test_connection_credentials():
try: # You are travis
if os.environ['TRAVIS_PULL_REQUEST'] != "false": # If current job is a Pull Request
print("Job is pull request. Won't check credentials")
return
except KeyError: # You are not travis
pass
gpc.token_enable = False
gpc.gmail_address = os.environ['GMAIL_ADDR']
gpc.gmail_password = os.environ['GMAIL_PWD']
success, error = gpc.connect()
assert error is None
assert success == True
def test_connection_token():
gpc.token_enable = True
gpc.token_url = token_url
gpc.retrieve_token(force_new=True)
success, error = gpc.connect()
assert error is None
assert success == True
def test_download_focus():
gpc.progress_bar = True
gpc.download_folder = os.path.abspath('.')
gpc.download(['org.mozilla.focus'])