deleted file mode 100644
--- a/testing/mozharness/mozharness/mozilla/googleplay.py
+++ /dev/null
@@ -1,40 +0,0 @@
-""" googleplay.py
-
- The way to get the API access is to
- 1) login in in the Google play admin
- 2) Settings
- 3) API Access
- 4) go in the Google Developers Console
- 5) Create "New client ID"
- or download the p12 key (it should remain
- super private)
- 6) Move the file in this directory with the name
- 'key.p12' or use the --credentials option
-"""
-
-import httplib2
-from oauth2client.service_account import ServiceAccountCredentials
-from apiclient.discovery import build
-from oauth2client import client
-
-
-# GooglePlayMixin {{{1
-class GooglePlayMixin(object):
-
- def connect_to_play(self):
- """ Connect to the google play interface
- """
-
- # Create an httplib2.Http object to handle our HTTP requests an
- # authorize it with the Credentials. Note that the first parameter,
- # service_account_name, is the Email address created for the Service
- # account. It must be the email address associated with the key that
- # was created.
- scope = 'https://www.googleapis.com/auth/androidpublisher'
- credentials = ServiceAccountCredentials.from_p12_keyfile(self.config["service_account"], self.config["google_play_credentials_file"], scopes=scope)
- http = httplib2.Http()
- http = credentials.authorize(http)
-
- service = build('androidpublisher', 'v2', http=http)
-
- return service
deleted file mode 100644
--- a/testing/mozharness/mozharness/mozilla/storel10n.py
+++ /dev/null
@@ -1,48 +0,0 @@
-""" storel10n.py
-
- Manage the localization of the Google play store
-
-"""
-
-from mozharness.base.log import LogMixin
-from mozharness.base.script import ScriptMixin
-
-
-class storel10n(ScriptMixin, LogMixin):
-
- l10n_api_url = "https://l10n.mozilla-community.org/stores_l10n/"
- all_locales_url = l10n_api_url + "api/google/listing/{channel}/"
- locale_url = l10n_api_url + "api/google/translation/{channel}/{locale}/"
- mapping_url = l10n_api_url + "api/google/localesmapping/?reverse"
-
- def __init__(self, config, log):
- self.config = config
- self.log_obj = log
- self.mappings = []
-
- def get_list_locales(self, package_name):
-
- """ Get all the translated locales supported by Google play
- So, locale unsupported by Google play won't be downloaded
- Idem for not translated locale
- """
- return self.load_json_url(self.all_locales_url.format(channel=package_name))
-
- def get_translation(self, package_name, locale):
- """ Get the translation for a locale
- """
- return self.load_json_url(self.locale_url.format(channel=package_name, locale=locale))
-
- def load_mapping(self):
- """ Download and load the locale mapping
- """
- self.mappings = self.load_json_url(self.mapping_url)
-
- def locale_mapping(self, locale):
- """ Google play and Mozilla don't have the exact locale code
- Translate them
- """
- if locale in self.mappings:
- return self.mappings[locale]
- else:
- return locale
deleted file mode 100644
--- a/testing/mozharness/scripts/get_apk.py
+++ /dev/null
@@ -1,275 +0,0 @@
-#!/usr/bin/env python
-
-import sys
-import os
-import re
-import signal
-
-# load modules from parent dir
-sys.path.insert(1, os.path.dirname(sys.path[0]))
-
-# import the guts
-from mozharness.base.script import BaseScript
-from mozharness.base.python import VirtualenvMixin
-from mozharness.base.script import ScriptMixin
-
-
-class GetAPK(BaseScript, VirtualenvMixin):
- all_actions = [
- 'create-virtualenv',
- 'download-apk'
- ]
-
- default_actions = [
- 'create-virtualenv',
- 'test'
- ]
-
- config_options = [
- [["--build"], {
- "dest": "build",
- "help": "Specify build number (default 1)",
- "default": "1"
- }],
- [["--version"], {
- "dest": "version",
- "help": "Specify version number to download (e.g. 23.0b7)",
- "default": "None"
- }],
- [["--latest-nightly"], {
- "dest": "latest_nightly",
- "help": "Download the latest nightly version",
- "action": "store_true",
- "default": False
- }],
- [["--latest-aurora"], {
- "dest": "latest_aurora",
- "help": "Download the latest aurora version",
- "action": "store_true",
- "default": False
- }],
- [["--arch"], {
- "dest": "arch",
- "help": "Specify which architecture to get the apk for",
- "default": "all"
- }],
- [["--locale"], {
- "dest": "locale",
- "help": "Specify which locale to get the apk for",
- "default": "multi"
- }],
- [["--clean"], {
- "dest": "clean",
- "help": "Use this option to clean the download directory",
- "action": "store_true",
- "default": False
- }]
- ]
-
- arch_values = ["arm", "x86"]
- multi_api_archs = ["arm"]
- multi_apis = ["api-15"] # v11 has been dropped in fx 46 (1155801)
- # v9 has been dropped in fx 48 (1220184)
-
- download_dir = "apk-download"
-
- apk_ext = ".apk"
- checksums_ext = ".checksums"
- android_prefix = "android-"
-
- base_url = "https://ftp.mozilla.org/pub/mobile"
- json_version_url = "https://product-details.mozilla.org/1.0/firefox_versions.json"
-
- # Cleanup half downloaded files on Ctrl+C
- def signal_handler(self, signal, frame):
- print("You pressed Ctrl+C!")
- self.cleanup()
- sys.exit(1)
-
- def cleanup(self):
- ScriptMixin.rmtree(self, self.download_dir)
- self.info("Download directory cleaned")
-
- def __init__(self, require_config_file=False, config={},
- all_actions=all_actions,
- default_actions=default_actions):
- default_config = {
- # the path inside the work_dir ('build') of where we will install the env.
- # pretty sure it's the default and not needed.
- 'virtualenv_path': 'venv',
- }
-
- default_config.update(config)
-
- BaseScript.__init__(
- self,
- config_options=self.config_options,
- require_config_file=require_config_file,
- config=default_config,
- all_actions=all_actions,
- )
-
- # Gets called once download is complete
- def download_complete(self, apk_file, checksum_file):
- self.info(apk_file + " has been downloaded successfully")
- ScriptMixin.rmtree(self, checksum_file)
-
- # Called if download fails due to 404 error or some other connection failure
- def download_error(self):
- self.cleanup()
- self.fatal("Download failed!")
-
- # Check the given values are correct
- def check_argument(self):
- if self.config["clean"]:
- self.cleanup()
- if self.config["version"] == "None":
- if self.config["clean"]:
- sys.exit(0)
- if self.config["version"] != "None" and (self.config["latest_nightly"] or self.config["latest_aurora"]):
- self.fatal("Cannot set a version and --latest-nightly or --latest-aurora")
-
- if self.config["arch"] not in self.arch_values and not self.config["arch"] == "all":
- error = self.config["arch"] + " is not a valid arch. " \
- "Try one of the following:"+os.linesep
- for arch in self.arch_values:
- error += arch + os.linesep
- error += "Or don't use the --arch option to download all the archs"
- self.fatal(error)
-
- if self.config["latest_nightly"] and self.config["latest_aurora"]:
- self.fatal("Conflicting options. Cannot use --latest-nightly with --latest-aurora")
-
- # Checksum check the APK
- def check_apk(self, apk_file, checksum_file):
- self.info("The checksum for the APK is being checked....")
- checksum = ScriptMixin.read_from_file(self, checksum_file, False)
- checksum = re.sub("\s(.*)", "", checksum.splitlines()[0])
-
- apk_checksum = self.file_sha512sum(apk_file)
-
- if checksum == apk_checksum:
- self.info("APK checksum check succeeded!")
- self.download_complete(apk_file, checksum_file)
- else:
- ScriptMixin.rmtree(self, self.download_dir)
- self.fatal("Downloading " + apk_file + " failed!")
-
- # Helper functions
- def generate_url(self, version, build, locale, api_suffix, arch_file):
- if self.config["latest_nightly"] or self.config["latest_aurora"]:
- code = "central" if self.config["latest_nightly"] else "aurora"
- return ("%s/nightly/latest-mozilla-%s-android-%s/fennec-%s.%s.android-%s") % (self.base_url, code, api_suffix, version, locale, arch_file)
-
- return ("%s/candidates/%s-candidates/build%s/%s%s/%s/fennec-%s.%s.%s%s") % (self.base_url, version, build, self.android_prefix, api_suffix, locale, version, locale, self.android_prefix, arch_file)
-
-
- def get_api_suffix(self, arch):
- if arch in self.multi_api_archs:
- return self.multi_apis
- else:
- return [arch]
-
- def get_arch_file(self, arch):
- if arch == "x86":
- # the filename contains i386 instead of x86
- return "i386"
- else:
- return arch
-
- def get_common_file_name(self, version, locale):
- return "fennec-" + version + "." + locale + "." + self.android_prefix
-
- # Function that actually downloads the file
- def download(self, version, build, arch, locale):
- ScriptMixin.mkdir_p(self, self.download_dir)
-
- common_filename = self.get_common_file_name(version, locale)
- arch_file = self.get_arch_file(arch)
-
- for api_suffix in self.get_api_suffix(arch):
- url = self.generate_url(version, build, locale, api_suffix, arch_file)
- apk_url = url + self.apk_ext
- checksum_url = url + self.checksums_ext
- if arch in self.multi_api_archs:
- filename = common_filename + arch_file + "-" + api_suffix
- else:
- filename = common_filename + arch_file
-
- filename_apk = os.path.join(self.download_dir, filename + self.apk_ext)
- filename_checksums = os.path.join(self.download_dir, filename + self.checksums_ext)
-
- # Download the APK
- retry_config = {'attempts': 1, 'cleanup': self.download_error}
- ScriptMixin.download_file(self, apk_url, filename_apk, retry_config=retry_config)
-
- # Download the checksum of the APK
- retry_config = {'attempts': 1, 'cleanup': self.download_error}
- ScriptMixin.download_file(self, checksum_url, filename_checksums, retry_config=retry_config)
-
- self.check_apk(filename_apk, filename_checksums)
-
- def get_version_name(self):
- if self.config["latest_nightly"] or self.config["latest_aurora"]:
- json = self.load_json_url(self.json_version_url)
- version_code = json['FIREFOX_NIGHTLY'] if self.config["latest_nightly"] else json['FIREFOX_AURORA']
- return version_code
- return self.config["version"]
-
- # Download all the archs if none is given
- def download_all(self, version, build, locale):
- for arch in self.arch_values:
- self.download(version, build, arch, locale)
-
- # Download apk initial action
- def download_apk(self):
- self.check_argument()
- version = self.get_version_name()
- arch = self.config["arch"]
- build = str(self.config["build"])
- locale = self.config["locale"]
-
- self.info("Downloading version " + version + " build #" + build
- + " for arch " + arch + " (locale " + locale + ")")
- if arch == "all":
- self.download_all(version, build, locale)
- else:
- self.download(version, build, arch, locale)
-
- # Test the helper, cleanup and check functions
- def test(self):
- ScriptMixin.mkdir_p(self, self.download_dir)
- testfile = os.path.join(self.download_dir, "testfile")
- testchecksums = os.path.join(self.download_dir, "testchecksums")
- ScriptMixin.write_to_file(self, testfile, "This is a test file!")
- ScriptMixin.write_to_file(self, testchecksums, self.file_sha512sum(testfile))
- self.check_apk(testfile, testchecksums)
- self.download_complete(testfile, testchecksums)
- if os.path.isfile(testchecksums):
- self.fatal("download_complete test failed!")
-
- self.cleanup()
- if os.path.isdir(self.download_dir):
- self.fatal("cleanup test failed")
-
- url = self.generate_url("43.0", "2", "multi", "x86", "i386")
- correcturl = "https://ftp.mozilla.org/pub/mozilla.org/mobile/candidates/43.0-candidates/build2/"\
- + self.android_prefix + "x86/multi/fennec-43.0.multi." + self.android_prefix + "i386"
-
- if not url == correcturl:
- self.fatal(("get_url test failed! %s != %s") % (url, correcturl))
-
- if not self.get_api_suffix(self.multi_api_archs[0]) == self.multi_apis:
- self.fatal("get_api_suffix test failed!")
-
- if not self.get_arch_file("x86") == "i386":
- self.fatal("get_arch_file test failed!")
-
- if not self.get_common_file_name("43.0", "multi") == "fennec-43.0.multi." + self.android_prefix:
- self.fatal("get_common_file_name test failed!")
-
-# main {{{1
-if __name__ == '__main__':
- myScript = GetAPK()
- signal.signal(signal.SIGINT, myScript.signal_handler)
- myScript.run_and_exit()
deleted file mode 100644
--- a/testing/mozharness/scripts/push_apk.py
+++ /dev/null
@@ -1,239 +0,0 @@
-#!/usr/bin/env python
-""" push_apk.py
-
- Upload the apk of a Firefox app on Google play
- Example for a beta upload:
- $ python push_apk.py --package-name org.mozilla.firefox_beta --service-account foo@developer.gserviceaccount.com --credentials key.p12 --apk-x86=/path/to/fennec-XX.0bY.multi.android-i386.apk --apk-armv7-v15=/path/to/fennec-XX.0bY.multi.android-arm-v15.apk --track production --push_apk
-
- Debian/Ubuntu dependencies: python-googleapi python-oauth2client
-"""
-import sys
-import os
-
-from oauth2client import client
-
-# load modules from parent dir
-sys.path.insert(1, os.path.dirname(sys.path[0]))
-
-# import the guts
-from mozharness.base.script import BaseScript
-from mozharness.mozilla.googleplay import GooglePlayMixin
-from mozharness.mozilla.storel10n import storel10n
-from mozharness.base.python import VirtualenvMixin
-
-
-class PushAPK(BaseScript, GooglePlayMixin, VirtualenvMixin):
- all_actions = [
- 'create-virtualenv',
- 'push_apk',
- 'test',
- ]
-
- default_actions = [
- 'create-virtualenv',
- 'test',
- ]
- config_options = [
- [["--track"], {
- "dest": "track",
- "help": "Track on which to upload "
- "(production, beta, alpha, rollout)",
- # We are not using alpha but we default to it to avoid mistake
- "default": "alpha"
- }],
- [["--service-account"], {
- "dest": "service_account",
- "help": "The service account email",
- }],
- [["--credentials"], {
- "dest": "google_play_credentials_file",
- "help": "The p12 authentication file",
- "default": "key.p12"
- }],
- [["--package-name"], {
- "dest": "package_name",
- "help": "The Google play name of the app",
- }],
- [["--apk-x86"], {
- "dest": "apk_file_x86",
- "help": "The path to the x86 APK file",
- }],
- [["--apk-armv7-v15"], {
- "dest": "apk_file_armv7_v15",
- "help": "The path to the ARM v7 API v15 APK file",
- }],
- [["--rollout-percentage"], {
- "dest": "rollout_percentage",
- "help": "The rollout percentage (update percentage)",
- "default": "None"
- }],
-
- ]
-
- # Google play has currently 3 tracks. Rollout deploys
- # to a limited percentage of users
- track_values = ("production", "beta", "alpha", "rollout")
-
- # We have 3 apps. Make sure that their names are correct
- package_name_values = {"org.mozilla.fennec_aurora": "aurora",
- "org.mozilla.firefox_beta": "beta",
- "org.mozilla.firefox": "release"}
-
- def __init__(self, require_config_file=False, config={},
- all_actions=all_actions,
- default_actions=default_actions):
-
- # Default configuration
- default_config = {
- 'debug_build': False,
- 'pip_index': True,
- # this will pip install it automajically when we call the create-virtualenv action
- 'virtualenv_modules': ['google-api-python-client'],
- "find_links": [ # so mozharness knows where to look for the package
- "http://pypi.pvt.build.mozilla.org/pub",
- "http://pypi.pub.build.mozilla.org/pub",
- ],
- # the path inside the work_dir ('build') of where we will install the env.
- # pretty sure it's the default and not needed.
- 'virtualenv_path': 'venv',
- }
- default_config.update(config)
-
- BaseScript.__init__(
- self,
- config_options=self.config_options,
- require_config_file=require_config_file,
- config=default_config,
- all_actions=all_actions,
- default_actions=default_actions,
- )
-
- self.translationMgmt = storel10n(config, {})
-
- def check_argument(self):
- """ Check that the given values are correct,
- files exists, etc
- """
- if "package_name" not in self.config:
- self.fatal("--package-name is mandatory")
-
- if self.config['track'] not in self.track_values:
- self.fatal("Unknown track value " + self.config['track'])
-
- if self.config['package_name'] not in self.package_name_values:
- self.fatal("Unknown package name value " +
- self.config['package_name'])
-
- if self.config['track'] == "rollout" and self.config["rollout_percentage"] is "None":
- self.fatal("When using track='rollout', --rollout-percentage must be provided too")
-
- if self.config["rollout_percentage"] is not "None":
- self.percentage = float(self.config["rollout_percentage"])
- if self.percentage < 0 or self.percentage > 100:
- self.fatal("Percentage should be between 0 and 100")
-
- if not os.path.isfile(self.config['apk_file_x86']):
- self.fatal("Could not find " + self.config['apk_file_x86'])
-
- if not os.path.isfile(self.config['apk_file_armv7_v15']):
- self.fatal("Could not find " + self.config['apk_file_armv7_v15'])
-
- if not os.path.isfile(self.config['google_play_credentials_file']):
- self.fatal("Could not find " + self.config['google_play_credentials_file'])
-
- def upload_apks(self, service, apk_files):
- """ Upload the APK to google play
-
- service -- The session to Google play
- apk_files -- The files
- """
- edit_request = service.edits().insert(body={},
- packageName=self.config['package_name'])
- package_code = self.package_name_values[self.config['package_name']]
- result = edit_request.execute()
- edit_id = result['id']
- # Store all the versions to set the tracks (needs to happen
- # at the same time
- versions = []
-
- # Retrieve the mapping
- self.translationMgmt.load_mapping()
-
- # For each files, upload it
- for apk_file in apk_files:
- try:
- # Upload the file
- apk_response = service.edits().apks().upload(
- editId=edit_id,
- packageName=self.config['package_name'],
- media_body=apk_file).execute()
- self.log('Version code %d has been uploaded. '
- 'Filename "%s" edit_id %s' %
- (apk_response['versionCode'], apk_file, edit_id))
-
- versions.append(apk_response['versionCode'])
-
- if 'aurora' in self.config['package_name']:
- self.warning('Aurora is not supported by store_l10n. Skipping what\'s new.')
- else:
- self._push_whats_new(package_code, service, edit_id, apk_response)
-
- except client.AccessTokenRefreshError:
- self.log('The credentials have been revoked or expired,'
- 'please re-run the application to re-authorize')
-
- upload_body = {u'versionCodes': versions}
- if self.config["rollout_percentage"] is not "None":
- upload_body[u'userFraction'] = self.percentage/100
-
- # Set the track for all apk
- service.edits().tracks().update(
- editId=edit_id,
- track=self.config['track'],
- packageName=self.config['package_name'],
- body=upload_body).execute()
- self.log('Application "%s" set to track "%s" for versions %s' %
- (self.config['package_name'], self.config['track'], versions))
-
- # Commit our changes
- commit_request = service.edits().commit(
- editId=edit_id, packageName=self.config['package_name']).execute()
- self.log('Edit "%s" has been committed' % (commit_request['id']))
-
- def _push_whats_new(self, package_code, service, edit_id, apk_response):
- locales = self.translationMgmt.get_list_locales(package_code)
- locales.append(u'en-US')
-
- for locale in locales:
- translation = self.translationMgmt.get_translation(package_code, locale)
- whatsnew = translation.get("whatsnew")
- if locale == "en-GB":
- self.log("Ignoring en-GB as locale")
- continue
- locale = self.translationMgmt.locale_mapping(locale)
- self.log('Locale "%s" what\'s new has been updated to "%s"'
- % (locale, whatsnew))
-
- listing_response = service.edits().apklistings().update(
- editId=edit_id, packageName=self.config['package_name'], language=locale,
- apkVersionCode=apk_response['versionCode'],
- body={'recentChanges': whatsnew}).execute()
-
- self.log('Listing for language %s was updated.' % listing_response['language'])
-
- def push_apk(self):
- """ Upload the APK files """
- self.check_argument()
- service = self.connect_to_play()
- apks = [self.config['apk_file_armv7_v15'], self.config['apk_file_x86']]
- self.upload_apks(service, apks)
-
- def test(self):
- """ Test if the connexion can be done """
- self.check_argument()
- self.connect_to_play()
-
-# main {{{1
-if __name__ == '__main__':
- myScript = PushAPK()
- myScript.run_and_exit()
deleted file mode 100644
--- a/testing/mozharness/scripts/update_apk_description.py
+++ /dev/null
@@ -1,224 +0,0 @@
-#!/usr/bin/env python
-""" update_apk_description.py
-
- Update the descriptions of an application (multilang)
- Example of beta update:
- $ python update_apk_description.py --service-account foo@developer.gserviceaccount.com --package-name org.mozilla.firefox --credentials key.p12 --update-apk-description
-"""
-import sys
-import os
-import urllib2
-import json
-
-from oauth2client import client
-
-# load modules from parent dir
-sys.path.insert(1, os.path.dirname(sys.path[0]))
-
-# import the guts
-from mozharness.base.script import BaseScript
-from mozharness.mozilla.googleplay import GooglePlayMixin
-from mozharness.mozilla.storel10n import storel10n
-from mozharness.base.python import VirtualenvMixin
-
-
-class UpdateDescriptionAPK(BaseScript, GooglePlayMixin, VirtualenvMixin):
- all_actions = [
- 'create-virtualenv',
- 'update-apk-description',
- 'test',
- ]
-
- default_actions = [
- 'create-virtualenv',
- 'test',
- ]
-
- config_options = [
- [["--service-account"], {
- "dest": "service_account",
- "help": "The service account email",
- }],
- [["--credentials"], {
- "dest": "google_play_credentials_file",
- "help": "The p12 authentication file",
- "default": "key.p12"
- }],
- [["--package-name"], {
- "dest": "package_name",
- "help": "The Google play name of the app",
- }],
- [["--l10n-api-url"], {
- "dest": "l10n_api_url",
- "help": "The L10N URL",
- "default": "https://l10n.mozilla-community.org/stores_l10n/"
- }],
- [["--force-locale"], {
- "dest": "force_locale",
- "help": "Force a specific locale (instead of all)",
- }],
- ]
-
- # We have 3 apps. Make sure that their names are correct
- package_name_values = {"org.mozilla.fennec_aurora": "aurora",
- "org.mozilla.firefox_beta": "beta",
- "org.mozilla.firefox": "release"}
-
- def __init__(self, require_config_file=False, config={},
- all_actions=all_actions,
- default_actions=default_actions):
-
- # Default configuration
- default_config = {
- 'debug_build': False,
- 'pip_index': True,
- # this will pip install it automajically when we call the
- # create-virtualenv action
- 'virtualenv_modules': ['google-api-python-client'],
- "find_links": [
- "http://pypi.pvt.build.mozilla.org/pub",
- "http://pypi.pub.build.mozilla.org/pub",
- ],
- 'virtualenv_path': 'venv',
- }
- default_config.update(config)
-
- BaseScript.__init__(
- self,
- config_options=self.config_options,
- require_config_file=require_config_file,
- config=default_config,
- all_actions=all_actions,
- default_actions=default_actions,
- )
-
- self.all_locales_url = self.config['l10n_api_url'] + "api/?done&channel={channel}"
- self.locale_url = self.config['l10n_api_url'] + "api/?locale={locale}&channel={channel}"
- self.mapping_url = self.config['l10n_api_url'] + "api/?locale_mapping&reverse"
- self.translationMgmt = storel10n(config, {})
-
- def check_argument(self):
- """ Check that the given values are correct,
- files exists, etc
- """
- if self.config['package_name'] not in self.package_name_values:
- self.fatal("Unknown package name value " +
- self.config['package_name'])
-
- if not os.path.isfile(self.config['google_play_credentials_file']):
- self.fatal("Could not find " + self.config['google_play_credentials_file'])
-
-
- def update_desc(self, service, package_name):
- """ Update the desc on google play
-
- service -- The session to Google play
- package_name -- The name of the package
- locale -- The locale to update
- description -- The new description
- """
-
- edit_request = service.edits().insert(body={},
- packageName=package_name)
- result = edit_request.execute()
- edit_id = result['id']
-
- # Retrieve the mapping
- self.translationMgmt.load_mapping()
- package_code = self.package_name_values[self.config['package_name']]
-
- if self.config.get("force_locale"):
- # The user forced a locale, don't need to retrieve the full list
- locales = [self.config.get("force_locale")]
- else:
- # Get all the locales from the web interface
- locales = self.translationMgmt.get_list_locales(package_code)
- nb_locales = 0
- for locale in locales:
- translation = self.translationMgmt.get_translation(package_code, locale)
- title = translation.get("title")
- short_desc = translation.get("short_desc")
- long_desc = translation.get("long_desc")
-
- # Google play expects some locales codes (de-DE instead of de)
- locale = self.translationMgmt.locale_mapping(locale)
-
- try:
- self.log("Updating " + package_code + " for '" + locale +
- "' / title: '" + title + "', short_desc: '" +
- short_desc[0:20] + "'..., long_desc: '" +
- long_desc[0:20] + "...'")
- service.edits().listings().update(
- editId=edit_id, packageName=package_name, language=locale,
- body={'fullDescription': long_desc,
- 'shortDescription': short_desc,
- 'title': title}).execute()
- nb_locales += 1
- except client.AccessTokenRefreshError:
- self.log('The credentials have been revoked or expired,'
- 'please re-run the application to re-authorize')
-
- # Commit our changes
- commit_request = service.edits().commit(
- editId=edit_id, packageName=package_name).execute()
- self.log('Edit "%s" has been committed. %d locale(s) updated.' % (commit_request['id'], nb_locales))
-
- def update_apk_description(self):
- """ Update the description """
- self.check_argument()
- service = self.connect_to_play()
- self.update_desc(service, self.config['package_name'])
-
- def test(self):
- """
- Test if the connexion can be done and if the various method
- works as expected
- """
- self.check_argument()
- self.connect_to_play()
- package_name = 'org.mozilla.fennec_aurora'
- locales = self.translationMgmt.get_list_locales(package_name)
- if not locales:
- self.fatal("get_list_locales() failed")
-
- self.translationMgmt.get_mapping()
- if not self.mappings:
- self.fatal("get_mapping() failed")
-
- loca = self.translationMgmt.locale_mapping("fr")
- if loca != "fr-FR":
- self.fatal("fr locale_mapping failed")
- loca = self.translationMgmt.locale_mapping("hr")
- if loca != "hr":
- self.fatal("hr locale_mapping failed")
-
- translation = self.translationMgmt.get_translation(package_name, 'cs')
- if len(translation.get('title')) < 5:
- self.fatal("get_translation title failed for the 'cs' locale")
- if len(translation.get('short_desc')) < 5:
- self.fatal("get_translation short_desc failed for the 'cs' locale")
- if len(translation.get('long_desc')) < 5:
- self.fatal("get_translation long_desc failed for the 'cs' locale")
-
- package_name = "org.mozilla.firefox_beta"
- translation = self.translationMgmt.get_translation(package_name, 'fr')
- if len(translation.get('title')) < 5:
- self.fatal("get_translation title failed for the 'fr' locale")
- if len(translation.get('short_desc')) < 5:
- self.fatal("get_translation short_desc failed for the 'fr' locale")
- if len(translation.get('long_desc')) < 5:
- self.fatal("get_translation long_desc failed for the 'fr' locale")
-
- package_name = "org.mozilla.firefox"
- translation = self.translationMgmt.get_translation(package_name, 'de')
- if len(translation.get('title')) < 5:
- self.fatal("get_translation title failed for the 'de' locale")
- if len(translation.get('short_desc')) < 5:
- self.fatal("get_translation short_desc failed for the 'de' locale")
- if len(translation.get('long_desc')) < 5:
- self.fatal("get_translation long_desc failed for the 'de' locale")
-
-# main {{{1
-if __name__ == '__main__':
- myScript = UpdateDescriptionAPK()
- myScript.run_and_exit()