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

Unified Diff: sitescripts/extensions/bin/updateDownloadLinks.py

Issue 9806015: Create an update manifest for Android releases as well, not just for Gecko-based extensions (Closed)
Patch Set: Created March 14, 2013, 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
« no previous file with comments | « .sitescripts.example ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sitescripts/extensions/bin/updateDownloadLinks.py
===================================================================
--- a/sitescripts/extensions/bin/updateDownloadLinks.py
+++ b/sitescripts/extensions/bin/updateDownloadLinks.py
@@ -18,17 +18,17 @@
"""
Update the list of extenstions
==============================
This script generates a list of extensions and saves these with download links
and version information
"""
-import os, re, urllib, urllib2, urlparse, subprocess, time
+import sys, os, re, urllib, urllib2, urlparse, subprocess, time
import xml.dom.minidom as dom
from ConfigParser import SafeConfigParser
from StringIO import StringIO
from sitescripts.utils import get_config, get_template
from sitescripts.extensions.utils import compareVersions, Configuration
from buildtools.packagerGecko import KNOWN_APPS
def urlencode(value):
@@ -153,56 +153,73 @@ def getDownloadLinks(result):
result.set(repo.repositoryName, "downloadURL", downloadURL)
result.set(repo.repositoryName, "version", version)
def readMetadata(repo, version):
"""
reads extension ID and compatibility information from metadata file in the
extension's repository
"""
- command = ['hg', '-R', repo.repository, 'cat', '-r', version, os.path.join(repo.repository, 'metadata.%s' % repo.type)]
- (result, dummy) = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()
+ if repo.type == 'android':
+ command = ['hg', '-R', repo.repository, 'id', '-r', version, '-n']
+ (result, dummy) = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()
+ revision = re.sub(r'\D', '', result)
- # Fall back to platform-independent metadata file for now
- if not result:
- command = ['hg', '-R', repo.repository, 'cat', '-r', version, os.path.join(repo.repository, 'metadata')]
- (result, dummy) = subprocess.Popen(command, stdout=subprocess.PIPE).communicate()
+ command = ['hg', '-R', repo.repository, 'cat', '-r', version, os.path.join(repo.repository, 'AndroidManifest.xml')]
+ (result, dummy) = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()
+ manifest = dom.parseString(result)
+ usesSdk = manifest.getElementsByTagName('uses-sdk')[0]
- parser = SafeConfigParser()
- parser.readfp(StringIO(result))
+ return {
+ 'revision': revision,
+ 'minSdkVersion': usesSdk.attributes["android:minSdkVersion"].value,
+ }
+ else:
+ command = ['hg', '-R', repo.repository, 'cat', '-r', version, os.path.join(repo.repository, 'metadata.%s' % repo.type)]
+ (result, dummy) = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()
- result = {
- 'extensionID': parser.get('general', 'id'),
- 'version': version,
- 'compat': []
- }
- for key, value in KNOWN_APPS.iteritems():
- if parser.has_option('compat', key):
- minVersion, maxVersion = parser.get('compat', key).split('/')
- result['compat'].append({'id': value, 'minVersion': minVersion, 'maxVersion': maxVersion})
- return result
+ # Fall back to platform-independent metadata file for now
+ if not result:
+ command = ['hg', '-R', repo.repository, 'cat', '-r', version, os.path.join(repo.repository, 'metadata')]
+ (result, dummy) = subprocess.Popen(command, stdout=subprocess.PIPE).communicate()
+
+ parser = SafeConfigParser()
+ parser.readfp(StringIO(result))
+
+ result = {
+ 'extensionID': parser.get('general', 'id'),
+ 'version': version,
+ 'compat': []
+ }
+ for key, value in KNOWN_APPS.iteritems():
+ if parser.has_option('compat', key):
+ minVersion, maxVersion = parser.get('compat', key).split('/')
+ result['compat'].append({'id': value, 'minVersion': minVersion, 'maxVersion': maxVersion})
+ return result
def writeUpdateManifest(links):
"""
- writes an update.rdf file for all Gecko extensions
+ writes an update manifest for all Gecko extensions and Android apps
"""
- extensions = []
+ extensions = {'gecko': [], 'android': []}
for repo in Configuration.getRepositoryConfigurations():
- if repo.type != 'gecko':
- continue
- if not links.has_section(repo.repositoryName):
+ if repo.type not in extensions or not links.has_section(repo.repositoryName):
continue
data = readMetadata(repo, links.get(repo.repositoryName, 'version'))
data['updateURL'] = links.get(repo.repositoryName, 'downloadURL')
- extensions.append(data)
+ extensions[repo.type].append(data)
- manifestPath = get_config().get('extensions', 'geckoUpdateManifestPath')
- template = get_template(get_config().get('extensions', 'geckoUpdateManifest'))
- template.stream({'extensions': extensions}).dump(manifestPath)
+ if len(extensions['android']) > 1:
+ print >>sys.stderr, 'Warning: more than one Android app defined, update manifest only works for one'
+
+ for repoType in extensions.iterkeys():
+ manifestPath = get_config().get('extensions', '%sUpdateManifestPath' % repoType)
+ template = get_template(get_config().get('extensions', '%sUpdateManifest' % repoType))
+ template.stream({'extensions': extensions[repoType]}).dump(manifestPath)
def updateLinks():
"""
writes the current extension download links to a file
"""
# Update downloads directory first
downloadsRepository = get_config().get('extensions', 'downloadsDirectory')
« no previous file with comments | « .sitescripts.example ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld