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

This commit is contained in:
Naomi Aro 2011-07-18 19:48:34 +02:00
commit 7edacd89cc
5 changed files with 137 additions and 39 deletions

View file

@ -25,9 +25,9 @@ class NowplayingController extends Zend_Controller_Action
$userInfo = Zend_Auth::getInstance()->getStorage()->read(); $userInfo = Zend_Auth::getInstance()->getStorage()->read();
$user = new User($userInfo->id); $user = new User($userInfo->id);
if ($request->isPost()) {
$form = new Application_Form_RegisterAirtime(); $form = new Application_Form_RegisterAirtime();
if ($request->isPost()) {
$values = $request->getPost(); $values = $request->getPost();
if ($values["Publicise"] != 1){ if ($values["Publicise"] != 1){
Application_Model_Preference::SetSupportFeedback($values["SupportFeedback"]); Application_Model_Preference::SetSupportFeedback($values["SupportFeedback"]);
@ -64,6 +64,10 @@ class NowplayingController extends Zend_Controller_Action
//popup if previous page was login //popup if previous page was login
if($refer_sses->referrer == 'login' && Application_Model_Nowplaying::ShouldShowPopUp() if($refer_sses->referrer == 'login' && Application_Model_Nowplaying::ShouldShowPopUp()
&& !Application_Model_Preference::GetSupportFeedback() && $user->isAdmin()){ && !Application_Model_Preference::GetSupportFeedback() && $user->isAdmin()){
$form = new Application_Form_RegisterAirtime();
$logo = Application_Model_Preference::GetStationLogo(); $logo = Application_Model_Preference::GetStationLogo();
if($logo){ if($logo){
$this->view->logoImg = $logo; $this->view->logoImg = $logo;

View file

@ -3,8 +3,9 @@
namespace DoctrineMigrations; namespace DoctrineMigrations;
/* /*
update cc_files table to include to "directory" column as well as add foreign key relation to 1) update cc_files table to include to "directory" column
cc_music_dirs table. 2) create a foreign key relationship from cc_files to cc_music_dirs
3) create a foreign key relationship from cc_schedule to cc_files
*/ */
use Doctrine\DBAL\Migrations\AbstractMigration, use Doctrine\DBAL\Migrations\AbstractMigration,
@ -14,21 +15,22 @@ class Version20110711161043 extends AbstractMigration
{ {
public function up(Schema $schema) public function up(Schema $schema)
{ {
/* 1) update cc_files table to include to "directory" column */
//CREATE the default value of "/srv/airtime/stor", this can be updated later in the upgrade script.
$this->_addSql("INSERT INTO cc_music_dirs (type, directory) VALUES ('stor', '/srv/airtime/stor');"); $this->_addSql("INSERT INTO cc_music_dirs (type, directory) VALUES ('stor', '/srv/airtime/stor');");
$this->_addSql("INSERT INTO cc_music_dirs (type, directory) VALUES ('upgrade', '');"); $this->_addSql("INSERT INTO cc_music_dirs (type, directory) VALUES ('upgrade', '');");
$cc_music_dirs = $schema->getTable('cc_music_dirs'); $cc_music_dirs = $schema->getTable('cc_music_dirs');
//start cc_files modifications /* 2) create a foreign key relationship from cc_files to cc_music_dirs */
$cc_files = $schema->getTable('cc_files'); $cc_files = $schema->getTable('cc_files');
$cc_files->addColumn('directory', 'integer', array('default'=> 2)); $cc_files->addColumn('directory', 'integer', array('default'=> 2));
$cc_files->addNamedForeignKeyConstraint('cc_music_dirs_folder_fkey', $cc_music_dirs, array('directory'), array('id'), array('onDelete' => 'CASCADE')); $cc_files->addNamedForeignKeyConstraint('cc_music_dirs_folder_fkey', $cc_music_dirs, array('directory'), array('id'), array('onDelete' => 'CASCADE'));
//end cc_files modifications
/* 3) create a foreign key relationship from cc_schedule to cc_files */
$cc_schedule = $schema->getTable('cc_schedule');
$cc_schedule->addNamedForeignKeyConstraint('cc_files_folder_fkey', $cc_files, array('file_id'), array('id'), array('onDelete' => 'CASCADE'));
} }
public function down(Schema $schema) public function down(Schema $schema)

View file

@ -8,7 +8,9 @@
//Pear classes. //Pear classes.
set_include_path(__DIR__.'/../../airtime_mvc/library/pear' . PATH_SEPARATOR . get_include_path()); set_include_path(__DIR__.'/../../airtime_mvc/library/pear' . PATH_SEPARATOR . get_include_path());
require_once('DB.php'); require_once('DB.php');
require_once(__DIR__.'/../../airtime_mvc/application/configs/constants.php');
require_once(dirname(__FILE__).'/AirtimeIni.php'); require_once(dirname(__FILE__).'/AirtimeIni.php');
if(exec("whoami") != "root"){ if(exec("whoami") != "root"){
@ -87,7 +89,9 @@ if (strcmp($version, "1.9.0") < 0){
//set the new version in the database. //set the new version in the database.
$sql = "DELETE FROM cc_pref WHERE keystr = 'system_version'"; $sql = "DELETE FROM cc_pref WHERE keystr = 'system_version'";
$CC_DBC->query($sql); $CC_DBC->query($sql);
$sql = "INSERT INTO cc_pref (keystr, valstr) VALUES ('system_version', '1.9.0-devel')";
$newVersion = AIRTIME_VERSION;
$sql = "INSERT INTO cc_pref (keystr, valstr) VALUES ('system_version', '$newVersion')";
$CC_DBC->query($sql); $CC_DBC->query($sql);

View file

@ -0,0 +1,83 @@
<?php
/* THIS FILE IS NOT MEANT FOR CUSTOMIZING.
* PLEASE EDIT THE FOLLOWING TO CHANGE YOUR CONFIG:
* /etc/airtime/airtime.conf
* /etc/airtime/pypo.cfg
* /etc/airtime/recorder.cfg
*/
global $CC_CONFIG;
$CC_CONFIG = array(
// prefix for table names in the database
'tblNamePrefix' => 'cc_',
/* ================================================ storage configuration */
'soundcloud-client-id' => '2CLCxcSXYzx7QhhPVHN4A',
'soundcloud-client-secret' => 'pZ7beWmF06epXLHVUP1ufOg2oEnIt9XhE8l8xt0bBs',
"rootDir" => __DIR__."/../..",
'pearPath' => dirname(__FILE__).'/../../../airtime_mvc/library/pear',
'zendPath' => dirname(__FILE__).'/../../../airtime_mvc/library/Zend',
'phingPath' => dirname(__FILE__).'/../../../airtime_mvc/library/phing'
);
$CC_CONFIG = Config::loadConfig($CC_CONFIG);
// Add database table names
$CC_CONFIG['playListTable'] = $CC_CONFIG['tblNamePrefix'].'playlist';
$CC_CONFIG['playListContentsTable'] = $CC_CONFIG['tblNamePrefix'].'playlistcontents';
$CC_CONFIG['filesTable'] = $CC_CONFIG['tblNamePrefix'].'files';
$CC_CONFIG['accessTable'] = $CC_CONFIG['tblNamePrefix'].'access';
$CC_CONFIG['permTable'] = $CC_CONFIG['tblNamePrefix'].'perms';
$CC_CONFIG['sessTable'] = $CC_CONFIG['tblNamePrefix'].'sess';
$CC_CONFIG['subjTable'] = $CC_CONFIG['tblNamePrefix'].'subjs';
$CC_CONFIG['smembTable'] = $CC_CONFIG['tblNamePrefix'].'smemb';
$CC_CONFIG['prefTable'] = $CC_CONFIG['tblNamePrefix'].'pref';
$CC_CONFIG['scheduleTable'] = $CC_CONFIG['tblNamePrefix'].'schedule';
$CC_CONFIG['playListTimeView'] = $CC_CONFIG['tblNamePrefix'].'playlisttimes';
$CC_CONFIG['showSchedule'] = $CC_CONFIG['tblNamePrefix'].'show_schedule';
$CC_CONFIG['showDays'] = $CC_CONFIG['tblNamePrefix'].'show_days';
$CC_CONFIG['showTable'] = $CC_CONFIG['tblNamePrefix'].'show';
$CC_CONFIG['showInstances'] = $CC_CONFIG['tblNamePrefix'].'show_instances';
$CC_CONFIG['playListSequence'] = $CC_CONFIG['playListTable'].'_id';
$CC_CONFIG['filesSequence'] = $CC_CONFIG['filesTable'].'_id';
$CC_CONFIG['prefSequence'] = $CC_CONFIG['prefTable'].'_id';
$CC_CONFIG['permSequence'] = $CC_CONFIG['permTable'].'_id';
$CC_CONFIG['subjSequence'] = $CC_CONFIG['subjTable'].'_id';
$CC_CONFIG['smembSequence'] = $CC_CONFIG['smembTable'].'_id';
// Add libs to the PHP path
$old_include_path = get_include_path();
set_include_path('.'.PATH_SEPARATOR.$CC_CONFIG['pearPath']
.PATH_SEPARATOR.$CC_CONFIG['zendPath']
.PATH_SEPARATOR.$old_include_path);
class Config {
public static function loadConfig($CC_CONFIG) {
$values = parse_ini_file('/etc/airtime/airtime.conf', true);
// Name of the web server user
$CC_CONFIG['webServerUser'] = $values['general']['web_server_user'];
$CC_CONFIG['rabbitmq'] = $values['rabbitmq'];
$CC_CONFIG['baseUrl'] = $values['general']['base_url'];
$CC_CONFIG['basePort'] = $values['general']['base_port'];
// Database config
$CC_CONFIG['dsn']['username'] = $values['database']['dbuser'];
$CC_CONFIG['dsn']['password'] = $values['database']['dbpass'];
$CC_CONFIG['dsn']['hostspec'] = $values['database']['host'];
$CC_CONFIG['dsn']['phptype'] = 'pgsql';
$CC_CONFIG['dsn']['database'] = $values['database']['dbname'];
$CC_CONFIG['apiKey'] = array($values['general']['api_key']);
$CC_CONFIG['soundcloud-connection-retries'] = $values['soundcloud']['connection_retries'];
$CC_CONFIG['soundcloud-connection-wait'] = $values['soundcloud']['time_between_retries'];
return $CC_CONFIG;
}
}

View file

@ -47,10 +47,10 @@ def copy_or_move_files_to(paths, dest, flag):
if( 'mp3' in ext or 'ogg' in ext ): if( 'mp3' in ext or 'ogg' in ext ):
destfile = dest+os.path.basename(path) destfile = dest+os.path.basename(path)
if(flag == 'copy'): if(flag == 'copy'):
print "Copying %(src)s to %(dest)s....." % {'src':path, 'dest':destfile} print "Copying %(src)s to %(dest)s..." % {'src':path, 'dest':destfile}
shutil.copy2(path, destfile) shutil.copy2(path, destfile)
elif(flag == 'move'): elif(flag == 'move'):
print "Moving %(src)s to %(dest)s....." % {'src':path, 'dest':destfile} print "Moving %(src)s to %(dest)s..." % {'src':path, 'dest':destfile}
shutil.move(path, destfile) shutil.move(path, destfile)
else: else:
print "Cannot find file or path: %s" % path print "Cannot find file or path: %s" % path
@ -95,7 +95,7 @@ def printHelp():
======================== ========================
There are two ways to import audio files into Airtime: There are two ways to import audio files into Airtime:
1) Copy or move files into the storage folder 1) Use airtime-import to copy or move files into the storage folder.
Copied or moved files will be placed into the folder: Copied or moved files will be placed into the folder:
%s %s
@ -103,12 +103,12 @@ There are two ways to import audio files into Airtime:
Files will be automatically organized into the structure Files will be automatically organized into the structure
"Artist/Album/TrackNumber-TrackName-Bitrate.file_extension". "Artist/Album/TrackNumber-TrackName-Bitrate.file_extension".
2) Add a folder to the Airtime library("watch" a folder) 2) Use airtime-import to add a folder to the Airtime library ("watch" a folder).
All the files in the watched folder will be imported to Airtime and the All the files in the watched folder will be imported to Airtime and the
folder will be monitored to automatically detect any changes. Hence any folder will be monitored to automatically detect any changes. Hence any
changes done in the folder(add, delete, edit a file) will trigger changes done in the folder(add, delete, edit a file) will trigger
updates in Airtime libarary. updates in Airtime library.
""" % storage_dir """ % storage_dir
parser.print_help() parser.print_help()
print "" print ""
@ -117,7 +117,7 @@ def CopyAction(option, opt, value, parser):
errorIfMultipleOption(parser.rargs) errorIfMultipleOption(parser.rargs)
stor = helper_get_stor_dir() stor = helper_get_stor_dir()
if(stor is None): if(stor is None):
exit("Unable to connect to the server.") exit("Unable to connect to the Airtime server.")
dest = stor+"organize/" dest = stor+"organize/"
copy_or_move_files_to(parser.rargs, dest, 'copy') copy_or_move_files_to(parser.rargs, dest, 'copy')
@ -125,16 +125,16 @@ def MoveAction(option, opt, value, parser):
errorIfMultipleOption(parser.rargs) errorIfMultipleOption(parser.rargs)
stor = helper_get_stor_dir() stor = helper_get_stor_dir()
if(stor is None): if(stor is None):
exit("Unable to connect to the server.") exit("Unable to connect to the Airtime server.")
dest = stor+"organize/" dest = stor+"organize/"
copy_or_move_files_to(parser.rargs, dest, 'move') copy_or_move_files_to(parser.rargs, dest, 'move')
def WatchAddAction(option, opt, value, parser): def WatchAddAction(option, opt, value, parser):
errorIfMultipleOption(parser.rargs) errorIfMultipleOption(parser.rargs)
if(len(parser.rargs) > 1): if(len(parser.rargs) > 1):
raise OptionValueError("Too many arguments. This option need exactly one argument.") raise OptionValueError("Too many arguments. This option requires exactly one argument.")
elif(len(parser.rargs) == 0 ): elif(len(parser.rargs) == 0 ):
raise OptionValueError("No argument found. This option need exactly one argument.") raise OptionValueError("No argument found. This option requires exactly one argument.")
path = parser.rargs[0] path = parser.rargs[0]
if(os.path.isdir(path)): if(os.path.isdir(path)):
res = api_client.add_watched_dir(path) res = api_client.add_watched_dir(path)
@ -144,17 +144,17 @@ def WatchAddAction(option, opt, value, parser):
if(res['msg']['code'] == 0): if(res['msg']['code'] == 0):
print "%s added to watched folder list successfully" % path print "%s added to watched folder list successfully" % path
else: else:
print "Adding a watched folder failed. : %s" % res['msg']['error'] print "Adding a watched folder failed: %s" % res['msg']['error']
else: else:
print "Given path is not a directory: %s" % path print "Given path is not a directory: %s" % path
def WatchListAction(option, opt, value, parser): def WatchListAction(option, opt, value, parser):
errorIfMultipleOption(parser.rargs) errorIfMultipleOption(parser.rargs)
if(len(parser.rargs) > 0): if(len(parser.rargs) > 0):
raise OptionValueError("This option doesn't take any argument.") raise OptionValueError("This option doesn't take any arguments.")
res = api_client.list_all_watched_dirs() res = api_client.list_all_watched_dirs()
if(res is None): if(res is None):
exit("Unable to connect to the server.") exit("Unable to connect to the Airtime server.")
dirs = res["dirs"].items() dirs = res["dirs"].items()
# there will be always 1 which is storage folder # there will be always 1 which is storage folder
if(len(dirs) == 1): if(len(dirs) == 1):
@ -167,21 +167,21 @@ def WatchListAction(option, opt, value, parser):
def WatchRemoveAction(option, opt, value, parser): def WatchRemoveAction(option, opt, value, parser):
errorIfMultipleOption(parser.rargs) errorIfMultipleOption(parser.rargs)
if(len(parser.rargs) > 1): if(len(parser.rargs) > 1):
raise OptionValueError("Too many arguments. This option need exactly one argument.") raise OptionValueError("Too many arguments. This option requires exactly one argument.")
elif(len(parser.rargs) == 0 ): elif(len(parser.rargs) == 0 ):
raise OptionValueError("No argument found. This option need exactly one argument.") raise OptionValueError("No argument found. This option requires exactly one argument.")
path = parser.rargs[0] path = parser.rargs[0]
if(os.path.isdir(path)): if(os.path.isdir(path)):
res = api_client.remove_watched_dir(path) res = api_client.remove_watched_dir(path)
if(res is None): if(res is None):
exit("Unable to connect to the server.") exit("Unable to connect to the Airtime server.")
# sucess # sucess
if(res['msg']['code'] == 0): if(res['msg']['code'] == 0):
print "%s removed from watched folder list successfully" % path print "%s removed from watch folder list successfully." % path
else: else:
print "Removing a watched folder failed. : %s" % res['msg']['error'] print "Removing the watch folder failed: %s" % res['msg']['error']
else: else:
print "Given path is not a directory: %s" % path print "The given path is not a directory: %s" % path
def StorageSetAction(option, opt, value, parser): def StorageSetAction(option, opt, value, parser):
bypass = False bypass = False
@ -195,37 +195,42 @@ def StorageSetAction(option, opt, value, parser):
parser.rargs.remove('--force') parser.rargs.remove('--force')
if(not bypass): if(not bypass):
errorIfMultipleOption(parser.rargs, "Only [-f] and [--force] option is allowed with this option.") errorIfMultipleOption(parser.rargs, "Only [-f] and [--force] option is allowed with this option.")
confirm = raw_input("Are you sure you want to change the storage direcory? (Y/n)") possibleInput = {'y','Y','n','N'}
confirm = confirm or 'Y' confirm = raw_input("Are you sure you want to change the storage direcory? (y/N) ")
if(confirm != 'Y'): confirm = confirm or 'N'
while(confirm not in possibleInput):
print "Not an acceptable input: %s\n" % confirm
confirm = raw_input("Are you sure you want to change the storage direcory? (y/N) ")
confirm = confirm or 'N'
if(confirm == 'n' or confirm =='N'):
sys.exit(1) sys.exit(1)
if(len(parser.rargs) > 1): if(len(parser.rargs) > 1):
raise OptionValueError("Too many arguments. This option need exactly one argument.") raise OptionValueError("Too many arguments. This option requires exactly one argument.")
elif(len(parser.rargs) == 0 ): elif(len(parser.rargs) == 0 ):
raise OptionValueError("No argument found. This option need exactly one argument.") raise OptionValueError("No argument found. This option requires exactly one argument.")
path = parser.rargs[0] path = parser.rargs[0]
if(os.path.isdir(path)): if(os.path.isdir(path)):
res = api_client.set_storage_dir(path) res = api_client.set_storage_dir(path)
if(res is None): if(res is None):
exit("Unable to connect to the server.") exit("Unable to connect to the Airtime server.")
# sucess # sucess
if(res['msg']['code'] == 0): if(res['msg']['code'] == 0):
print "Successfully set storage folder to %s" % path print "Successfully set storage folder to %s" % path
else: else:
print "Setting storage folder to failed.: %s" % res['msg']['error'] print "Setting storage folder failed: %s" % res['msg']['error']
else: else:
print "Given path is not a directory: %s" % path print "The given path is not a directory: %s" % path
def StorageGetAction(option, opt, value, parser): def StorageGetAction(option, opt, value, parser):
errorIfMultipleOption(parser.rargs) errorIfMultipleOption(parser.rargs)
if(len(parser.rargs) > 0): if(len(parser.rargs) > 0):
raise OptionValueError("This option doesn't take any argument.") raise OptionValueError("This option does not take any arguments.")
print helper_get_stor_dir() print helper_get_stor_dir()
usage = """[-c|--copy FILE/DIR [FILE/DIR...]] [-m|--move FILE/DIR [FILE/DIR...]] usage = """[-c|--copy FILE/DIR [FILE/DIR...]] [-m|--move FILE/DIR [FILE/DIR...]]
[--watch-add DIR] [--watch-list] [--watch-remve DIR] [--watch-add DIR] [--watch-list] [--watch-remove DIR]
[--storage-dir-set DIR] [--storage-dir-get]""" [--storage-dir-set DIR] [--storage-dir-get]"""
parser = OptionParser(usage=usage, add_help_option=False) parser = OptionParser(usage=usage, add_help_option=False)