Chromium Code Reviews| Index: chrome/browser/resources/chromeos/chromevox/tools/upload_chromevox_to_webstore.py |
| diff --git a/chrome/browser/resources/chromeos/chromevox/tools/upload_chromevox_to_webstore.py b/chrome/browser/resources/chromeos/chromevox/tools/upload_chromevox_to_webstore.py |
| new file mode 100755 |
| index 0000000000000000000000000000000000000000..6c6db7af08494389f3eee5027ee12a57831deba9 |
| --- /dev/null |
| +++ b/chrome/browser/resources/chromeos/chromevox/tools/upload_chromevox_to_webstore.py |
| @@ -0,0 +1,82 @@ |
| +#!/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 json |
| +import optparse |
| +import os |
| +import sys |
| +import tempfile |
| +from zipfile import ZipFile |
| + |
| +# A list of files to exclude from the webstore build. |
| +EXCLUDE_FILES = ['manifest_guest.json'] |
| + |
| + |
| +def CreateOptionParser(): |
| + parser = optparse.OptionParser(description=__doc__) |
| + parser.usage = '%prog <extension_path> <output_path>' |
| + return parser |
| + |
| +def MakeManifestEdits(root, old): |
| + '''Customize a manifest for the webstore. |
| + |
| + Args: |
| + root: The directory containing file. |
| + |
| + old: A json file. |
| + |
| + 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 |
| + |
| +def main(): |
| + _, args = CreateOptionParser().parse_args() |
| + if len(args) != 2: |
| + print 'Expected exactly two arguments' |
| + sys.exit(1) |
| + |
| + extension_path = args[0] |
| + output_path = args[1] |
| + |
| + 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), '') |
| + |
| + for file in files: |
| + extension_file = file |
| + if file in EXCLUDE_FILES: |
| + continue |
| + if file == 'manifest.json': |
| + extension_file = file |
| + new_file = MakeManifestEdits(root, file) |
| + zip.write( |
| + new_file.name, os.path.join(rel_path, extension_file)) |
| + continue |
| + |
| + zip.write( |
| + os.path.join(root, file), os.path.join(rel_path, extension_file)) |
| + # TODO(dtseng): Publish to webstore |
|
dmazzoni
2014/07/28 05:29:07
Is this TODO still valid? Your comment on the code
David Tseng
2014/07/29 23:52:18
Done.
|
| + |
| +if __name__ == '__main__': |
| + main() |