--- a/python/mozboot/mozboot/android.py
+++ b/python/mozboot/mozboot/android.py
@@ -130,17 +130,17 @@ def install_mobile_android_sdk_or_ndk(ur
finally:
os.chdir(old_path)
def get_paths(os_name):
mozbuild_path = os.environ.get('MOZBUILD_STATE_PATH',
os.path.expanduser(os.path.join('~', '.mozbuild')))
sdk_path = os.environ.get('ANDROID_SDK_HOME',
- os.path.join(mozbuild_path, 'android-sdk-{}'.format(os_name)))
+ os.path.join(mozbuild_path, 'android-sdk-{0}'.format(os_name)))
ndk_path = os.environ.get('ANDROID_NDK_HOME',
os.path.join(mozbuild_path, 'android-ndk-r11c'))
return (mozbuild_path, sdk_path, ndk_path)
def ensure_dir(dir):
'''Ensures the given directory exists'''
if dir and not os.path.exists(dir):
@@ -161,37 +161,37 @@ def ensure_android(os_name, artifact_mod
`os_name` can be 'linux' or 'macosx'.
'''
# The user may have an external Android SDK (in which case we
# save them a lengthy download), or they may have already
# completed the download. We unpack to
# ~/.mozbuild/{android-sdk-$OS_NAME, android-ndk-$VER}.
mozbuild_path, sdk_path, ndk_path = get_paths(os_name)
os_tag = 'darwin' if os_name == 'macosx' else os_name
- sdk_url = 'https://dl.google.com/android/repository/sdk-tools-{}-3859397.zip'.format(os_tag)
+ sdk_url = 'https://dl.google.com/android/repository/sdk-tools-{0}-3859397.zip'.format(os_tag)
ndk_url = android_ndk_url(os_name)
ensure_android_sdk_and_ndk(mozbuild_path, os_name,
sdk_path=sdk_path, sdk_url=sdk_url,
ndk_path=ndk_path, ndk_url=ndk_url,
artifact_mode=artifact_mode)
if no_interactive:
# Cribbed from observation and https://stackoverflow.com/a/38381577.
- path = os.path.join(mozbuild_path, 'android-sdk-{}'.format(os_name), 'licenses')
+ path = os.path.join(mozbuild_path, 'android-sdk-{0}'.format(os_name), 'licenses')
ensure_dir(path)
licenses = {
'android-sdk-license': '8933bad161af4178b1185d1a37fbf41ea5269c55',
'android-sdk-preview-license': '84831b9409646a918e30573bab4c9c91346d8abd',
}
for license, tag in licenses.items():
lname = os.path.join(path, license)
if not os.path.isfile(lname):
- open(lname, 'w').write('\n{}\n'.format(tag))
+ open(lname, 'w').write('\n{0}\n'.format(tag))
# We expect the |sdkmanager| tool to be at
# ~/.mozbuild/android-sdk-$OS_NAME/tools/bin/sdkmanager.
sdkmanager_tool = os.path.join(sdk_path, 'tools', 'bin', 'sdkmanager')
ensure_android_packages(sdkmanager_tool=sdkmanager_tool)
@@ -220,31 +220,31 @@ def ensure_android_sdk_and_ndk(mozbuild_
print(ANDROID_SDK_EXISTS % sdk_path)
elif os.path.isdir(sdk_path):
raise NotImplementedError(ANDROID_SDK_TOO_OLD % sdk_path)
else:
# The SDK archive used to include a top-level
# android-sdk-$OS_NAME directory; it no longer does so. We
# preserve the old convention to smooth detecting existing SDK
# installations.
- install_mobile_android_sdk_or_ndk(sdk_url, os.path.join(mozbuild_path, 'android-sdk-{}'.format(os_name)))
+ install_mobile_android_sdk_or_ndk(sdk_url, os.path.join(mozbuild_path, 'android-sdk-{0}'.format(os_name)))
def ensure_android_packages(sdkmanager_tool, packages=None):
'''
Use the given sdkmanager tool (like 'sdkmanager') to install required
Android packages.
'''
# This tries to install all the required Android packages. The user
# may be prompted to agree to the Android license.
package_file_name = os.path.abspath(os.path.join(os.path.dirname(__file__), 'android-packages.txt'))
print(INSTALLING_ANDROID_PACKAGES % open(package_file_name, 'rt').read())
subprocess.check_call([sdkmanager_tool,
- '--package_file={}'.format(package_file_name)])
+ '--package_file={0}'.format(package_file_name)])
def suggest_mozconfig(os_name, artifact_mode=False):
_mozbuild_path, sdk_path, ndk_path = get_paths(os_name)
if artifact_mode:
print(MOBILE_ANDROID_ARTIFACT_MODE_MOZCONFIG_TEMPLATE % (sdk_path))
else:
print(MOBILE_ANDROID_MOZCONFIG_TEMPLATE % (sdk_path, ndk_path))
@@ -283,17 +283,17 @@ def main(argv):
if platform.system() == 'Darwin':
os_name = 'macosx'
elif platform.system() == 'Linux':
os_name = 'linux'
elif platform.system() == 'Windows':
os_name = 'windows'
else:
raise NotImplementedError("We don't support bootstrapping the Android SDK (or Android NDK) "
- "on {} yet!".format(platform.system()))
+ "on {0} yet!".format(platform.system()))
ensure_android(os_name, artifact_mode=options.artifact_mode, no_interactive=options.no_interactive)
suggest_mozconfig(os_name, options.artifact_mode)
return 0
if __name__ == '__main__':