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

Unified Diff: sitescripts/extensions/utils.py

Issue 5723465818570752: Issue 520 - Generate PAD files for download portals when updating download links (Closed)
Patch Set: Created May 26, 2014, 10 a.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: sitescripts/extensions/utils.py
===================================================================
--- a/sitescripts/extensions/utils.py
+++ b/sitescripts/extensions/utils.py
@@ -15,8 +15,9 @@
# You should have received a copy of the GNU General Public License
# along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
-import re
-from ConfigParser import NoOptionError
+import re, os, subprocess
Wladimir Palant 2014/05/26 10:54:57 One import per line?
Sebastian Noack 2014/05/26 12:04:53 Done.
+from ConfigParser import SafeConfigParser, NoOptionError
+from StringIO import StringIO
from sitescripts.utils import get_config
def compareVersionParts(part1, part2):
@@ -132,6 +133,8 @@
certname = _defineGlobalProperty('signtool_certname')
dbdir = _defineGlobalProperty('signtool_dbdir')
dbpass = _defineGlobalProperty('signtool_dbpass')
+ padDirectory = _defineGlobalProperty('padDirectory')
+ padURL = _defineGlobalProperty('padURL')
keyFile = _defineLocalProperty('key', '')
name = _defineLocalProperty('name')
@@ -142,6 +145,7 @@
clientID = _defineLocalProperty('clientID', '')
clientSecret = _defineLocalProperty('clientSecret', '')
refreshToken = _defineLocalProperty('refreshToken', '')
+ padTemplate = _defineLocalProperty('padTemplate')
latestRevision = _defineNightlyProperty('latestRevision')
@@ -181,6 +185,46 @@
"""
return self.repositoryName
+ def listContents(self, version='tip'):
+ return subprocess.check_output(['hg', '-R', self.repository, 'locate', '-r', version]).splitlines()
+
+ def readMetadata(self, version='tip'):
+ genericFilename = 'metadata'
+ filename = '%s.%s' % (genericFilename, self.type)
+ files = self.listContents(version)
+
+ if filename not in files:
+ # some repositories like those for Android and
+ # Internet Explorer don't have metadata files
+ if genericFilename not in files:
+ return None
+
+ # Fall back to platform-independent metadata file
+ filename = genericFilename
+
+ command = ['hg', '-R', self.repository, 'cat', '-r', version, os.path.join(self.repository, filename)]
+ result = subprocess.check_output(command)
+
+ parser = SafeConfigParser()
+ parser.readfp(StringIO(result))
+
+ return parser
+
+ @property
+ def basename(self):
+ metadata = self.readMetadata()
+ if metadata:
+ return metadata.get('general', 'basename')
+ return os.path.basename(self.repository)
+
+ def getDownloads(self):
+ prefix = self.basename + '-'
+ command = ['hg', 'locate', '-R', self.downloadsRepo, '-r', 'default']
+
+ for filename in subprocess.check_output(command).splitlines():
+ if filename.startswith(prefix) and filename.endswith(self.packageSuffix):
+ yield (filename, filename[len(prefix):len(filename) - len(self.packageSuffix)])
+
@staticmethod
def getRepositoryConfigurations(nightlyConfig = None):
"""
« sitescripts/extensions/template/pad.xml ('K') | « sitescripts/extensions/template/pad.xml ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld