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

Unified 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: Remov logging. 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/resources/chromeos/chromevox/tools/upload_chromevox_to_webstore.py
diff --git a/chrome/browser/resources/chromeos/chromevox/tools/upload_chromevox_to_webstore.py b/chrome/browser/resources/chromeos/chromevox/tools/upload_chromevox_to_webstore.py
new file mode 100755
index 0000000000000000000000000000000000000000..eb047f8a48e9de1a5b5975fa690bc65adae44460
--- /dev/null
+++ b/chrome/browser/resources/chromeos/chromevox/tools/upload_chromevox_to_webstore.py
@@ -0,0 +1,108 @@
+#!/usr/bin/env python
+
+# Copyright 2014 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+'''Publishes ChromeVox to the webstore.
+ Given an unpacked extension, compresses and sends to the Chrome webstore.
+
+ Releasing to the webstore should involve the following manual steps before
+ running this script:
+ 1. clean the output directory.
+ 2. make a release build.
+ 3. run manual smoke tests.
+ 4. run automated ChromeVox tests.
+'''
+
+import chromevox_webstore_util
+import json
+import optparse
+import os
+import sys
+import tempfile
+from zipfile import ZipFile
+
+# A list of files to exclude from the webstore build.
+EXCLUDE_FILES = ['manifest_guest.json']
+
+
+def CreateOptionParser():
+ parser = optparse.OptionParser(description=__doc__)
+ parser.usage = '%prog <extension_path> <output_path> <client_secret'
+ return parser
+
+def MakeManifestEdits(root, old):
+ '''Customize a manifest for the webstore.
+
+ Args:
+ root: The directory containing file.
+
+ old: A json file.
+
+ Returns:
+ File of the new manifest.
+ '''
+ new_file = tempfile.NamedTemporaryFile()
+ new = new_file.name
+ with open(os.path.join(root, old)) as old_file:
+ new_contents = json.loads(old_file.read())
+ new_contents.pop('key', '')
+ new_file.write(json.dumps(new_contents))
+ return new_file
+
+def RunInteractivePrompt(client_secret, output_path):
+ input = ''
+ while True:
+ print 'u upload'
+ print 'g get upload status'
+ print 't publish trusted tester'
+ print 'p publish public'
+ print 'q quit'
+ input = raw_input('Please select an option: ')
+ input = input.strip()
+ if input == 'g':
+ chromevox_webstore_util.GetUploadStatus(client_secret)
+ elif input == 'u':
+ chromevox_webstore_util.PostUpload(output_path, client_secret)
+ elif input == 't':
+ chromevox_webstore_util.PostPublishTrustedTesters(client_secret)
+ elif input == 'p':
+ chromevox_webstore_util.PostPublish(client_secret)
+ elif input == 'q':
+ sys.exit()
+ else:
+ print 'Unrecognized option: %s' % input
+
+def main():
+ _, args = CreateOptionParser().parse_args()
+ if len(args) != 3:
+ print 'Expected exactly three arguments'
+ sys.exit(1)
+
+ extension_path = args[0]
+ output_path = args[1]
+ client_secret = args[2]
+
+ with ZipFile(output_path, 'w') as zip:
+ for root, dirs, files in os.walk(extension_path):
+ rel_path = os.path.join(os.path.relpath(root, extension_path), '')
+
+ for file in files:
dmazzoni 2014/07/30 05:39:55 file is a reserved word in python, please use some
David Tseng 2014/07/31 21:52:57 Ah yes; changed.
+ extension_file = file
+ if file in EXCLUDE_FILES:
+ continue
+ if file == 'manifest.json':
+ extension_file = file
+ new_file = MakeManifestEdits(root, file)
+ zip.write(
+ new_file.name, os.path.join(rel_path, extension_file))
+ continue
+
+ zip.write(
+ os.path.join(root, file), os.path.join(rel_path, extension_file))
+ RunInteractivePrompt(client_secret, output_path)
dmazzoni 2014/07/30 05:39:55 I don't think this is indented correctly - it will
David Tseng 2014/07/31 21:52:57 Yup; you're right. I haven't really tested this ex
+
+
+if __name__ == '__main__':
+ main()

Powered by Google App Engine
This is Rietveld 408576698