Relative/Remote paths work with upload-apk.py #453

This commit is contained in:
Isaac Hutt 2017-02-10 11:38:42 -08:00
parent 09bfffd9e5
commit b3be115ada
2 changed files with 18 additions and 1 deletions

View File

@ -1,7 +1,7 @@
{
"app_name": "PhET",
"package": "org.kiwix.kiwixcustomphet",
"version_name": "2017-01",
"version_name": "2017-02",
"version_code": "3",
"zim_file": "content.zim",
"embed_zim": false,

View File

@ -52,6 +52,8 @@ def syscall(args, shell=False, with_print=True):
args = ' '.join(args)
call(args, shell=shell)
def move_to_current_folder():
os.chdir(CURRENT_PATH)
def get_remote_content(url):
''' file descriptor from remote file using GET '''
@ -156,6 +158,21 @@ def upload_to_play_store(jsdata, channel=None):
apk_file = os.path.join(CURRENT_PATH, 'build', 'outputs', 'apk',
'{}-{}.apk'.format(package_name, version_name))
json_file_dir = os.path.abspath(os.path.dirname(jspath))
# download remote zim file
if is_remote_path(jsdata.get('zim_file')):
zimfile_url = jsdata.get('zim_file')
remote_filename = get_remote_file_name(zimfile_url)
local_file_path = os.path.join(json_file_dir, remote_filename)
download_remote_file(zimfile_url, local_file_path)
jsdata.update({'zim_file': local_file_path})
# update relative paths to absolute
os.chdir(json_file_dir)
jsdata.update({'zim_file': os.path.abspath(jsdata.get('zim_file'))})
move_to_current_folder()
if not jsdata.get('embed_zim', False):
comp_file = tempfile.NamedTemporaryFile(suffix='.a').name
copy_to(jsdata['zim_file'], comp_file)