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: Fixed a typo Created May 26, 2014, 12:18 p.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
« no previous file with comments | « sitescripts/extensions/template/pad.xml ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sitescripts/extensions/utils.py
===================================================================
--- a/sitescripts/extensions/utils.py
+++ b/sitescripts/extensions/utils.py
@@ -16,7 +16,10 @@
# along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
import re
-from ConfigParser import NoOptionError
+import os
+import subprocess
+from ConfigParser import SafeConfigParser, NoOptionError
+from StringIO import StringIO
from sitescripts.utils import get_config
def compareVersionParts(part1, part2):
@@ -132,6 +135,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 +147,7 @@
clientID = _defineLocalProperty('clientID', '')
clientSecret = _defineLocalProperty('clientSecret', '')
refreshToken = _defineLocalProperty('refreshToken', '')
+ padTemplate = _defineLocalProperty('padTemplate')
latestRevision = _defineNightlyProperty('latestRevision')
@@ -181,6 +187,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):
"""
« no previous file with comments | « sitescripts/extensions/template/pad.xml ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld