Merge branch 'devel' of dev.sourcefabric.org:airtime into devel

This commit is contained in:
James 2011-11-10 15:35:52 -05:00
commit 56a6da51a9
16 changed files with 278 additions and 68 deletions

View File

@ -81,7 +81,7 @@ class Application_Form_AddUser extends Zend_Form
$submit = new Zend_Form_Element_Submit('submit');
$submit->setAttrib('class', 'ui-button ui-state-default right-floated');
$submit->setIgnore(true);
$submit->setLabel('Submit');
$submit->setLabel('Save');
$this->addElement($submit);
}

View File

@ -16,7 +16,7 @@ class Application_Form_AdvancedSearch extends Zend_Form
// Add the submit button
$this->addElement('button', 'search_submit', array(
'ignore' => true,
'label' => 'Submit',
'label' => 'Save',
'order' => '-1'
));
$this->getElement('search_submit')->removeDecorator('DtDdWrapper');

View File

@ -134,7 +134,7 @@ class Application_Form_EditAudioMD extends Zend_Form
$this->addElement('submit', 'submit', array(
'ignore' => true,
'class' => 'ui-button ui-state-default',
'label' => 'Submit',
'label' => 'Save',
'decorators' => array(
'ViewHelper'
)

View File

@ -24,7 +24,7 @@ class Application_Form_PlaylistMetadata extends Zend_Form{
// Add the comment element
$this->addElement('button', 'new_playlist_submit', array(
'label' => 'Submit',
'label' => 'Save',
'ignore' => true
));
}

View File

@ -1,5 +1,7 @@
<?php
require_once 'customfilters/ImageSize.php';
class Application_Form_RegisterAirtime extends Zend_Form
{
@ -102,12 +104,8 @@ class Application_Form_RegisterAirtime extends Zend_Form
->setRequired(false)
->setDecorators(array('File'))
->addValidator('Count', false, 1)
->addValidator('Extension', false, 'jpg,png,gif')
->addValidator('ImageSize', false, array(
'minwidth' => 200,
'minheight' => 200,
'maxwidth' => 600,
'maxheight' => 600));
->addValidator('Extension', false, 'jpg,jpeg,png,gif')
->addFilter('ImageSize');
$this->addElement($upload);
//enable support feedback

View File

@ -1,5 +1,7 @@
<?php
require_once 'customfilters/ImageSize.php';
class Application_Form_SupportSettings extends Zend_Form
{
@ -99,12 +101,8 @@ class Application_Form_SupportSettings extends Zend_Form
->setRequired(false)
->setDecorators(array('File'))
->addValidator('Count', false, 1)
->addValidator('Extension', false, 'jpg,png,gif')
->addValidator('ImageSize', false, array(
'minwidth' => 200,
'minheight' => 200,
'maxwidth' => 600,
'maxheight' => 600));
->addValidator('Extension', false, 'jpg,jpeg,png,gif')
->addFilter('ImageSize');
$upload->setAttrib('accept', 'image/jpeg,image/gif,image/png,image/jpg');
$this->addElement($upload);
@ -153,7 +151,7 @@ class Application_Form_SupportSettings extends Zend_Form
$submit = new Zend_Form_Element_Submit("submit");
$submit->class = 'ui-button ui-state-default right-floated';
$submit->setIgnore(true)
->setLabel("Submit")
->setLabel("Save")
->setDecorators(array('ViewHelper'));
$this->addElement($submit);
}

View File

@ -0,0 +1,42 @@
<?php
class Zend_Filter_ImageSize implements Zend_Filter_Interface {
public function filter($value) {
if(!file_exists($value)) {
throw new Zend_Filter_Exception('Image does not exist: ' . $value);
}
$image = imageCreateFromString(file_get_contents($value));
if(false === $image) {
throw new Zend_Filter_Exception('Can\'t load image: ' . $value);
}
// find ratio to scale down to
// TODO: pass 600 as parameter in the future
$origWidth = imagesx($image);
$origHeight = imagesy($image);
$ratio = max($origWidth, $origHeight) / 600;
if($ratio < 1) {
return;
}
// create a scaled down image
$newWidth = round($origWidth / $ratio);
$newHeight = round($origHeight / $ratio);
$resized = imagecreatetruecolor($newWidth, $newHeight);
imagecopyresampled($resized, $image, 0, 0, 0, 0, $newWidth, $newHeight, $origWidth, $origHeight);
// determine type and store to disk
$explodeResult = explode(".", $value);
$type = $explodeResult[count($explodeResult) - 1];
$writeFunc = 'image' . $type;
if($type == 'jpeg' || $type == 'jpg') {
imagejpeg($resized, $value, 100);
} else {
$writeFunc($resized, $value);
}
}
}
?>

View File

@ -144,7 +144,7 @@
<?php }?>
<?php echo $this->element->getElement('Logo') ?>
<p class="info-text">Min. size: 200x200 Max. size: 600x600</p>
<p class="info-text">Note: Anything larger than 600x600 will be resized.</p>
<?php if($this->element->getElement('Logo')->hasErrors()) : ?>
<ul class='errors'>
<?php foreach($this->element->getElement('Logo')->getMessages() as $error): ?>

View File

@ -138,7 +138,7 @@
<?php }?>
<?php echo $this->element->getElement('Logo') ?>
<div class="info-text"><p>Min. size: 200x200 Max. size: 600x600</p></div>
<div class="info-text"><p>Note: Anything larger than 600x600 will be resized.</p></div>
<?php if($this->element->getElement('Logo')->hasErrors()) : ?>
<ul class='errors'>
<?php foreach($this->element->getElement('Logo')->getMessages() as $error): ?>

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@ -241,7 +241,7 @@ select {
color:#a5a5a5;
}
.listen-control-block a {
.listen-control-block a, .listen-control-button {
font-size:11px;
text-transform:uppercase;
padding:0;
@ -251,9 +251,13 @@ select {
font-weight:bold;
margin-top:34px;
display:block;
text-align:center;
}
.listen-control-block a span {
.listen-control-button {
margin-top:6px;
}
.listen-control-block a span, .listen-control-button span {
background-color: #6e6e6e;
background: -moz-linear-gradient(top, #868686 0, #6e6e6e 100%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0, #868686), color-stop(100%, #6e6e6e));
@ -265,10 +269,13 @@ select {
text-shadow: #555555 0px -1px;
display:block;
}
.listen-control-block a:hover {
.listen-control-button span {
padding:2px 10px;
}
.listen-control-block a:hover, .listen-control-button:hover {
border:1px solid #000;
}
.listen-control-block a:hover span {
.listen-control-block a:hover span, .listen-control-button:hover span {
background-color: #292929;
background: -moz-linear-gradient(top, #3b3b3b 0, #292929 100%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0, #3b3b3b), color-stop(100%, #292929));
@ -1212,7 +1219,8 @@ button, input {
.button-bar-top .input_text {
height:25px;
margin-right:6px
margin-right:6px;
padding: 0 3px;
}
.button-bar-top .input_text.hasDatepicker, .input_text.hasDatepicker {
background-image:url(images/input_with_calendar_bg.png);
@ -1618,6 +1626,10 @@ div.success{
width: 500px;
}
.preferences .padded {
margin-top: 5px; /* Firefox needs this */
}
dt.block-display, dd.block-display {
display: block;
float: none;
@ -1944,7 +1956,16 @@ dd .info-text-small {
/*width:98.5%;*/
min-width:152px;
}
.stream-config .display_field dd input[type="text"], .stream-config .display_field dd textarea {
min-width:99%;
padding: 4px 3px;
}
.stream-config .display_field dd textarea {
min-height:60px;
}
.simple-formblock .display_field dd {
min-width:68%;
}
.stream-config dd input[id$=port] {
width:152px;
}
@ -2300,4 +2321,55 @@ tfoot tr th {
-webkit-box-shadow: rgba(0, 0, 0, 0.4) 0 2px 2px inset;
}
#stream_url {font-size:12px; line-height: 170%;}
.stream-setting-content fieldset {border-width:0 1px 1px 1px;}
.stream-setting-content fieldset {border-width:0 1px 1px 1px;}
.stream-setting-content fieldset {
border-width: 0 1px 1px;
}
.stream-setting-content fieldset.display_field {
border: 1px solid #8F8F8F;
padding: 10px;
}
.stream-setting-content fieldset.display_field.closed {
border-width: 1px 0 0;
}
/*---//////////////////// STREAM SETTINGS STATUS ////////////////////---*/
.stream-status {
border: 1px solid;
padding:2px 10px 4px 22px;
margin:2px 1px 10px 0px;
width: auto;
}
.stream-status h3 {
font-size: 12px;
font-weight: bold;
line-height: 12px;
padding:0;
margin:5px 4px 2px 4px;
}
.stream-status p {
padding:0;
margin:2px 3px 1px 4px;
color:#4F4F4F;
font-size: 11px;
}
.stream-config dd.stream-status {
padding:2px 10px 4px 22px;
margin:4px 0 10px 14px;
width: 65%;
}
.status-good {
background:#e3ffc9 url(images/stream_status.png) no-repeat 5px 5px;
border-color:#54b300;
}
.status-good h3 {
color:#54b300;
}
.status-error {
background:#ffeded url(images/stream_status.png) no-repeat 5px -128px;
border-color:#f90000;
}
.status-error h3 {
color:#DA0101;
}

View File

@ -1,8 +1,19 @@
#Airtime install/upgrade infrastructure
#author martin.konecny@sourcefabric.org
#Documentation for this page:
#http://wiki.sourcefabric.org/x/OwCD
import os
import time
import sys
from fabric.api import *
from fabric.contrib.files import comment, sed, append
from xml.dom.minidom import parse
from xml.dom.minidom import Node
from xml.dom.minidom import Element
env.user = 'martin'
env.password = 'test'
@ -14,6 +25,10 @@ env.vm_download_url = "http://host.sourcefabric.org/vms/VirtualBox"
#fab -f fab_setup.py ubuntu_lucid_64 airtime_182_tar airtime_190_tar
def shutdown():
sudo("shutdown -hP now")
time.sleep(30)
def test():
x = sudo('airtime-check-system')
print x.failed
@ -26,68 +41,110 @@ def download_if_needed(vdi_dir, xml_dir, vm_name, vm_vdi_file, vm_xml_file):
if os.path.exists(os.path.join(vdi_dir, vm_vdi_file)):
print "File %s already exists. No need to re-download" % os.path.join(vdi_dir, vm_vdi_file)
downloaded = False
else:
print "File %s not found. Downloading" % vm_vdi_file
local("wget %s/%s/%s -O %s"%(env.vm_download_url, vm_name, vm_vdi_file, os.path.join(vdi_dir, vm_vdi_file)))
downloaded = True
tmpPath = local("mktemp", capture=True)
local("wget %s/%s/%s -O %s"%(env.vm_download_url, vm_name, vm_vdi_file, tmpPath))
os.rename(tmpPath, os.path.join(vdi_dir, vm_vdi_file))
if os.path.exists(os.path.join(xml_dir, vm_xml_file)):
print "File %s already exists. No need to re-download" % os.path.join(xml_dir, vm_xml_file)
else:
print "File %s not found. Downloading" % vm_xml_file
local("wget %s/%s/%s -O %s"%(env.vm_download_url, vm_name, vm_xml_file, os.path.join(xml_dir, vm_xml_file)))
return downloaded
local("rm -f %s"%os.path.join(xml_dir, vm_xml_file))
local("wget %s/%s/%s -O %s"%(env.vm_download_url, vm_name, vm_xml_file, os.path.join(xml_dir, vm_xml_file)))
def create_fresh_os(os_version, os_arch):
def create_fresh_os(vm_name, update_virtualenv=False, debian=False):
vm_name = 'Ubuntu_%s_%s'%(os_version, os_arch)
vm_vdi_file = 'Ubuntu_%s_%s.vdi'%(os_version, os_arch)
vm_xml_file = 'Ubuntu_%s_%s.xml'%(os_version, os_arch)
vm_vdi_file = '%s.vdi'%vm_name
vm_xml_file = '%s.xml'%vm_name
vdi_dir = os.path.expanduser('~/tmp/vms/%s'%vm_name)
vdi_snapshot_dir = os.path.expanduser('~/tmp/vms/%s/Snapshots'%vm_name)
xml_dir = os.path.expanduser('~/.VirtualBox')
vm_xml_path = os.path.join(xml_dir, vm_xml_file)
downloaded = download_if_needed(vdi_dir, xml_dir, vm_name, vm_vdi_file, vm_xml_file)
if downloaded:
"""
if not os.path.exists("%s/vm_registered"%vdi_dir) and os.path.exists(vm_xml_path):
#vm_xml file exists, but it wasn't registered. Did something go wrong on a previous attempt?
#Let's attempt to correct this by completely removing the virtual machine.
dom = parse(vm_xml_path)
root = dom.childNodes[0]
rootChildren = root.childNodes
#manually remove all snapshots before removing virtual machine
for rc in rootChildren:
if rc.nodeType == Node.ELEMENT_NODE and rc.localName == "Machine":
snapshotNodes = rc.getElementsByTagName("Snapshot")
for sn in snapshotNodes:
local("VBoxManage snapshot %s delete %s"% (vm_name, sn.getAttribute("uuid")[1:-1]))
os.remove(vm_xml_path)
local("VBoxManage unregistervm %s --delete"% vm_name)
"""
download_if_needed(vdi_dir, xml_dir, vm_name, vm_vdi_file, vm_xml_file)
if not os.path.exists("%s/vm_registered"%vdi_dir):
local("VBoxManage registervm %s"%os.path.join(xml_dir, vm_xml_file), capture=True)
local('VBoxManage storagectl "%s" --name "SATA Controller" --add sata'%vm_name)
local('VBoxManage storageattach "%s" --storagectl "SATA Controller" --port 0 --type hdd --medium %s'%(vm_name, os.path.join(vdi_dir, vm_vdi_file)))
local("VBoxManage snapshot %s take fresh_install"%vm_name)
local('VBoxManage storageattach "%s" --storagectl "SATA Controller" --port 0 --device 0 --type hdd --medium %s'%(vm_name, os.path.join(vdi_dir, vm_vdi_file)))
local("VBoxManage modifyvm %s --snapshotfolder %s"%(vm_name, vdi_snapshot_dir))
#else:
# local('VBoxManage snapshot %s restore fresh_install'%vm_name)
local("VBoxManage snapshot %s take fresh_install"%vm_name)
local("touch %s/vm_registered"%vdi_dir)
local('VBoxManage snapshot %s restore fresh_install'%vm_name)
local('VBoxManage startvm %s'%vm_name)
print "Please wait while attempting to acquire IP address"
time.sleep(15)
try_again = True
while try_again:
ret = local('VBoxManage --nologo guestproperty get "%s" /VirtualBox/GuestInfo/Net/0/V4/IP'%vm_name, capture=True)
triple = ret.partition(':')
ip_addr = triple[2].strip(' \r\n')
print "Address found %s"%ip_addr
try_again = (len(ip_addr) == 0)
time.sleep(1)
time.sleep(30)
ret = local('VBoxManage --nologo guestproperty get "%s" /VirtualBox/GuestInfo/Net/0/V4/IP'%vm_name, capture=True)
triple = ret.partition(':')
ip_addr = triple[2].strip(' \r\n')
print "Address found %s"%ip_addr
env.hosts.append(ip_addr)
env.host_string = ip_addr
if update_virtualenv:
print "Lucid detected - updating python virtualenv"
sudo('apt-get update')
sudo('apt-get install -y python-setuptools')
sudo('wget http://apt.sourcefabric.org/pool/main/p/python-virtualenv/python-virtualenv_1.4.9-3_all.deb')
sudo('dpkg -i python-virtualenv_1.4.9-3_all.deb')
if debian:
append('/etc/apt/sources.list', "deb http://www.debian-multimedia.org squeeze main non-free", use_sudo=True)
def ubuntu_lucid_32(fresh_os=True):
if (fresh_os):
create_fresh_os('10.04', '32')
create_fresh_os('Ubuntu_10.04_32', update_virtualenv=True)
def ubuntu_lucid_64(fresh_os=True):
if (fresh_os):
create_fresh_os('10.04', '64')
create_fresh_os('Ubuntu_10.04_64', update_virtualenv=True)
def ubuntu_natty_32(fresh_os=True):
if (fresh_os):
create_fresh_os('11.04', '32')
create_fresh_os('Ubuntu_11.04_32')
def ubuntu_natty_64(fresh_os=True):
if (fresh_os):
create_fresh_os('11.04', '64')
create_fresh_os('Ubuntu_11.04_64')
def debian_squeeze_32(fresh_os=True):
if (fresh_os):
create_fresh_os('Debian_Squeeze_32', debian=True)
def debian_squeeze_64(fresh_os=True):
if (fresh_os):
create_fresh_os('Debian_Squeeze_64', debian=True)
def airtime_182_tar():
sudo('apt-get update')
sudo('apt-get install -y tar gzip unzip apache2 php5-pgsql libapache2-mod-php5 ' + \
@ -123,13 +180,23 @@ def airtime_182_tar():
run('tar xfz airtime-1.8.2.tar.gz')
sudo('cd ~/airtime-1.8.2/install && php airtime-install.php')
#need to reboot because of daemon-tools.
reboot(45)
sudo('airtime-check-system')
def airtime_194_tar():
#1.9.4 doesn't do apt-get update during install, and therefore the package index
#files are not resynchronized. Need to do this here.
sudo('apt-get update')
run('wget http://downloads.sourceforge.net/project/airtime/1.9.4/airtime-1.9.4.tar.gz')
run('tar xfz airtime-1.9.4.tar.gz')
sudo('cd ~/airtime-1.9.4/install_full/ubuntu && ./airtime-full-install')
sudo('cd /home/martin/airtime-1.9.4/install_full/ubuntu && ./airtime-full-install')
def airtime_195_tar():
run('wget http://downloads.sourceforge.net/project/airtime/1.9.5-RC5/airtime-1.9.5-RC5.tar.gz')
run('tar xfz airtime-1.9.5-RC5.tar.gz')
sudo('cd /home/martin/airtime-1.9.5/install_full/ubuntu && ./airtime-full-install')
def airtime_latest_deb():
append('/etc/apt/sources.list', "deb http://apt.sourcefabric.org/ lucid main", use_sudo=True)
@ -141,11 +208,11 @@ def airtime_latest_deb():
sudo('apt-get purge -y pulseaudio')
sudo('apt-get install -y --force-yes airtime')
def airtime_devel():
def airtime_git_branch(branch="devel"):
sudo('apt-get update')
sudo('apt-get install -y git-core')
run('git clone https://github.com/sourcefabric/Airtime.git ~/airtime')
sudo('cd ~/airtime && git checkout devel && install_full/ubuntu/airtime-full-install || true')
sudo('cd /home/martin/airtime && git checkout %s && install_full/ubuntu/airtime-full-install || true' % branch)
def airtime_200():

21
dev_tools/fabric/run.sh Executable file
View File

@ -0,0 +1,21 @@
#!/bin/bash
exec 2>&1
target="airtime_195_tar"
airtime_versions=("" "airtime_182_tar" "airtime_194_tar")
ubuntu_versions=("ubuntu_lucid_32" "ubuntu_natty_32")
num1=${#ubuntu_versions[@]}
num2=${#airtime_versions[@]}
for i in $(seq 0 $(($num1 -1)));
do
for j in $(seq 0 $(($num2 -1)));
do
echo fab -f fab_setup.py ${ubuntu_versions[$i]} ${airtime_versions[$j]} $target shutdown
fab -f fab_setup.py ${ubuntu_versions[$i]} ${airtime_versions[$j]} $target shutdown 2>&1 | tee "${ubuntu_versions[$i]}_${airtime_versions[$j]}_$target.log"
done
done

View File

@ -45,10 +45,7 @@ python $AIRTIMEROOT/python_apps/create-pypo-user.py
$SCRIPTPATH/include/airtime-copy-files.sh
$SCRIPTPATH/include/airtime-initialize.sh $@
#Hack to parse rabbitmq pid and place it into the correct directory. This is also
#done in our rabbitmq init.d script, but placing it here so that monit recognizes
# it faster (in time for the airtime-check-system)
sed "s/.*,\(.*\)\}.*/\1/" /var/lib/rabbitmq/pids > /var/run/rabbitmq.pid
/usr/lib/airtime/utils/rabbitmq-update-pid.sh
echo -e "\n*** Verifying your system environment, running airtime-check-system ***"
sleep 10

View File

@ -6,5 +6,5 @@
check process rabbitmq-server
with pidfile "/var/run/rabbitmq.pid"
start program = "/bin/bash -c '/etc/init.d/rabbitmq-server start; sed "s/.*,\(.*\)\}.*/\1/" /var/lib/rabbitmq/pids > /var/run/rabbitmq.pid'"
start program = "/bin/bash -c '/etc/init.d/rabbitmq-server start; /usr/lib/airtime/utils/rabbitmq-update-pid.sh'"
stop program = "/etc/init.d/rabbitmq-server stop"

15
utils/rabbitmq-update-pid.sh Executable file
View File

@ -0,0 +1,15 @@
#!/bin/bash
#Hack to parse rabbitmq pid and place it into the correct directory. This is also
#done in our rabbitmq init.d script, but placing it here so that monit recognizes
# it faster (in time for the upcoming airtime-check-system)
codename=`lsb_release -cs`
if [ "$codename" == "oneiric" ];
then
rabbitmqstatus=`/etc/init.d/rabbitmq-server status | grep "\[{pid"`
rabbitmqpid=`echo $rabbitmqstatus | sed "s/.*,\(.*\)\}.*/\1/"`
else
rabbitmqpid=`sed "s/.*,\(.*\)\}.*/\1/" /var/lib/rabbitmq/pids`
fi
echo "RabbitMQ PID: $rabbitmqpid"
echo "$rabbitmqpid" > /var/run/rabbitmq.pid