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(): ...@@ -55,6 +55,7 @@ def GetAuthCode():
print 'Navigating to %s' % auth_url print 'Navigating to %s' % auth_url
webbrowser.open(auth_url) webbrowser.open(auth_url)
httpd.handle_request() httpd.handle_request()
httpd.server_close()
return httpd.code return httpd.code
def GetOauthToken(code, client_secret): def GetOauthToken(code, client_secret):
...@@ -90,7 +91,7 @@ def SendPostCommand(command, client_secret, header_additions = {}, body=None): ...@@ -90,7 +91,7 @@ def SendPostCommand(command, client_secret, header_additions = {}, body=None):
headers = GetPopulatedHeader(client_secret) headers = GetPopulatedHeader(client_secret)
headers = dict(headers.items() + header_additions.items()) headers = dict(headers.items() + header_additions.items())
conn = httplib.HTTPSConnection(API_ENDPOINT_DOMAIN) conn = httplib.HTTPSConnection(API_ENDPOINT_DOMAIN)
conn.request('PUT', command, body, headers) conn.request('POST', command, body, headers)
return conn.getresponse() return conn.getresponse()
def GetUploadStatus(client_secret): def GetUploadStatus(client_secret):
......
...@@ -32,7 +32,7 @@ def CreateOptionParser(): ...@@ -32,7 +32,7 @@ def CreateOptionParser():
parser.usage = '%prog <extension_path> <output_path> <client_secret' parser.usage = '%prog <extension_path> <output_path> <client_secret'
return parser return parser
def MakeManifestEdits(root, old): def MakeManifestEdits(root, old, new_file):
'''Customize a manifest for the webstore. '''Customize a manifest for the webstore.
Args: Args:
...@@ -40,16 +40,15 @@ def MakeManifestEdits(root, old): ...@@ -40,16 +40,15 @@ def MakeManifestEdits(root, old):
old: A json file. old: A json file.
new_file: a temporary file to place the manifest in.
Returns: Returns:
File of the new manifest. File of the new manifest.
''' '''
new_file = tempfile.NamedTemporaryFile()
new = new_file.name
with open(os.path.join(root, old)) as old_file: with open(os.path.join(root, old)) as old_file:
new_contents = json.loads(old_file.read()) new_contents = json.loads(old_file.read())
new_contents.pop('key', '') new_contents.pop('key', '')
new_file.write(json.dumps(new_contents)) new_file.file.write(json.dumps(new_contents))
return new_file
def RunInteractivePrompt(client_secret, output_path): def RunInteractivePrompt(client_secret, output_path):
input = '' input = ''
...@@ -62,13 +61,18 @@ def RunInteractivePrompt(client_secret, output_path): ...@@ -62,13 +61,18 @@ def RunInteractivePrompt(client_secret, output_path):
input = raw_input('Please select an option: ') input = raw_input('Please select an option: ')
input = input.strip() input = input.strip()
if input == 'g': if input == 'g':
chromevox_webstore_util.GetUploadStatus(client_secret) print ('Upload status: %s' %
chromevox_webstore_util.GetUploadStatus(client_secret).read())
elif input == 'u': 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': 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': 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': elif input == 'q':
sys.exit() sys.exit()
else: else:
...@@ -92,14 +96,17 @@ def main(): ...@@ -92,14 +96,17 @@ def main():
if extension_file in EXCLUDE_FILES: if extension_file in EXCLUDE_FILES:
continue continue
if extension_file == 'manifest.json': 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( zip.write(
new_file.name, os.path.join(rel_path, extension_file)) new_file.name, os.path.join(rel_path, extension_file))
continue continue
zip.write(os.path.join(root, extension_file), zip.write(os.path.join(root, extension_file),
os.path.join(rel_path, 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__': 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