/usr/share/cherokee/admin/wizards/streaming.py is in cherokee-admin 1.2.101-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 | # -*- coding: utf-8 -*-
#
# Cherokee-admin's Media Streaming Wizard
#
# Authors:
# Taher Shihadeh <taher@octality.com>
# Alvaro Lopez Ortega <alvaro@alobbs.com>
#
# Copyright (C) 2010 Alvaro Lopez Ortega
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of version 2 of the GNU General Public
# License as published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA.
#
#
# Tested:
# 2010/04/14: Cherokee 0.99.41
#
import re
import string
import CTK
import Wizard
import validations
from util import *
from configured import CHEROKEE_PLUGINDIR
NOTE_WELCOME_H1 = N_("Welcome to the Streaming Wizard")
NOTE_WELCOME_P1 = N_("This Wizard Adds a rule to stream media files.")
PREFIX = 'tmp!wizard!streaming'
APPLY = r'/wizard/vserver/streaming/apply'
EXTENSIONS = 'mp3,ogv,flv,mov,ogg,mp4,webm'
CONFIG = """
%(rule_pre)s!match = extensions
%(rule_pre)s!match!extensions = %(extensions)s
%(rule_pre)s!handler = streaming
%(rule_pre)s!handler!rate = 1
%(rule_pre)s!handler!rate_factor = 0.5
%(rule_pre)s!handler!rate_boost = 5
"""
class Commit:
def Commit_Rule (self):
vsrv_num = CTK.cfg.get_val ('%s!vsrv_num'%(PREFIX))
vsrv_pre = 'vserver!%s'%(vsrv_num)
prio, rule_pre = cfg_vsrv_rule_get_next (vsrv_pre)
extensions = EXTENSIONS
config = CONFIG % (locals())
CTK.cfg.apply_chunk (config)
# Clean up
CTK.cfg.normalize ('%s!rule'%(vsrv_pre))
del (CTK.cfg[PREFIX])
return CTK.cfg_reply_ajax_ok()
def __call__ (self):
if CTK.post.pop('final'):
CTK.cfg_apply_post()
return self.Commit_Rule()
return CTK.cfg_apply_post()
class Welcome:
def __call__ (self):
cont = CTK.Container()
cont += CTK.RawHTML ('<h2>%s</h2>' %(_(NOTE_WELCOME_H1)))
cont += Wizard.Icon ('streaming', {'class': 'wizard-descr'})
box = CTK.Box ({'class': 'wizard-welcome'})
box += CTK.RawHTML ('<p>%s</p>' %(_(NOTE_WELCOME_P1)))
box += Wizard.CookBookBox ('cookbook_streaming')
# Send the VServer num
vsrv_num = re.findall (r'^/wizard/vserver/(\d+)/', CTK.request.url)[0]
submit = CTK.Submitter (APPLY)
submit += CTK.Hidden('%s!vsrv_num'%(PREFIX), vsrv_num)
submit += CTK.Hidden('final', '1')
cont += submit
cont += box
cont += NextStep (vsrv_num)
return cont.Render().toStr()
class NextStep (CTK.Container):
def __init__ (self, vsrv_num):
CTK.Container.__init__ (self)
self._pre = 'vserver!%s'%(vsrv_num)
if self._can_proceed ():
self += CTK.DruidButtonsPanel_Create()
else:
self += CTK.RawHTML ('<p>%s</p>' %(self._msg))
self += CTK.DruidButtonsPanel_Cancel()
def _can_proceed (self):
mods = filter(lambda x: 'streaming' in x, os.listdir(CHEROKEE_PLUGINDIR))
if not len(mods):
self._msg = _("The media streaming plug-in is not installed.")
return False
rules = CTK.cfg.keys('%s!rule'%(self._pre))
for r in rules:
if CTK.cfg.get_val ('%s!rule!%s!match'%(self._pre, r)) != 'extensions':
continue
if CTK.cfg.get_val ('%s!rule!%s!match!extensions'%(self._pre, r)) == EXTENSIONS:
self._msg = _("Media streaming is already configured.")
return False
return True
# Rule
CTK.publish ('^/wizard/vserver/(\d+)/streaming$', Welcome)
CTK.publish (r'^%s'%(APPLY), Commit, method="POST")
|