Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: sitescripts/extensions/utils.py

Issue 29322523: Issue 2796 - Moved logic to extract Safari Developer ID to buildtools (Closed)
Patch Set: Updated dependency Created July 17, 2015, 11:55 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « sitescripts/extensions/bin/updateUpdateManifests.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 # coding: utf-8 1 # coding: utf-8
2 2
3 # This file is part of the Adblock Plus web scripts, 3 # This file is part of the Adblock Plus web scripts,
4 # Copyright (C) 2006-2015 Eyeo GmbH 4 # Copyright (C) 2006-2015 Eyeo GmbH
5 # 5 #
6 # Adblock Plus is free software: you can redistribute it and/or modify 6 # Adblock Plus is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License version 3 as 7 # it under the terms of the GNU General Public License version 3 as
8 # published by the Free Software Foundation. 8 # published by the Free Software Foundation.
9 # 9 #
10 # Adblock Plus is distributed in the hope that it will be useful, 10 # Adblock Plus is distributed in the hope that it will be useful,
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 This static method will enumerate Configuration 238 This static method will enumerate Configuration
239 objects representing the settings for each repository. 239 objects representing the settings for each repository.
240 """ 240 """
241 config = get_config() 241 config = get_config()
242 for key, value in config.items("extensions"): 242 for key, value in config.items("extensions"):
243 if key.endswith("_repository"): 243 if key.endswith("_repository"):
244 repositoryName = re.sub(r'_repository$', '', key) 244 repositoryName = re.sub(r'_repository$', '', key)
245 if repositoryName: 245 if repositoryName:
246 yield Configuration(config, nightlyConfig, repositoryName, value) 246 yield Configuration(config, nightlyConfig, repositoryName, value)
247 247
248 def getSafariCertificateID(keyFile):
249 import M2Crypto
250
251 bio = M2Crypto.BIO.openfile(keyFile)
252 try:
253 while True:
254 try:
255 cert = M2Crypto.X509.load_cert_bio(bio)
256 except M2Crypto.X509.X509Error:
257 raise Exception('No safari developer certificate found in chain')
258
259 subject = cert.get_subject()
260 for entry in subject.get_entries_by_nid(subject.nid['CN']):
261 m = re.match(r'Safari Developer: \((.*?)\)', entry.get_data().as_text())
262 if m:
263 return m.group(1)
264 finally:
265 bio.close()
266
267 def _urlencode(value): 248 def _urlencode(value):
268 return urllib.quote(value.encode('utf-8'), '') 249 return urllib.quote(value.encode('utf-8'), '')
269 250
270 def _urlopen(url, attempts=3): 251 def _urlopen(url, attempts=3):
271 """ 252 """
272 Tries to open a particular URL, retries on failure. 253 Tries to open a particular URL, retries on failure.
273 """ 254 """
274 for i in range(attempts): 255 for i in range(attempts):
275 try: 256 try:
276 return urllib.urlopen(url) 257 return urllib.urlopen(url)
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
444 if not extensions: 425 if not extensions:
445 return 426 return
446 427
447 updates = {} 428 updates = {}
448 for extension in extensions: 429 for extension in extensions:
449 updates[extension['basename']] = { 430 updates[extension['basename']] = {
450 "url": extension['updateURL'], 431 "url": extension['updateURL'],
451 "version": extension['version'] 432 "version": extension['version']
452 } 433 }
453 writeLibabpUpdateManifest(path, updates) 434 writeLibabpUpdateManifest(path, updates)
OLDNEW
« no previous file with comments | « sitescripts/extensions/bin/updateUpdateManifests.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld