Commit 2c8ed737 authored by dtseng's avatar dtseng Committed by Commit bot

Make a few fixes to the ChromeVox webstore upload script.

TEST=run the script:
enter 'u' to upload, login and verify that uploading is successful.
Back at the prompt, enter 'p' to publish publically. Verify ChromeVox updates.

Review URL: https://codereview.chromium.org/515723005

Cr-Commit-Position: refs/heads/master@{#293784}
parent 443eb4ca
......@@ -55,6 +55,7 @@ def GetAuthCode():
print 'Navigating to %s' % auth_url
webbrowser.open(auth_url)
httpd.handle_request()
httpd.server_close()
return httpd.code
def GetOauthToken(code, client_secret):
......@@ -90,7 +91,7 @@ def SendPostCommand(command, client_secret, header_additions = {}, body=None):
headers = GetPopulatedHeader(client_secret)
headers = dict(headers.items() + header_additions.items())
conn = httplib.HTTPSConnection(API_ENDPOINT_DOMAIN)
conn.request('PUT', command, body, headers)
conn.request('POST', command, body, headers)
return conn.getresponse()
def GetUploadStatus(client_secret):
......
......@@ -32,7 +32,7 @@ def CreateOptionParser():
parser.usage = '%prog <extension_path> <output_path> <client_secret'
return parser
def MakeManifestEdits(root, old):
def MakeManifestEdits(root, old, new_file):
'''Customize a manifest for the webstore.
Args:
......@@ -40,16 +40,15 @@ def MakeManifestEdits(root, old):
old: A json file.
new_file: a temporary file to place the manifest in.
Returns:
File of the new manifest.
'''
new_file = tempfile.NamedTemporaryFile()
new = new_file.name
with open(os.path.join(root, old)) as old_file:
new_contents = json.loads(old_file.read())
new_contents.pop('key', '')
new_file.write(json.dumps(new_contents))
return new_file
new_file.file.write(json.dumps(new_contents))
def RunInteractivePrompt(client_secret, output_path):
input = ''
......@@ -62,13 +61,18 @@ def RunInteractivePrompt(client_secret, output_path):
input = raw_input('Please select an option: ')
input = input.strip()
if input == 'g':
chromevox_webstore_util.GetUploadStatus(client_secret)
print ('Upload status: %s' %
chromevox_webstore_util.GetUploadStatus(client_secret).read())
elif input == 'u':
chromevox_webstore_util.PostUpload(output_path, client_secret)
print ('Uploaded with status: %s' %
chromevox_webstore_util.PostUpload(output_path, client_secret))
elif input == 't':
chromevox_webstore_util.PostPublishTrustedTesters(client_secret)
print ('Published to trusted testers with status: %s' %
chromevox_webstore_util.PostPublishTrustedTesters(
client_secret).read())
elif input == 'p':
chromevox_webstore_util.PostPublish(client_secret)
print ('Published to public with status: %s' %
chromevox_webstore_util.PostPublish(client_secret).read())
elif input == 'q':
sys.exit()
else:
......@@ -92,14 +96,17 @@ def main():
if extension_file in EXCLUDE_FILES:
continue
if extension_file == 'manifest.json':
new_file = MakeManifestEdits(root, extension_file)
new_file = tempfile.NamedTemporaryFile(mode='w+a', bufsize=0)
MakeManifestEdits(root, extension_file, new_file)
zip.write(
new_file.name, os.path.join(rel_path, extension_file))
continue
zip.write(os.path.join(root, extension_file),
os.path.join(rel_path, extension_file))
RunInteractivePrompt(client_secret, output_path)
print 'Created ChromeVox zip file in %s' % output_path
print 'Please run manual smoke tests before proceeding.'
RunInteractivePrompt(client_secret, output_path)
if __name__ == '__main__':
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment