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

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: 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 52 new_file.file.flush()
dmazzoni 2014/08/28 23:13:01 As an alternative to calling flush, pass bufsize =
David Tseng 2014/08/29 21:12:49 Done.
53 53
54 def RunInteractivePrompt(client_secret, output_path): 54 def RunInteractivePrompt(client_secret, output_path):
55 input = '' 55 input = ''
56 while True: 56 while True:
57 print 'u upload' 57 print 'u upload'
58 print 'g get upload status' 58 print 'g get upload status'
59 print 't publish trusted tester' 59 print 't publish trusted tester'
60 print 'p publish public' 60 print 'p publish public'
61 print 'q quit' 61 print 'q quit'
62 input = raw_input('Please select an option: ') 62 input = raw_input('Please select an option: ')
63 input = input.strip() 63 input = input.strip()
64 if input == 'g': 64 if input == 'g':
65 chromevox_webstore_util.GetUploadStatus(client_secret) 65 print ('Upload status: %s' %
66 chromevox_webstore_util.GetUploadStatus(client_secret).read())
66 elif input == 'u': 67 elif input == 'u':
67 chromevox_webstore_util.PostUpload(output_path, client_secret) 68 print ('Uploaded with status: %s' %
69 chromevox_webstore_util.PostUpload(output_path, client_secret))
68 elif input == 't': 70 elif input == 't':
69 chromevox_webstore_util.PostPublishTrustedTesters(client_secret) 71 print ('Published to trusted testers with status: %s' %
72 chromevox_webstore_util.PostPublishTrustedTesters(
73 client_secret).read())
70 elif input == 'p': 74 elif input == 'p':
71 chromevox_webstore_util.PostPublish(client_secret) 75 print ('Published to public with status: %s' %
76 chromevox_webstore_util.PostPublish(client_secret).read())
72 elif input == 'q': 77 elif input == 'q':
73 sys.exit() 78 sys.exit()
74 else: 79 else:
75 print 'Unrecognized option: %s' % input 80 print 'Unrecognized option: %s' % input
76 81
77 def main(): 82 def main():
78 _, args = CreateOptionParser().parse_args() 83 _, args = CreateOptionParser().parse_args()
79 if len(args) != 3: 84 if len(args) != 3:
80 print 'Expected exactly three arguments' 85 print 'Expected exactly three arguments'
81 sys.exit(1) 86 sys.exit(1)
82 87
83 extension_path = args[0] 88 extension_path = args[0]
84 output_path = args[1] 89 output_path = args[1]
85 client_secret = args[2] 90 client_secret = args[2]
86 91
87 with ZipFile(output_path, 'w') as zip: 92 with ZipFile(output_path, 'w') as zip:
88 for root, dirs, files in os.walk(extension_path): 93 for root, dirs, files in os.walk(extension_path):
89 rel_path = os.path.join(os.path.relpath(root, extension_path), '') 94 rel_path = os.path.join(os.path.relpath(root, extension_path), '')
90 95
91 for extension_file in files: 96 for extension_file in files:
92 if extension_file in EXCLUDE_FILES: 97 if extension_file in EXCLUDE_FILES:
93 continue 98 continue
94 if extension_file == 'manifest.json': 99 if extension_file == 'manifest.json':
95 new_file = MakeManifestEdits(root, extension_file) 100 new_file = tempfile.NamedTemporaryFile(mode='w+a')
101 MakeManifestEdits(root, extension_file, new_file)
96 zip.write( 102 zip.write(
97 new_file.name, os.path.join(rel_path, extension_file)) 103 new_file.name, os.path.join(rel_path, extension_file))
98 continue 104 continue
99 105
100 zip.write(os.path.join(root, extension_file), 106 zip.write(os.path.join(root, extension_file),
101 os.path.join(rel_path, extension_file)) 107 os.path.join(rel_path, extension_file))
102 RunInteractivePrompt(client_secret, output_path) 108 print 'Created ChromeVox zip file in %s' % output_path
109 print 'Please run manual smoke tests before proceeding.'
110 RunInteractivePrompt(client_secret, output_path)
103 111
104 112
105 if __name__ == '__main__': 113 if __name__ == '__main__':
106 main() 114 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