1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134
|
#!/usr/bin/env python
# Copyright 2014 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
'''Publishes ChromeVox to the webstore.
Given an unpacked extension, compresses and sends to the Chrome webstore.
Releasing to the webstore should involve the following manual steps before
running this script:
1. clean the output directory.
2. make a release build.
3. run manual smoke tests.
4. run automated ChromeVox tests.
'''
import chromevox_webstore_util
import generate_manifest
import json
import optparse
import os
import sys
import tempfile
from zipfile import ZipFile
_SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
_CHROME_SOURCE_DIR = os.path.normpath(
os.path.join(
_SCRIPT_DIR, *[os.path.pardir] * 6))
sys.path.insert(
0, os.path.join(_CHROME_SOURCE_DIR, 'build', 'util'))
import version
# A list of files (or directories) to exclude from the webstore build.
EXCLUDE_PATHS = [
'cvox2/background/',
'manifest.json',
'manifest_guest.json',
]
def CreateOptionParser():
parser = optparse.OptionParser(description=__doc__)
parser.usage = '%prog <extension_path> <output_path> <client_secret'
return parser
def GetVersion():
'''Returns the chrome version string.'''
filename = os.path.join(_CHROME_SOURCE_DIR, 'chrome', 'VERSION')
values = version.fetch_values([filename])
return version.subst_template('@MAJOR@.@MINOR@.@BUILD@.@PATCH@', values)
def MakeManifest():
'''Create a manifest for the webstore.
Returns:
Temporary file with generated manifest.
'''
new_file = tempfile.NamedTemporaryFile(mode='w+a', bufsize=0)
in_file_name = os.path.join(_SCRIPT_DIR, os.path.pardir,
'manifest.json.jinja2')
context = {
'is_chromevox_classic': '1',
'is_guest_manifest': '0',
'is_js_compressed': '1',
'set_version': GetVersion()
}
generate_manifest.processJinjaTemplate(in_file_name, new_file.name, context)
return new_file
def RunInteractivePrompt(client_secret, output_path):
input = ''
while True:
print 'u upload'
print 'g get upload status'
print 't publish trusted tester'
print 'p publish public'
print 'q quit'
input = raw_input('Please select an option: ')
input = input.strip()
if input == 'g':
print ('Upload status: %s' %
chromevox_webstore_util.GetUploadStatus(client_secret).read())
elif input == 'u':
print ('Uploaded with status: %s' %
chromevox_webstore_util.PostUpload(output_path, client_secret))
elif input == 't':
print ('Published to trusted testers with status: %s' %
chromevox_webstore_util.PostPublishTrustedTesters(
client_secret).read())
elif input == 'p':
print ('Published to public with status: %s' %
chromevox_webstore_util.PostPublish(client_secret).read())
elif input == 'q':
sys.exit()
else:
print 'Unrecognized option: %s' % input
def main():
_, args = CreateOptionParser().parse_args()
if len(args) != 3:
print 'Expected exactly three arguments'
sys.exit(1)
extension_path = args[0]
output_path = args[1]
client_secret = args[2]
with ZipFile(output_path, 'w') as zip:
for root, dirs, files in os.walk(extension_path):
rel_path = os.path.join(os.path.relpath(root, extension_path), '')
if rel_path in EXCLUDE_PATHS:
continue
for extension_file in files:
if extension_file in EXCLUDE_PATHS:
continue
zip.write(os.path.join(root, extension_file),
os.path.join(rel_path, extension_file))
manifest_file = MakeManifest()
zip.write(manifest_file.name, 'manifest.json')
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__':
main()
|