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

Delta Between Two Patch Sets: sitescripts/extensions/utils.py

Issue 5723465818570752: Issue 520 - Generate PAD files for download portals when updating download links (Closed)
Left Patch Set: Created May 26, 2014, 10 a.m.
Right Patch Set: Addressed comments Created June 4, 2014, 4:35 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « sitescripts/extensions/template/pad.xml ('k') | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
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-2014 Eyeo GmbH 4 # Copyright (C) 2006-2014 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,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of 11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details. 13 # GNU General Public License for more details.
14 # 14 #
15 # You should have received a copy of the GNU General Public License 15 # You should have received a copy of the GNU General Public License
16 # along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. 16 # along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
17 17
18 import re, os, subprocess 18 import re
Wladimir Palant 2014/05/26 10:54:57 One import per line?
Sebastian Noack 2014/05/26 12:04:53 Done.
19 import os
20 import subprocess
19 from ConfigParser import SafeConfigParser, NoOptionError 21 from ConfigParser import SafeConfigParser, NoOptionError
20 from StringIO import StringIO 22 from StringIO import StringIO
21 from sitescripts.utils import get_config 23 from sitescripts.utils import get_config
22 24
23 def compareVersionParts(part1, part2): 25 def compareVersionParts(part1, part2):
24 def convertInt(value, default): 26 def convertInt(value, default):
25 try: 27 try:
26 return int(value) 28 return int(value)
27 except ValueError: 29 except ValueError:
28 return default 30 return default
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 return result 85 return result
84 return 0 86 return 0
85 87
86 class Configuration(object): 88 class Configuration(object):
87 """ 89 """
88 This class represents the configuration settings for a single repository. 90 This class represents the configuration settings for a single repository.
89 Some of these properties come from the nightly config file and can be 91 Some of these properties come from the nightly config file and can be
90 changed (latestRevision), others come from the global config and are 92 changed (latestRevision), others come from the global config and are
91 read-only (repository, repositoryName, nightliesDirectory). 93 read-only (repository, repositoryName, nightliesDirectory).
92 """ 94 """
93 95 def _defineProperty(name, local=False, type='', default=None):
94 def _defineGlobalProperty(key): 96 def getter(self):
95 """ 97 method = getattr(self.config, 'get' + type)
96 Creates a property corresponding with a key in the config file 98 key = '%s_%s' % (self.repositoryName, name) if local else name
97 """ 99
98 return property(lambda self: self.config.get('extensions', key))
99
100 def _defineLocalProperty(key, default = None):
101 """
102 Creates a property corresponding with a repository-specific key in the con fig file
103 """
104 def getLocalProperty(self):
105 try: 100 try:
106 return self.config.get('extensions', self.repositoryName + '_' + key) 101 return method('extensions', key)
107 except NoOptionError, e: 102 except NoOptionError:
108 if default != None: 103 if default is None:
109 return default 104 raise
110 else: 105 return default
111 raise e 106
112 return property(getLocalProperty) 107 return property(getter)
113 108
114 def _defineNightlyProperty(key): 109 def _defineNightlyProperty(key):
115 """ 110 """
116 Creates a property corresponding with a key in the nightly config file 111 Creates a property corresponding with a key in the nightly config file
117 """ 112 """
118 return property(lambda self: self.nightlyConfig.get(self.repositoryName, key ), 113 return property(lambda self: self.nightlyConfig.get(self.repositoryName, key ),
119 lambda self, value: self.nightlyConfig.set(self.repositoryNa me, key, value)) 114 lambda self, value: self.nightlyConfig.set(self.repositoryNa me, key, value))
120 115
121 config = None 116 config = None
122 nightlyConfig = None 117 nightlyConfig = None
123 repositoryName = None 118 repositoryName = None
124 repository = None 119 repository = None
125 120
126 buildRepository = _defineGlobalProperty('buildRepository') 121 buildRepository = _defineProperty('buildRepository')
127 nightliesDirectory = _defineGlobalProperty('nightliesDirectory') 122 nightliesDirectory = _defineProperty('nightliesDirectory')
128 nightliesURL = _defineGlobalProperty('nightliesURL') 123 nightliesURL = _defineProperty('nightliesURL')
129 downloadsRepo = _defineGlobalProperty('downloadsRepo') 124 downloadsRepo = _defineProperty('downloadsRepo')
130 downloadsURL = _defineGlobalProperty('downloadsURL') 125 downloadsURL = _defineProperty('downloadsURL')
131 docsDirectory = _defineGlobalProperty('docsDirectory') 126 docsDirectory = _defineProperty('docsDirectory')
132 signtool = _defineGlobalProperty('signtool') 127 signtool = _defineProperty('signtool')
133 certname = _defineGlobalProperty('signtool_certname') 128 certname = _defineProperty('signtool_certname')
134 dbdir = _defineGlobalProperty('signtool_dbdir') 129 dbdir = _defineProperty('signtool_dbdir')
135 dbpass = _defineGlobalProperty('signtool_dbpass') 130 dbpass = _defineProperty('signtool_dbpass')
136 padDirectory = _defineGlobalProperty('padDirectory') 131 padDirectory = _defineProperty('padDirectory')
137 padURL = _defineGlobalProperty('padURL') 132 padURL = _defineProperty('padURL')
138 133 padTemplate = _defineProperty('padTemplate')
139 keyFile = _defineLocalProperty('key', '') 134
140 name = _defineLocalProperty('name') 135 keyFile = _defineProperty('key', local=True, default='')
141 galleryID = _defineLocalProperty('galleryID', '') 136 name = _defineProperty('name', local=True)
142 devbuildGalleryID = _defineLocalProperty('devbuildGalleryID', '') 137 galleryID = _defineProperty('galleryID', local=True, default='')
143 downloadPage = _defineLocalProperty('downloadPage', '') 138 devbuildGalleryID = _defineProperty('devbuildGalleryID', local=True, default=' ')
144 experimental = _defineLocalProperty('experimental', '') 139 downloadPage = _defineProperty('downloadPage', local=True, default='')
145 clientID = _defineLocalProperty('clientID', '') 140 experimental = _defineProperty('experimental', local=True, default='')
146 clientSecret = _defineLocalProperty('clientSecret', '') 141 clientID = _defineProperty('clientID', local=True, default='')
147 refreshToken = _defineLocalProperty('refreshToken', '') 142 clientSecret = _defineProperty('clientSecret', local=True, default='')
148 padTemplate = _defineLocalProperty('padTemplate') 143 refreshToken = _defineProperty('refreshToken', local=True, default='')
144 pad = _defineProperty('pad', local=True, type='boolean', default=False)
149 145
150 latestRevision = _defineNightlyProperty('latestRevision') 146 latestRevision = _defineNightlyProperty('latestRevision')
151 147
152 def __init__(self, config, nightlyConfig, repositoryName, repository): 148 def __init__(self, config, nightlyConfig, repositoryName, repository):
153 """ 149 """
154 Creates a new Configuration instance that is bound to a particular 150 Creates a new Configuration instance that is bound to a particular
155 repository. 151 repository.
156 """ 152 """
157 153
158 self.repositoryName = repositoryName 154 self.repositoryName = repositoryName
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 except M2Crypto.X509.X509Error: 249 except M2Crypto.X509.X509Error:
254 raise Exception('No safari developer certificate found in chain') 250 raise Exception('No safari developer certificate found in chain')
255 251
256 subject = cert.get_subject() 252 subject = cert.get_subject()
257 for entry in subject.get_entries_by_nid(subject.nid['CN']): 253 for entry in subject.get_entries_by_nid(subject.nid['CN']):
258 m = re.match(r'Safari Developer: \((.*?)\)', entry.get_data().as_text()) 254 m = re.match(r'Safari Developer: \((.*?)\)', entry.get_data().as_text())
259 if m: 255 if m:
260 return m.group(1) 256 return m.group(1)
261 finally: 257 finally:
262 bio.close() 258 bio.close()
LEFTRIGHT

Powered by Google App Engine
This is Rietveld