Merge pull request #318 from clouserw/random
fixing a couple of bugs; 3 commits; bug 751209, bug 750510
This commit is contained in:
Коммит
9ac44234ae
|
@ -16,6 +16,7 @@ import path
|
|||
from lib import recommend
|
||||
from celery.task.sets import TaskSet
|
||||
from celeryutils import task
|
||||
import waffle
|
||||
|
||||
import amo
|
||||
import cronjobs
|
||||
|
@ -73,6 +74,10 @@ def _build_reverse_name_lookup(data, **kw):
|
|||
# delete it.
|
||||
@cronjobs.register
|
||||
def fast_current_version():
|
||||
|
||||
# Candidate for deletion - Bug 750510
|
||||
if not waffle.switch_is_active('current_version_crons'):
|
||||
return
|
||||
# Only find the really recent versions; this is called a lot.
|
||||
t = datetime.now() - timedelta(minutes=5)
|
||||
qs = Addon.objects.values_list('id')
|
||||
|
@ -90,6 +95,11 @@ def fast_current_version():
|
|||
@cronjobs.register
|
||||
def update_addons_current_version():
|
||||
"""Update the current_version field of the addons."""
|
||||
|
||||
# Candidate for deletion - Bug 750510
|
||||
if not waffle.switch_is_active('current_version_crons'):
|
||||
return
|
||||
|
||||
d = (Addon.objects.filter(disabled_by_user=False,
|
||||
status__in=amo.VALID_STATUSES)
|
||||
.exclude(type=amo.ADDON_PERSONA).values_list('id'))
|
||||
|
@ -103,6 +113,11 @@ def update_addons_current_version():
|
|||
# delete it.
|
||||
@task(rate_limit='20/m')
|
||||
def _update_addons_current_version(data, **kw):
|
||||
|
||||
# Candidate for deletion - Bug 750510
|
||||
if not waffle.switch_is_active('current_version_crons'):
|
||||
return
|
||||
|
||||
task_log.info("[%s@%s] Updating addons current_versions." %
|
||||
(len(data), _update_addons_current_version.rate_limit))
|
||||
for pk in data:
|
||||
|
|
|
@ -22,12 +22,14 @@ class TestBuildReverseNameLookup(amo.tests.TestCase):
|
|||
class CurrentVersionTestCase(amo.tests.TestCase):
|
||||
fixtures = ['base/addon_3615']
|
||||
|
||||
@patch('waffle.switch_is_active', lambda x: True)
|
||||
def test_addons(self):
|
||||
Addon.objects.filter(pk=3615).update(_current_version=None)
|
||||
eq_(Addon.objects.filter(_current_version=None, pk=3615).count(), 1)
|
||||
cron._update_addons_current_version(((3615,),))
|
||||
eq_(Addon.objects.filter(_current_version=None, pk=3615).count(), 0)
|
||||
|
||||
@patch('waffle.switch_is_active', lambda x: True)
|
||||
def test_cron(self):
|
||||
Addon.objects.filter(pk=3615).update(_current_version=None)
|
||||
eq_(Addon.objects.filter(_current_version=None, pk=3615).count(), 1)
|
||||
|
|
|
@ -1,31 +0,0 @@
|
|||
<?xml version="1.0"?>
|
||||
<RDF:RDF xmlns:RDF="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:pfs="http://www.mozilla.org/2004/pfs-rdf#">
|
||||
|
||||
<RDF:Description about="urn:mozilla:plugin-results:{{ plugin.mimetype }}">
|
||||
<pfs:plugins><RDF:Seq>
|
||||
<RDF:li resource="urn:mozilla:plugin:{{ plugin.guid }}"/>
|
||||
</RDF:Seq></pfs:plugins>
|
||||
</RDF:Description>
|
||||
|
||||
<RDF:Description about="urn:mozilla:plugin:{{ plugin.guid }}">
|
||||
<pfs:updates><RDF:Seq>
|
||||
<RDF:li resource="urn:mozilla:plugin:{{ plugin.guid }}:{{ plugin.version }}"/>
|
||||
</RDF:Seq></pfs:updates>
|
||||
</RDF:Description>
|
||||
|
||||
<RDF:Description about="urn:mozilla:plugin:{{ plugin.guid }}:{{ plugin.version }}">
|
||||
<pfs:name>{{ plugin.name }}</pfs:name>
|
||||
<pfs:requestedMimetype>{{ plugin.mimetype }}</pfs:requestedMimetype>
|
||||
<pfs:guid>{{ plugin.guid }}</pfs:guid>
|
||||
<pfs:version>{{ plugin.version }}</pfs:version>
|
||||
<pfs:IconUrl>{{ plugin.iconUrl }}</pfs:IconUrl>
|
||||
<pfs:InstallerLocation>{{ plugin.InstallerLocation }}</pfs:InstallerLocation>
|
||||
<pfs:InstallerHash>{{ plugin.InstallerHash }}</pfs:InstallerHash>
|
||||
<pfs:XPILocation>{{ plugin.XPILocation }}</pfs:XPILocation>
|
||||
<pfs:InstallerShowsUI>{{ plugin.InstallerShowsUI }}</pfs:InstallerShowsUI>
|
||||
<pfs:manualInstallationURL>{{ plugin.manualInstallationURL }}</pfs:manualInstallationURL>
|
||||
<pfs:licenseURL>{{ plugin.licenseURL }}</pfs:licenseURL>
|
||||
<pfs:needsRestart>{{ plugin.needsRestart }}</pfs:needsRestart>
|
||||
</RDF:Description>
|
||||
|
||||
</RDF:RDF>
|
|
@ -1,4 +1,3 @@
|
|||
from collections import defaultdict
|
||||
import json
|
||||
import re
|
||||
|
||||
|
@ -19,7 +18,6 @@ from django_statsd.clients import statsd
|
|||
|
||||
import amo
|
||||
import api
|
||||
from api.views import render_xml
|
||||
import files.tasks
|
||||
from amo.decorators import no_login_required, post_required
|
||||
from amo.utils import log_cef
|
||||
|
@ -171,302 +169,6 @@ def record(request):
|
|||
return http.HttpResponseForbidden()
|
||||
|
||||
|
||||
def plugin_check(request):
|
||||
|
||||
g = defaultdict(str, [(k, v) for k, v in request.GET.iteritems()])
|
||||
|
||||
required = ['mimetype', 'appID', 'appVersion', 'clientOS', 'chromeLocale']
|
||||
|
||||
# Some defaults we override depending on what we find below.
|
||||
plugin = dict(mimetype='-1', name='-1', guid='-1', version=None,
|
||||
iconUrl=None, XPILocation=None, InstallerLocation=None,
|
||||
InstallerHash=None, InstallerShowsUI=None,
|
||||
manualInstallationURL=None, licenseURL=None,
|
||||
needsRestart='true')
|
||||
|
||||
# Special case for mimetype if they are provided.
|
||||
plugin['mimetype'] = g['mimetype'] or '-1'
|
||||
|
||||
for s in required:
|
||||
if s not in request.GET:
|
||||
# A sort of 404, matching what was returned in the original PHP.
|
||||
return render_xml(request, 'services/plugin_check.xml',
|
||||
{'plugin': plugin})
|
||||
|
||||
# Figure out what plugins we've got, and what plugins we know where
|
||||
# to get.
|
||||
|
||||
# Begin our huge and embarrassing if-else statement.
|
||||
if (g['mimetype'] in ['application/x-shockwave-flash',
|
||||
'application/futuresplash'] and
|
||||
re.match(flash_re, g['clientOS'])):
|
||||
|
||||
# We really want the regexp for Linux to be /Linux(?! x86_64)/ but
|
||||
# for now we can't tell 32-bit linux appart from 64-bit linux, so
|
||||
# feed all x86_64 users the flash player, even if it's a 32-bit
|
||||
# plugin.
|
||||
|
||||
# We've got flash plugin installers for Win and Linux (x86),
|
||||
# present those to the user, and for Mac users, tell them where
|
||||
# they can go to get the installer.
|
||||
|
||||
plugin.update(
|
||||
name='Adobe Flash Player',
|
||||
manualInstallationURL='http://www.adobe.com/go/getflashplayer')
|
||||
|
||||
# Don't use a https URL for the license here, per request from
|
||||
# Macromedia.
|
||||
|
||||
if g['clientOS'].startswith('Win'):
|
||||
plugin.update(
|
||||
guid='{4cfaef8a-a6c9-41a0-8e6f-967eb8f49143}',
|
||||
XPILocation=None,
|
||||
iconUrl='http://fpdownload2.macromedia.com/pub/flashplayer/current/fp_win_installer.ico',
|
||||
needsRestart='false',
|
||||
InstallerShowsUI='true')
|
||||
|
||||
if re.match(r'^(?!.*(Win64|x64))Win.*$', g['clientOS']):
|
||||
plugin.update(
|
||||
version='11.2.202.233',
|
||||
InstallerHash='sha256:94887c02a7bc40c844798c3ca840d53ead56203410d2a1cf49f1f557773a41a2',
|
||||
InstallerLocation='http://download.macromedia.com/pub/flashplayer/current/FP_PL_PFS_INSTALLER_32bit.exe')
|
||||
else:
|
||||
plugin.update(
|
||||
version='11.2.202.233 64-bit',
|
||||
InstallerHash='sha256:d60c42140f5612a818e364690f2d6ee021a45cabc0f2cfffe1d010e99939c374',
|
||||
InstallerLocation='http://download.macromedia.com/pub/flashplayer/current/FP_PL_PFS_INSTALLER_64bit.exe')
|
||||
|
||||
elif (g['mimetype'] == 'application/x-director' and
|
||||
g['clientOS'].startswith('Win')):
|
||||
plugin.update(
|
||||
name='Adobe Shockwave Player',
|
||||
manualInstallationURL='http://get.adobe.com/shockwave/')
|
||||
|
||||
# Even though the shockwave installer is not a silent installer, we
|
||||
# need to show its EULA here since we've got a slimmed down
|
||||
# installer that doesn't do that itself.
|
||||
if g['chromeLocale'] != 'ja-JP':
|
||||
plugin.update(
|
||||
licenseURL='http://www.adobe.com/go/eula_shockwaveplayer')
|
||||
else:
|
||||
plugin.update(
|
||||
licenseURL='http://www.adobe.com/go/eula_shockwaveplayer_jp')
|
||||
plugin.update(
|
||||
guid='{45f2a22c-4029-4209-8b3d-1421b989633f}',
|
||||
XPILocation=None,
|
||||
version='11.6.4.634',
|
||||
InstallerHash='sha256:5eeaa6969ad812a827b827b0357dc32bcb8ca77757528cf44631b290cfcb4117',
|
||||
InstallerLocation='http://fpdownload.macromedia.com/pub/shockwave/default/english/win95nt/latest/Shockwave_Installer_FF.exe',
|
||||
needsRestart='false',
|
||||
InstallerShowsUI='false')
|
||||
|
||||
elif (g['mimetype'] in ['audio/x-pn-realaudio-plugin',
|
||||
'audio/x-pn-realaudio'] and
|
||||
re.match(r'^(Win|Linux|PPC Mac OS X)', g['clientOS'])):
|
||||
plugin.update(
|
||||
name='Real Player',
|
||||
version='10.5',
|
||||
manualInstallationURL='http://www.real.com')
|
||||
|
||||
if g['clientOS'].startswith('Win'):
|
||||
plugin.update(
|
||||
XPILocation='http://forms.real.com/real/player/download.html?type=firefox',
|
||||
guid='{d586351c-cb55-41a7-8e7b-4aaac5172d39}')
|
||||
else:
|
||||
plugin.update(
|
||||
guid='{269eb771-59de-4702-9209-ca97ce522f6d}')
|
||||
|
||||
elif (re.match(quicktime_re, g['mimetype']) and
|
||||
re.match(r'^(Win|PPC Mac OS X)', g['clientOS'])):
|
||||
|
||||
# Well, we don't have a plugin that can handle any of those
|
||||
# mimetypes, but the Apple Quicktime plugin can. Point the user to
|
||||
# the Quicktime download page.
|
||||
|
||||
plugin.update(
|
||||
name='Apple Quicktime',
|
||||
guid='{a42bb825-7eee-420f-8ee7-834062b6fefd}',
|
||||
InstallerShowsUI='true',
|
||||
manualInstallationURL='http://www.apple.com/quicktime/download/')
|
||||
|
||||
elif (re.match(java_re, g['mimetype']) and
|
||||
re.match(r'^(Win|Linux|PPC Mac OS X)', g['clientOS'])):
|
||||
|
||||
# We serve up the Java plugin for the following mimetypes:
|
||||
#
|
||||
# application/x-java-vm
|
||||
# application/x-java-applet;jpi-version=1.5
|
||||
# application/x-java-bean;jpi-version=1.5
|
||||
# application/x-java-applet;version=1.3
|
||||
# application/x-java-bean;version=1.3
|
||||
# application/x-java-applet;version=1.2.2
|
||||
# application/x-java-bean;version=1.2.2
|
||||
# application/x-java-applet;version=1.2.1
|
||||
# application/x-java-bean;version=1.2.1
|
||||
# application/x-java-applet;version=1.4.2
|
||||
# application/x-java-bean;version=1.4.2
|
||||
# application/x-java-applet;version=1.5
|
||||
# application/x-java-bean;version=1.5
|
||||
# application/x-java-applet;version=1.3.1
|
||||
# application/x-java-bean;version=1.3.1
|
||||
# application/x-java-applet;version=1.4
|
||||
# application/x-java-bean;version=1.4
|
||||
# application/x-java-applet;version=1.4.1
|
||||
# application/x-java-bean;version=1.4.1
|
||||
# application/x-java-applet;version=1.2
|
||||
# application/x-java-bean;version=1.2
|
||||
# application/x-java-applet;version=1.1.3
|
||||
# application/x-java-bean;version=1.1.3
|
||||
# application/x-java-applet;version=1.1.2
|
||||
# application/x-java-bean;version=1.1.2
|
||||
# application/x-java-applet;version=1.1.1
|
||||
# application/x-java-bean;version=1.1.1
|
||||
# application/x-java-applet;version=1.1
|
||||
# application/x-java-bean;version=1.1
|
||||
# application/x-java-applet
|
||||
# application/x-java-bean
|
||||
#
|
||||
#
|
||||
# We don't have a Java plugin to offer here, but Sun's got one for
|
||||
# Windows. For other platforms we know where to get one, point the
|
||||
# user to the JRE download page.
|
||||
|
||||
plugin.update(
|
||||
name='Java Runtime Environment',
|
||||
version='1.6 u31',
|
||||
manualInstallationURL='http://java.com/downloads',
|
||||
InstallerShowsUI='false',
|
||||
needsRestart='false')
|
||||
|
||||
# For now, send Vista users to a manual download page.
|
||||
#
|
||||
# This is a temp fix for bug 366129 until vista has a non-manual
|
||||
# solution.
|
||||
if g['clientOS'].startswith('Windows NT 6.0'):
|
||||
plugin.update(
|
||||
guid='{fbe640ef-4375-4f45-8d79-767d60bf75b8}',
|
||||
InstallerLocation='http://java.com/firefoxjre_exe',
|
||||
InstallerHash='sha1:fe5d345ffd399641fd49d73258F60ac274af3a5f')
|
||||
elif g['clientOS'].startswith('Win'):
|
||||
plugin.update(
|
||||
guid='{92a550f2-dfd2-4d2f-a35d-a98cfda73595}',
|
||||
InstallerLocation='http://java.com/firefoxjre_exe',
|
||||
InstallerHash='sha1:fe5d345ffd399641fd49d73258f60ac274af3A5f',
|
||||
XPILocation='http://java.com/jre-install.xpi')
|
||||
else:
|
||||
plugin.update(
|
||||
guid='{fbe640ef-4375-4f45-8d79-767d60bf75b8}')
|
||||
|
||||
elif (g['mimetype'] in ['application/pdf', 'application/vnd.fdf',
|
||||
'application/vnd.adobe.xfdf',
|
||||
'application/vnd.adobe.xdp+xml',
|
||||
'application/vnd.adobe.xfd+xml'] and
|
||||
re.match(r'^(Win|PPC Mac OS X|Linux(?! x86_64))', g['clientOS'])):
|
||||
plugin.update(
|
||||
name='Adobe Acrobat Plug-In',
|
||||
guid='{d87cd824-67cb-4547-8587-616c70318095}',
|
||||
manualInstallationURL='http://www.adobe.com/products/acrobat/readstep.html')
|
||||
|
||||
elif (g['mimetype'] == 'application/x-mtx' and
|
||||
re.match(r'^(Win|PPC Mac OS X)', g['clientOS'])):
|
||||
plugin.update(
|
||||
name='Viewpoint Media Player',
|
||||
guid='{03f998b2-0e00-11d3-a498-00104b6eb52e}',
|
||||
manualInstallationURL='http://www.viewpoint.com/pub/products/vmp.html')
|
||||
|
||||
elif re.match(wmp_re, g['mimetype']):
|
||||
# We serve up the Windows Media Player plugin for the following
|
||||
# mimetypes:
|
||||
#
|
||||
# application/asx
|
||||
# application/x-mplayer2
|
||||
# audio/x-ms-wax
|
||||
# audio/x-ms-wma
|
||||
# video/x-ms-asf
|
||||
# video/x-ms-asf-plugin
|
||||
# video/x-ms-wm
|
||||
# video/x-ms-wmp
|
||||
# video/x-ms-wmv
|
||||
# video/x-ms-wmx
|
||||
# video/x-ms-wvx
|
||||
#
|
||||
# For all windows users who don't have the WMP 11 plugin, give them
|
||||
# a link for it.
|
||||
if g['clientOS'].startswith('Win'):
|
||||
plugin.update(
|
||||
name='Windows Media Player',
|
||||
version='11',
|
||||
guid='{cff1240a-fd24-4b9f-8183-ccd96e5300d0}',
|
||||
manualInstallationURL='http://port25.technet.com/pages/windows-media-player-firefox-plugin-download.aspx')
|
||||
|
||||
# For OSX users -- added Intel to this since flip4mac is a UB.
|
||||
# Contact at MS was okay w/ this, plus MS points to this anyway.
|
||||
elif re.match(r'^(PPC|Intel) Mac OS X', g['clientOS']):
|
||||
plugin.update(
|
||||
name='Flip4Mac',
|
||||
version='2.1',
|
||||
guid='{cff0240a-fd24-4b9f-8183-ccd96e5300d0}',
|
||||
manualInstallationURL='http://www.flip4mac.com/wmv_download.htm')
|
||||
|
||||
elif (g['mimetype'] == 'application/x-xstandard' and
|
||||
re.match(r'^(Win|PPC Mac OS X)', g['clientOS'])):
|
||||
plugin.update(
|
||||
name='XStandard XHTML WYSIWYG Editor',
|
||||
guid='{3563d917-2f44-4e05-8769-47e655e92361}',
|
||||
iconUrl='http://xstandard.com/images/xicon32x32.gif',
|
||||
XPILocation='http://xstandard.com/download/xstandard.xpi',
|
||||
InstallerShowsUI='false',
|
||||
manualInstallationURL='http://xstandard.com/download/',
|
||||
licenseURL='http://xstandard.com/license/')
|
||||
|
||||
elif (g['mimetype'] == 'application/x-dnl' and
|
||||
g['clientOS'].startswith('Win')):
|
||||
plugin.update(
|
||||
name='DNL Reader',
|
||||
guid='{ce9317a3-e2f8-49b9-9b3b-a7fb5ec55161}',
|
||||
version='5.5',
|
||||
iconUrl='http://digitalwebbooks.com/reader/dwb16.gif',
|
||||
XPILocation='http://digitalwebbooks.com/reader/xpinst.xpi',
|
||||
InstallerShowsUI='false',
|
||||
manualInstallationURL='http://digitalwebbooks.com/reader/')
|
||||
|
||||
elif (g['mimetype'] == 'application/x-videoegg-loader' and
|
||||
g['clientOS'].startswith('Win')):
|
||||
plugin.update(
|
||||
name='VideoEgg Publisher',
|
||||
guid='{b8b881f0-2e07-11db-a98b-0800200c9a66}',
|
||||
iconUrl='http://videoegg.com/favicon.ico',
|
||||
XPILocation='http://update.videoegg.com/Install/Windows/Initial/VideoEggPublisher.xpi',
|
||||
InstallerShowsUI='true',
|
||||
manualInstallationURL='http://www.videoegg.com/')
|
||||
|
||||
elif (g['mimetype'] == 'video/divx' and
|
||||
g['clientOS'].startswith('Win')):
|
||||
plugin.update(
|
||||
name='DivX Web Player',
|
||||
guid='{a8b771f0-2e07-11db-a98b-0800200c9a66}',
|
||||
iconUrl='http://images.divx.com/divx/player/webplayer.png',
|
||||
XPILocation='http://download.divx.com/player/DivXWebPlayer.xpi',
|
||||
InstallerShowsUI='false',
|
||||
licenseURL='http://go.divx.com/plugin/license/',
|
||||
manualInstallationURL='http://go.divx.com/plugin/download/')
|
||||
|
||||
elif (g['mimetype'] == 'video/divx' and
|
||||
re.match(r'^(PPC|Intel) Mac OS X', g['clientOS'])):
|
||||
plugin.update(
|
||||
name='DivX Web Player',
|
||||
guid='{a8b771f0-2e07-11db-a98b-0800200c9a66}',
|
||||
iconUrl='http://images.divx.com/divx/player/webplayer.png',
|
||||
XPILocation='http://download.divx.com/player/DivXWebPlayerMac.xpi',
|
||||
InstallerShowsUI='false',
|
||||
licenseURL='http://go.divx.com/plugin/license/',
|
||||
manualInstallationURL='http://go.divx.com/plugin/download/')
|
||||
|
||||
# End ridiculously huge and embarrassing if-else block.
|
||||
|
||||
return render_xml(request, 'services/plugin_check.xml', {'plugin': plugin})
|
||||
|
||||
|
||||
def plugin_check_redirect(request):
|
||||
return redirect('%s?%s' %
|
||||
(settings.PFS_URL,
|
||||
|
|
|
@ -80,17 +80,6 @@ def _update_collections_subscribers(data, **kw):
|
|||
transaction.commit_unless_managed()
|
||||
|
||||
|
||||
# TODO(jbalogh): removed from cron on 6/27/11. If the site doesn't break,
|
||||
# delete it.
|
||||
@cronjobs.register
|
||||
def collection_meta():
|
||||
from . import tasks
|
||||
collections = Collection.objects.values_list('id', flat=True)
|
||||
ts = [tasks.cron_collection_meta.subtask(args=chunk)
|
||||
for chunk in chunked(collections, 1000)]
|
||||
TaskSet(ts).apply_async()
|
||||
|
||||
|
||||
@cronjobs.register
|
||||
def update_collections_votes():
|
||||
"""Update collection's votes."""
|
||||
|
|
|
@ -101,11 +101,6 @@ def collection_watchers(*ids, **kw):
|
|||
log.error('Updating collection watchers failed: %s, %s' % (pk, e))
|
||||
|
||||
|
||||
@task(rate_limit='10/m')
|
||||
def cron_collection_meta(*addons, **kw):
|
||||
collection_meta(*addons)
|
||||
|
||||
|
||||
@task
|
||||
def index_collections(ids, **kw):
|
||||
es = elasticutils.get_es()
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
INSERT INTO waffle_switch (name, active, note)
|
||||
VALUES ('current_version_crons', 1,
|
||||
'Flip this to disable some crons and see if stuff breaks. Bug 750510');
|
Загрузка…
Ссылка в новой задаче