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

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

Issue 8851004: Added Opera extension type (Closed)
Patch Set: Created Nov. 13, 2012, 9:46 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/extensions/bin/createNightlies.py ('k') | sitescripts/extensions/utils.py » ('j') | 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, urllib, urlparse, subprocess, time
+import 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):
@@ -72,16 +72,36 @@ def getGoogleDownloadLink(galleryID):
document = dom.parseString(contents)
updateTags = document.getElementsByTagName('updatecheck')
updateTag = updateTags[0] if len(updateTags) > 0 else None
if updateTag and updateTag.hasAttribute('codebase') and updateTag.hasAttribute('version'):
return (updateTag.getAttribute('codebase'), updateTag.getAttribute('version'))
else:
return (None, None)
+def getOperaDownloadLink(galleryID):
+ """
+ gets download link for an Opera add-on from the Opera Addons site
+ """
+ class HeadRequest(urllib2.Request):
+ def get_method(self):
+ return "HEAD"
+
+ url = 'https://addons.opera.com/extensions/download/%s/' % urlencode(galleryID)
+ response = urllib2.urlopen(HeadRequest(url))
+ content_disposition = response.info().dict.get('content-disposition', None)
+ if content_disposition != None:
+ match = re.search(r'filename=\S+-([\d.]+)-\d+\.oex$', content_disposition)
+ else:
+ match = None;
+ if match:
+ return (url, match.group(1))
+ else:
+ return (None, None)
+
def getLocalLink(repo):
"""
gets the link for the newest download of an add-on in the local downloads
repository
"""
dir = repo.downloadsDirectory
url = repo.downloadsURL
@@ -104,16 +124,18 @@ def getDownloadLink(repo):
gets the download link to the most current version of an extension
"""
galleryURL = None
galleryVersion = None
if repo.type == "gecko" and repo.galleryID:
(galleryURL, galleryVersion) = getMozillaDownloadLink(repo.galleryID)
elif repo.type == "chrome" and repo.galleryID:
(galleryURL, galleryVersion) = getGoogleDownloadLink(repo.galleryID)
+ elif repo.type == "opera" and repo.galleryID:
+ (galleryURL, galleryVersion) = getOperaDownloadLink(repo.galleryID)
(downloadsURL, downloadsVersion) = getLocalLink(repo)
if galleryVersion == None or (downloadsVersion != None and
compareVersions(galleryVersion, downloadsVersion) < 0):
return (downloadsURL, downloadsVersion)
else:
return (galleryURL, galleryVersion)
« no previous file with comments | « sitescripts/extensions/bin/createNightlies.py ('k') | sitescripts/extensions/utils.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld