[CUSTOM_APP] Add a zim_path option to build_custom_app.py
If the user what to make a custom_app locally, he will need to download the zim file before. As he has already the zim, it is better to give the zim_path instead of give the zim_url and have `build_custom_app.py` download a second time the zim.
This commit is contained in:
parent
ac5dc39955
commit
78dd2626ca
|
@ -59,13 +59,14 @@ def parse_args():
|
||||||
parser.add_argument('--step', default='launch', choices=['launch', 'publish'], help=argparse.SUPPRESS)
|
parser.add_argument('--step', default='launch', choices=['launch', 'publish'], help=argparse.SUPPRESS)
|
||||||
parser.add_argument('--apks-dir', help=argparse.SUPPRESS)
|
parser.add_argument('--apks-dir', help=argparse.SUPPRESS)
|
||||||
parser.add_argument('--version', default="0", help=argparse.SUPPRESS)
|
parser.add_argument('--version', default="0", help=argparse.SUPPRESS)
|
||||||
|
parser.add_argument('--zim-path', default=None, help=argparse.SUPPRESS)
|
||||||
parser.add_argument('--content-version-code', type=int)
|
parser.add_argument('--content-version-code', type=int)
|
||||||
parser.add_argument('--package-name', default=None, help=argparse.SUPPRESS)
|
parser.add_argument('--package-name', default=None, help=argparse.SUPPRESS)
|
||||||
parser.add_argument('--google-api-key', help=argparse.SUPPRESS)
|
parser.add_argument('--google-api-key', help=argparse.SUPPRESS)
|
||||||
|
|
||||||
options = parser.parse_args()
|
options = parser.parse_args()
|
||||||
|
|
||||||
if not options.package_name or not options.zim_url:
|
if not options.package_name or not (options.zim_url or options.zim_path):
|
||||||
if not options.package_name:
|
if not options.package_name:
|
||||||
print("Try to get package name from info.json file")
|
print("Try to get package name from info.json file")
|
||||||
if not options.zim_url:
|
if not options.zim_url:
|
||||||
|
@ -102,8 +103,9 @@ def download_zim_file(zim_url, dest_dir=None):
|
||||||
return os.path.join(dest_dir, out_filename)
|
return os.path.join(dest_dir, out_filename)
|
||||||
|
|
||||||
|
|
||||||
def get_zim_size(zim_url, check_certificate=True):
|
def get_zim_size(*, zim_url=None, zim_path=None, check_certificate=True):
|
||||||
print("Try to get zim size")
|
print("Try to get zim size")
|
||||||
|
if not zim_path:
|
||||||
if not check_certificate:
|
if not check_certificate:
|
||||||
context = ssl.create_default_context()
|
context = ssl.create_default_context()
|
||||||
context.check_hostname = False
|
context.check_hostname = False
|
||||||
|
@ -121,19 +123,24 @@ def get_zim_size(zim_url, check_certificate=True):
|
||||||
print("No 'Content-Length' header in http answer from the server.\n"
|
print("No 'Content-Length' header in http answer from the server.\n"
|
||||||
"We need to download the zim file to get its size.")
|
"We need to download the zim file to get its size.")
|
||||||
zim_path = download_zim_file(zim_url, tempfile.gettempdir())
|
zim_path = download_zim_file(zim_url, tempfile.gettempdir())
|
||||||
|
|
||||||
size = os.path.getsize(zim_path)
|
size = os.path.getsize(zim_path)
|
||||||
print("Zim size is {}".format(size))
|
print("Zim size is {}".format(size))
|
||||||
return size
|
return size
|
||||||
|
|
||||||
|
|
||||||
def do_launch(options):
|
def do_launch(options):
|
||||||
zim_size = get_zim_size(options.zim_url, options.check_certificate)
|
if options.zim_path:
|
||||||
|
zim_size = get_zim_size(zim_path=options.zim_path)
|
||||||
|
else:
|
||||||
|
zim_size = get_zim_size(zim_url=options.zim_url,
|
||||||
|
check_certificate=options.check_certificate)
|
||||||
travis_launch_build('kiwix', 'kiwix-build', options, zim_size)
|
travis_launch_build('kiwix', 'kiwix-build', options, zim_size)
|
||||||
print("Travis build has been launch.")
|
print("Travis build has been launch.")
|
||||||
|
|
||||||
|
|
||||||
def do_publish(options):
|
def do_publish(options):
|
||||||
zim_path = download_zim_file(options.zim_url)
|
zim_path = options.zim_path or download_zim_file(options.zim_url)
|
||||||
googleService = Google(options)
|
googleService = Google(options)
|
||||||
with googleService.new_request():
|
with googleService.new_request():
|
||||||
versionCodes = []
|
versionCodes = []
|
||||||
|
|
Loading…
Reference in New Issue