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

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: Address feedback. Created 6 years, 4 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
« no previous file with comments | « chrome/browser/resources/chromeos/chromevox/tools/generate_manifest.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 chromevox_webstore_util
19 import json
20 import optparse
21 import os
22 import sys
23 import tempfile
24 from zipfile import ZipFile
25
26 # A list of files to exclude from the webstore build.
27 EXCLUDE_FILES = ['manifest_guest.json']
28
29
30 def CreateOptionParser():
31 parser = optparse.OptionParser(description=__doc__)
32 parser.usage = '%prog <extension_path> <output_path> <client_secret'
33 return parser
34
35 def MakeManifestEdits(root, old):
36 '''Customize a manifest for the webstore.
37
38 Args:
39 root: The directory containing file.
40
41 old: A json file.
42
43 Returns:
44 File of the new manifest.
45 '''
46 new_file = tempfile.NamedTemporaryFile()
47 new = new_file.name
48 with open(os.path.join(root, old)) as old_file:
49 new_contents = json.loads(old_file.read())
50 new_contents.pop('key', '')
51 new_file.write(json.dumps(new_contents))
52 return new_file
53
54 def RunInteractivePrompt(client_secret, output_path):
55 input = ''
56 while True:
57 print 'u upload'
58 print 'g get upload status'
59 print 't publish trusted tester'
60 print 'p publish public'
61 print 'q quit'
62 input = raw_input('Please select an option: ')
63 input = input.strip()
64 if input == 'g':
65 chromevox_webstore_util.GetUploadStatus(client_secret)
66 elif input == 'u':
67 chromevox_webstore_util.PostUpload(output_path, client_secret)
68 elif input == 't':
69 chromevox_webstore_util.PostPublishTrustedTesters(client_secret)
70 elif input == 'p':
71 chromevox_webstore_util.PostPublish(client_secret)
72 elif input == 'q':
73 sys.exit()
74 else:
75 print 'Unrecognized option: %s' % input
76
77 def main():
78 _, args = CreateOptionParser().parse_args()
79 if len(args) != 3:
80 print 'Expected exactly three arguments'
81 sys.exit(1)
82
83 extension_path = args[0]
84 output_path = args[1]
85 client_secret = args[2]
86
87 with ZipFile(output_path, 'w') as zip:
88 for root, dirs, files in os.walk(extension_path):
89 rel_path = os.path.join(os.path.relpath(root, extension_path), '')
90
91 for extension_file in files:
92 if extension_file in EXCLUDE_FILES:
93 continue
94 if extension_file == 'manifest.json':
95 new_file = MakeManifestEdits(root, extension_file)
96 zip.write(
97 new_file.name, os.path.join(rel_path, extension_file))
98 continue
99
100 zip.write(os.path.join(root, extension_file),
101 os.path.join(rel_path, extension_file))
102 RunInteractivePrompt(client_secret, output_path)
103
104
105 if __name__ == '__main__':
106 main()
OLDNEW
« no previous file with comments | « chrome/browser/resources/chromeos/chromevox/tools/generate_manifest.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698