OLD | NEW |
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 25 matching lines...) Expand all Loading... |
36 # A list of files (or directories) to exclude from the webstore build. | 36 # A list of files (or directories) to exclude from the webstore build. |
37 EXCLUDE_PATHS = [ | 37 EXCLUDE_PATHS = [ |
38 'cvox2/background/', | 38 'cvox2/background/', |
39 'manifest.json', | 39 'manifest.json', |
40 'manifest_guest.json', | 40 'manifest_guest.json', |
41 ] | 41 ] |
42 | 42 |
43 | 43 |
44 def CreateOptionParser(): | 44 def CreateOptionParser(): |
45 parser = optparse.OptionParser(description=__doc__) | 45 parser = optparse.OptionParser(description=__doc__) |
46 parser.usage = '%prog <extension_path> <output_path> <client_secret' | 46 parser.usage = '%prog <extension_path> <client_secret>' |
| 47 parser.add_option('-p', '--publish', action='store_true', |
| 48 help='publish the extension') |
47 return parser | 49 return parser |
48 | 50 |
49 | 51 |
50 def GetVersion(): | 52 def GetVersion(): |
51 '''Returns the chrome version string.''' | 53 '''Returns the chrome version string.''' |
52 filename = os.path.join(_CHROME_SOURCE_DIR, 'chrome', 'VERSION') | 54 filename = os.path.join(_CHROME_SOURCE_DIR, 'chrome', 'VERSION') |
53 values = version.fetch_values([filename]) | 55 values = version.fetch_values([filename]) |
54 return version.subst_template('@MAJOR@.@MINOR@.@BUILD@.@PATCH@', values) | 56 return version.subst_template('@MAJOR@.@MINOR@.@BUILD@.@PATCH@', values) |
55 | 57 |
56 | 58 |
(...skipping 24 matching lines...) Expand all Loading... |
81 print 't publish trusted tester' | 83 print 't publish trusted tester' |
82 print 'p publish public' | 84 print 'p publish public' |
83 print 'q quit' | 85 print 'q quit' |
84 input = raw_input('Please select an option: ') | 86 input = raw_input('Please select an option: ') |
85 input = input.strip() | 87 input = input.strip() |
86 if input == 'g': | 88 if input == 'g': |
87 print ('Upload status: %s' % | 89 print ('Upload status: %s' % |
88 chromevox_webstore_util.GetUploadStatus(client_secret).read()) | 90 chromevox_webstore_util.GetUploadStatus(client_secret).read()) |
89 elif input == 'u': | 91 elif input == 'u': |
90 print ('Uploaded with status: %s' % | 92 print ('Uploaded with status: %s' % |
91 chromevox_webstore_util.PostUpload(output_path, client_secret)) | 93 chromevox_webstore_util.PostUpload(output_path.name, client_secret)) |
92 elif input == 't': | 94 elif input == 't': |
93 print ('Published to trusted testers with status: %s' % | 95 print ('Published to trusted testers with status: %s' % |
94 chromevox_webstore_util.PostPublishTrustedTesters( | 96 chromevox_webstore_util.PostPublishTrustedTesters( |
95 client_secret).read()) | 97 client_secret).read()) |
96 elif input == 'p': | 98 elif input == 'p': |
97 print ('Published to public with status: %s' % | 99 print ('Published to public with status: %s' % |
98 chromevox_webstore_util.PostPublish(client_secret).read()) | 100 chromevox_webstore_util.PostPublish(client_secret).read()) |
99 elif input == 'q': | 101 elif input == 'q': |
100 sys.exit() | 102 sys.exit() |
101 else: | 103 else: |
102 print 'Unrecognized option: %s' % input | 104 print 'Unrecognized option: %s' % input |
103 | 105 |
104 def main(): | 106 def main(): |
105 _, args = CreateOptionParser().parse_args() | 107 options, args = CreateOptionParser().parse_args() |
106 if len(args) != 3: | 108 if len(args) != 2: |
107 print 'Expected exactly three arguments' | 109 print 'Expected exactly two arguments' |
| 110 print str(args) |
108 sys.exit(1) | 111 sys.exit(1) |
109 | 112 |
110 extension_path = args[0] | 113 extension_path = args[0] |
111 output_path = args[1] | 114 client_secret = args[1] |
112 client_secret = args[2] | 115 output_path = tempfile.NamedTemporaryFile() |
113 | 116 |
114 with ZipFile(output_path, 'w') as zip: | 117 with ZipFile(output_path, 'w') as zip: |
115 for root, dirs, files in os.walk(extension_path): | 118 for root, dirs, files in os.walk(extension_path): |
116 rel_path = os.path.join(os.path.relpath(root, extension_path), '') | 119 rel_path = os.path.join(os.path.relpath(root, extension_path), '') |
117 if rel_path in EXCLUDE_PATHS: | 120 if rel_path in EXCLUDE_PATHS: |
118 continue | 121 continue |
119 | 122 |
120 for extension_file in files: | 123 for extension_file in files: |
121 if extension_file in EXCLUDE_PATHS: | 124 if extension_file in EXCLUDE_PATHS: |
122 continue | 125 continue |
123 | 126 |
124 zip.write(os.path.join(root, extension_file), | 127 zip.write(os.path.join(root, extension_file), |
125 os.path.join(rel_path, extension_file)) | 128 os.path.join(rel_path, extension_file)) |
126 manifest_file = MakeManifest() | 129 manifest_file = MakeManifest() |
127 zip.write(manifest_file.name, 'manifest.json') | 130 zip.write(manifest_file.name, 'manifest.json') |
128 print 'Created ChromeVox zip file in %s' % output_path | 131 print 'Created ChromeVox zip file in %s' % output_path.name |
129 print 'Please run manual smoke tests before proceeding.' | 132 print 'Please run manual smoke tests before proceeding.' |
130 RunInteractivePrompt(client_secret, output_path) | 133 if options.publish: |
| 134 print('Uploading...%s' % |
| 135 chromevox_webstore_util.PostUpload(output_path.name, client_secret)) |
| 136 print('publishing...%s' % |
| 137 chromevox_webstore_util.PostPublish(client_secret).read()) |
| 138 else: |
| 139 RunInteractivePrompt(client_secret, output_path) |
131 | 140 |
132 | 141 |
133 if __name__ == '__main__': | 142 if __name__ == '__main__': |
134 main() | 143 main() |
OLD | NEW |