Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1194)

Side by Side Diff: chrome/browser/resources/chromeos/chromevox/tools/upload_chromevox_to_webstore.py

Issue 417703002: Add scripts to semi-automate publishing of ChromeVox webstore extension using webstore API. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rename some files. Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 #!/usr/bin/env python
2
3 # Copyright 2014 The Chromium Authors. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file.
6
7 '''Publishes ChromeVox to the webstore.
8 Given an unpacked extension, compresses and sends to the Chrome webstore.
9
10 Releasing to the webstore should involve the following manual steps before
11 running this script:
12 1. clean the output directory.
13 2. make a release build.
14 3. run manual smoke tests.
15 4. run automated ChromeVox tests.
16 '''
17
18 import json
19 import optparse
20 import os
21 import sys
22 import tempfile
23 from zipfile import ZipFile
24
25 # A list of files to exclude from the webstore build.
26 EXCLUDE_FILES = ['manifest_guest.json']
27
28
29 def CreateOptionParser():
30 parser = optparse.OptionParser(description=__doc__)
31 parser.usage = '%prog <extension_path> <output_path>'
32 return parser
33
34 def MakeManifestEdits(root, old):
35 '''Customize a manifest for the webstore.
36
37 Args:
38 root: The directory containing file.
39
40 old: A json file.
41
42 Returns:
43 File of the new manifest.
44 '''
45 new_file = tempfile.NamedTemporaryFile()
46 new = new_file.name
47 with open(os.path.join(root, old)) as old_file:
48 new_contents = json.loads(old_file.read())
49 new_contents.pop('key', '')
50 new_file.write(json.dumps(new_contents))
51 return new_file
52
53 def main():
54 _, args = CreateOptionParser().parse_args()
55 if len(args) != 2:
56 print 'Expected exactly two arguments'
57 sys.exit(1)
58
59 extension_path = args[0]
60 output_path = args[1]
61
62 with ZipFile(output_path, 'w') as zip:
63 for root, dirs, files in os.walk(extension_path):
64 rel_path = os.path.join(os.path.relpath(root, extension_path), '')
65
66 for file in files:
67 extension_file = file
68 if file in EXCLUDE_FILES:
69 continue
70 if file == 'manifest.json':
71 extension_file = file
72 new_file = MakeManifestEdits(root, file)
73 zip.write(
74 new_file.name, os.path.join(rel_path, extension_file))
75 continue
76
77 zip.write(
78 os.path.join(root, file), os.path.join(rel_path, extension_file))
79 # 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.
80
81 if __name__ == '__main__':
82 main()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698