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

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

Issue 515723005: Make a few fixes to the ChromeVox webstore upload script. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: bufsize=0 Created 6 years, 3 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
« no previous file with comments | « chrome/browser/resources/chromeos/chromevox/tools/chromevox_webstore_util.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
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 2
3 # Copyright 2014 The Chromium Authors. All rights reserved. 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 4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file. 5 # found in the LICENSE file.
6 6
7 '''Publishes ChromeVox to the webstore. 7 '''Publishes ChromeVox to the webstore.
8 Given an unpacked extension, compresses and sends to the Chrome webstore. 8 Given an unpacked extension, compresses and sends to the Chrome webstore.
9 9
10 Releasing to the webstore should involve the following manual steps before 10 Releasing to the webstore should involve the following manual steps before
(...skipping 14 matching lines...) Expand all
25 25
26 # A list of files to exclude from the webstore build. 26 # A list of files to exclude from the webstore build.
27 EXCLUDE_FILES = ['manifest_guest.json'] 27 EXCLUDE_FILES = ['manifest_guest.json']
28 28
29 29
30 def CreateOptionParser(): 30 def CreateOptionParser():
31 parser = optparse.OptionParser(description=__doc__) 31 parser = optparse.OptionParser(description=__doc__)
32 parser.usage = '%prog <extension_path> <output_path> <client_secret' 32 parser.usage = '%prog <extension_path> <output_path> <client_secret'
33 return parser 33 return parser
34 34
35 def MakeManifestEdits(root, old): 35 def MakeManifestEdits(root, old, new_file):
36 '''Customize a manifest for the webstore. 36 '''Customize a manifest for the webstore.
37 37
38 Args: 38 Args:
39 root: The directory containing file. 39 root: The directory containing file.
40 40
41 old: A json file. 41 old: A json file.
42 42
43 new_file: a temporary file to place the manifest in.
44
43 Returns: 45 Returns:
44 File of the new manifest. 46 File of the new manifest.
45 ''' 47 '''
46 new_file = tempfile.NamedTemporaryFile()
47 new = new_file.name
48 with open(os.path.join(root, old)) as old_file: 48 with open(os.path.join(root, old)) as old_file:
49 new_contents = json.loads(old_file.read()) 49 new_contents = json.loads(old_file.read())
50 new_contents.pop('key', '') 50 new_contents.pop('key', '')
51 new_file.write(json.dumps(new_contents)) 51 new_file.file.write(json.dumps(new_contents))
52 return new_file
53 52
54 def RunInteractivePrompt(client_secret, output_path): 53 def RunInteractivePrompt(client_secret, output_path):
55 input = '' 54 input = ''
56 while True: 55 while True:
57 print 'u upload' 56 print 'u upload'
58 print 'g get upload status' 57 print 'g get upload status'
59 print 't publish trusted tester' 58 print 't publish trusted tester'
60 print 'p publish public' 59 print 'p publish public'
61 print 'q quit' 60 print 'q quit'
62 input = raw_input('Please select an option: ') 61 input = raw_input('Please select an option: ')
63 input = input.strip() 62 input = input.strip()
64 if input == 'g': 63 if input == 'g':
65 chromevox_webstore_util.GetUploadStatus(client_secret) 64 print ('Upload status: %s' %
65 chromevox_webstore_util.GetUploadStatus(client_secret).read())
66 elif input == 'u': 66 elif input == 'u':
67 chromevox_webstore_util.PostUpload(output_path, client_secret) 67 print ('Uploaded with status: %s' %
68 chromevox_webstore_util.PostUpload(output_path, client_secret))
68 elif input == 't': 69 elif input == 't':
69 chromevox_webstore_util.PostPublishTrustedTesters(client_secret) 70 print ('Published to trusted testers with status: %s' %
71 chromevox_webstore_util.PostPublishTrustedTesters(
72 client_secret).read())
70 elif input == 'p': 73 elif input == 'p':
71 chromevox_webstore_util.PostPublish(client_secret) 74 print ('Published to public with status: %s' %
75 chromevox_webstore_util.PostPublish(client_secret).read())
72 elif input == 'q': 76 elif input == 'q':
73 sys.exit() 77 sys.exit()
74 else: 78 else:
75 print 'Unrecognized option: %s' % input 79 print 'Unrecognized option: %s' % input
76 80
77 def main(): 81 def main():
78 _, args = CreateOptionParser().parse_args() 82 _, args = CreateOptionParser().parse_args()
79 if len(args) != 3: 83 if len(args) != 3:
80 print 'Expected exactly three arguments' 84 print 'Expected exactly three arguments'
81 sys.exit(1) 85 sys.exit(1)
82 86
83 extension_path = args[0] 87 extension_path = args[0]
84 output_path = args[1] 88 output_path = args[1]
85 client_secret = args[2] 89 client_secret = args[2]
86 90
87 with ZipFile(output_path, 'w') as zip: 91 with ZipFile(output_path, 'w') as zip:
88 for root, dirs, files in os.walk(extension_path): 92 for root, dirs, files in os.walk(extension_path):
89 rel_path = os.path.join(os.path.relpath(root, extension_path), '') 93 rel_path = os.path.join(os.path.relpath(root, extension_path), '')
90 94
91 for extension_file in files: 95 for extension_file in files:
92 if extension_file in EXCLUDE_FILES: 96 if extension_file in EXCLUDE_FILES:
93 continue 97 continue
94 if extension_file == 'manifest.json': 98 if extension_file == 'manifest.json':
95 new_file = MakeManifestEdits(root, extension_file) 99 new_file = tempfile.NamedTemporaryFile(mode='w+a', bufsize=0)
100 MakeManifestEdits(root, extension_file, new_file)
96 zip.write( 101 zip.write(
97 new_file.name, os.path.join(rel_path, extension_file)) 102 new_file.name, os.path.join(rel_path, extension_file))
98 continue 103 continue
99 104
100 zip.write(os.path.join(root, extension_file), 105 zip.write(os.path.join(root, extension_file),
101 os.path.join(rel_path, extension_file)) 106 os.path.join(rel_path, extension_file))
102 RunInteractivePrompt(client_secret, output_path) 107 print 'Created ChromeVox zip file in %s' % output_path
108 print 'Please run manual smoke tests before proceeding.'
109 RunInteractivePrompt(client_secret, output_path)
103 110
104 111
105 if __name__ == '__main__': 112 if __name__ == '__main__':
106 main() 113 main()
OLDNEW
« no previous file with comments | « chrome/browser/resources/chromeos/chromevox/tools/chromevox_webstore_util.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698