Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug 1905093 - set googleapiclient retries to 3 #260

Merged
merged 2 commits into from
Jul 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 13 additions & 10 deletions mozapkpublisher/common/store.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@

logger = logging.getLogger(__name__)

NUM_RETRIES = 3


def add_general_google_play_arguments(parser):
parser.add_argument('--credentials', dest='google_play_credentials_filename',
Expand All @@ -32,7 +34,7 @@ class _ExecuteDummy:
def __init__(self, return_value):
self._return_value = return_value

def execute(self):
def execute(self, **kwargs):
return self._return_value


Expand Down Expand Up @@ -70,7 +72,7 @@ def get_track_status(self, track):
editId=self._edit_id,
track=track,
packageName=self._package_name
).execute()
).execute(num_retries=NUM_RETRIES)
logger.debug('Track "{}" has status: {}'.format(track, response))
return response

Expand All @@ -84,7 +86,7 @@ def upload_apk(self, apk):
media_body=apk_path,
# Seems like mime type need not be specified for apk files:
# media_mime_type='application/octet-stream',
).execute()
).execute(num_retries=NUM_RETRIES)
logger.info('"{}" uploaded'.format(apk_path))
logger.debug('Upload response: {}'.format(response))
except HttpError as e:
Expand Down Expand Up @@ -116,7 +118,7 @@ def upload_aab(self, aab):
packageName=self._package_name,
media_body=aab_path,
media_mime_type='application/octet-stream',
).execute()
).execute(num_retries=NUM_RETRIES)
logger.info('"{}" uploaded'.format(aab_path))
logger.debug('Upload response: {}'.format(response))
except Exception:
Expand Down Expand Up @@ -158,7 +160,7 @@ def _update_track(self, track, version_codes, rollout_percentage=None):

response = self._edit_resource.tracks().update(
editId=self._edit_id, track=track, packageName=self._package_name, body=body
).execute()
).execute(num_retries=NUM_RETRIES)
logger.info('Track "{}" updated with: {}'.format(track, body))
logger.debug('Track update response: {}'.format(response))

Expand All @@ -170,15 +172,15 @@ def update_listings(self, language, title, full_description, short_description):
}
response = self._edit_resource.listings().update(
editId=self._edit_id, packageName=self._package_name, language=language, body=body
).execute()
).execute(num_retries=NUM_RETRIES)
logger.info(u'Listing for language "{}" has been updated with: {}'.format(language, body))
logger.debug(u'Listing response: {}'.format(response))

def update_whats_new(self, language, apk_version_code, whats_new):
response = self._edit_resource.apklistings().update(
editId=self._edit_id, packageName=self._package_name, language=language,
apkVersionCode=apk_version_code, body={'recentChanges': whats_new}
).execute()
).execute(num_retries=NUM_RETRIES)
logger.info(u'What\'s new listing for ("{}", "{}") has been updated to: "{}"'.format(
language, apk_version_code, whats_new
))
Expand All @@ -188,11 +190,11 @@ def update_whats_new(self, language, apk_version_code, whats_new):
@contextmanager
def transaction(credentials_file_name, package_name, *, contact_server, dry_run):
edit_resource = _create_google_edit_resource(contact_server, credentials_file_name)
edit_id = edit_resource.insert(body={}, packageName=package_name).execute()['id']
edit_id = edit_resource.insert(body={}, packageName=package_name).execute(num_retries=NUM_RETRIES)['id']
google_play = GooglePlayEdit(edit_resource, edit_id, package_name)
yield google_play
if not dry_run:
edit_resource.commit(editId=edit_id, packageName=package_name).execute()
edit_resource.commit(editId=edit_id, packageName=package_name).execute(num_retries=NUM_RETRIES)
logger.info('Changes committed')
logger.debug('edit_id "{}" for "{}" has been committed'.format(edit_id, package_name))
else:
Expand All @@ -209,7 +211,8 @@ def _create_google_edit_resource(contact_google_play, credentials_file_name):

service = build(serviceName='androidpublisher', version='v3',
credentials=credentials,
cache_discovery=False)
cache_discovery=False,
num_retries=NUM_RETRIES)

return service.edits()
else:
Expand Down
Loading