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

Side by Side Diff: chrome/browser/resources/chromeos/chromevox/tools/chromevox_webstore_util.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
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 '''A set of utilities to interface with the Chrome Webstore API.''' 7 '''A set of utilities to interface with the Chrome Webstore API.'''
8 8
9 import SimpleHTTPServer 9 import SimpleHTTPServer
10 import SocketServer 10 import SocketServer
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 Handler = CodeRequestHandler 48 Handler = CodeRequestHandler
49 httpd = SocketServer.TCPServer(("", PORT), Handler) 49 httpd = SocketServer.TCPServer(("", PORT), Handler)
50 query = '&'.join(['response_type=code', 50 query = '&'.join(['response_type=code',
51 'scope=%s' % WEBSTORE_API_SCOPE, 51 'scope=%s' % WEBSTORE_API_SCOPE,
52 'client_id=%(client_id)s' % PROJECT_ARGS, 52 'client_id=%(client_id)s' % PROJECT_ARGS,
53 'redirect_uri=%(redirect_uri)s' % PROJECT_ARGS]) 53 'redirect_uri=%(redirect_uri)s' % PROJECT_ARGS])
54 auth_url = ' https://%s%s?%s' % (OAUTH_DOMAIN, OAUTH_AUTH_COMMAND, query) 54 auth_url = ' https://%s%s?%s' % (OAUTH_DOMAIN, OAUTH_AUTH_COMMAND, query)
55 print 'Navigating to %s' % auth_url 55 print 'Navigating to %s' % auth_url
56 webbrowser.open(auth_url) 56 webbrowser.open(auth_url)
57 httpd.handle_request() 57 httpd.handle_request()
58 httpd.server_close()
58 return httpd.code 59 return httpd.code
59 60
60 def GetOauthToken(code, client_secret): 61 def GetOauthToken(code, client_secret):
61 PROJECT_ARGS['code'] = code 62 PROJECT_ARGS['code'] = code
62 PROJECT_ARGS['client_secret'] = client_secret 63 PROJECT_ARGS['client_secret'] = client_secret
63 body = urllib.urlencode(PROJECT_ARGS) 64 body = urllib.urlencode(PROJECT_ARGS)
64 conn = httplib.HTTPSConnection(OAUTH_DOMAIN) 65 conn = httplib.HTTPSConnection(OAUTH_DOMAIN)
65 conn.putrequest('POST', OAUTH_TOKEN_COMMAND) 66 conn.putrequest('POST', OAUTH_TOKEN_COMMAND)
66 conn.putheader('content-type', 'application/x-www-form-urlencoded') 67 conn.putheader('content-type', 'application/x-www-form-urlencoded')
67 conn.putheader('content-length', len(body)) 68 conn.putheader('content-length', len(body))
(...skipping 15 matching lines...) Expand all
83 def SendGetCommand(command, client_secret): 84 def SendGetCommand(command, client_secret):
84 headers = GetPopulatedHeader(client_secret) 85 headers = GetPopulatedHeader(client_secret)
85 conn = httplib.HTTPSConnection(API_ENDPOINT_DOMAIN) 86 conn = httplib.HTTPSConnection(API_ENDPOINT_DOMAIN)
86 conn.request('GET', command, '', headers) 87 conn.request('GET', command, '', headers)
87 return conn.getresponse() 88 return conn.getresponse()
88 89
89 def SendPostCommand(command, client_secret, header_additions = {}, body=None): 90 def SendPostCommand(command, client_secret, header_additions = {}, body=None):
90 headers = GetPopulatedHeader(client_secret) 91 headers = GetPopulatedHeader(client_secret)
91 headers = dict(headers.items() + header_additions.items()) 92 headers = dict(headers.items() + header_additions.items())
92 conn = httplib.HTTPSConnection(API_ENDPOINT_DOMAIN) 93 conn = httplib.HTTPSConnection(API_ENDPOINT_DOMAIN)
93 conn.request('PUT', command, body, headers) 94 conn.request('POST', command, body, headers)
94 return conn.getresponse() 95 return conn.getresponse()
95 96
96 def GetUploadStatus(client_secret): 97 def GetUploadStatus(client_secret):
97 '''Gets the status of a previous upload. 98 '''Gets the status of a previous upload.
98 Args: 99 Args:
99 client_secret ChromeVox's client secret creds. 100 client_secret ChromeVox's client secret creds.
100 ''' 101 '''
101 return SendGetCommand(COMMAND_GET_UPLOAD_STATUS, client_secret) 102 return SendGetCommand(COMMAND_GET_UPLOAD_STATUS, client_secret)
102 103
103 # httplib fails to persist the connection during upload; use curl instead. 104 # httplib fails to persist the connection during upload; use curl instead.
(...skipping 25 matching lines...) Expand all
129 return SendPostCommand(COMMAND_POST_PUBLISH, 130 return SendPostCommand(COMMAND_POST_PUBLISH,
130 client_secret, 131 client_secret,
131 { 'publishTarget': 'trustedTesters'}) 132 { 'publishTarget': 'trustedTesters'})
132 133
133 def PostPublish(client_secret): 134 def PostPublish(client_secret):
134 '''Publishes a previously uploaded ChromeVox extension publically. 135 '''Publishes a previously uploaded ChromeVox extension publically.
135 Args: 136 Args:
136 client_secret ChromeVox's client secret creds. 137 client_secret ChromeVox's client secret creds.
137 ''' 138 '''
138 return SendPostCommand(COMMAND_POST_PUBLISH, client_secret) 139 return SendPostCommand(COMMAND_POST_PUBLISH, client_secret)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698