Merge branch '1.9.1' into devel
Conflicts: airtime_mvc/library/php-amqplib/demo/amqp_publisher.php
This commit is contained in:
commit
386e966080
4 changed files with 73 additions and 19 deletions
|
@ -14,7 +14,7 @@ $PORT = 5672;
|
|||
$USER = 'guest';
|
||||
$PASS = 'guest';
|
||||
$VHOST = '/';
|
||||
$EXCHANGE = 'router';
|
||||
$EXCHANGE = 'airtime-schedule';
|
||||
$QUEUE = 'msgs';
|
||||
$CONSUMER_TAG = 'consumer';
|
||||
|
||||
|
@ -23,7 +23,7 @@ $ch = $conn->channel();
|
|||
$ch->access_request($VHOST, false, false, true, true);
|
||||
|
||||
$ch->queue_declare($QUEUE);
|
||||
$ch->exchange_declare($EXCHANGE, 'direct', false, false, false);
|
||||
$ch->exchange_declare($EXCHANGE, 'direct', false, true);
|
||||
$ch->queue_bind($QUEUE, $EXCHANGE);
|
||||
|
||||
function process_message($msg) {
|
||||
|
|
|
@ -13,7 +13,8 @@ $PORT = 5672;
|
|||
$USER = 'guest';
|
||||
$PASS = 'guest';
|
||||
$VHOST = '/';
|
||||
$EXCHANGE = 'airtime-pypo';
|
||||
$EXCHANGE = 'airtime-schedule';
|
||||
|
||||
$QUEUE = 'msgs';
|
||||
|
||||
$conn = new AMQPConnection($HOST, $PORT, $USER, $PASS);
|
||||
|
@ -30,4 +31,5 @@ $ch->basic_publish($msg, $EXCHANGE);
|
|||
echo "Sent message '".$msg_body."'\n";
|
||||
$ch->close();
|
||||
$conn->close();
|
||||
|
||||
?>
|
||||
|
|
|
@ -20,10 +20,57 @@ class Airtime194Upgrade{
|
|||
exec("cp -R ".$AIRTIME_SRC."/* ".$phpDir);
|
||||
}
|
||||
|
||||
public static function ModifyHtAccessTimezone($phpDir){
|
||||
$file = realpath($phpDir)."/public/.htaccess";
|
||||
|
||||
$fn = "/etc/timezone";
|
||||
$handle = @fopen($fn, "r");
|
||||
if ($handle){
|
||||
$timezone = trim(fgets($handle, 4096));
|
||||
fclose($handle);
|
||||
} else {
|
||||
echo "Could not open $fn";
|
||||
}
|
||||
|
||||
$key = "php_value date.timezone";
|
||||
//the best way to do this is use cli utility "sed", but I don't have time to learn this
|
||||
$handle = @fopen($file, "r");
|
||||
if ($handle) {
|
||||
while (($buffer = fgets($handle, 4096)) !== false) {
|
||||
if (strlen($key) > $buffer){
|
||||
if (substr($buffer, 0, strlen($key)) == $key){
|
||||
$output[] = "$key \"$timezone\"".PHP_EOL;
|
||||
} else {
|
||||
$output[] = $buffer;
|
||||
}
|
||||
} else {
|
||||
$output[] = $buffer;
|
||||
}
|
||||
}
|
||||
if (!feof($handle)) {
|
||||
echo "Error: unexpected fgets() fail\n";
|
||||
}
|
||||
fclose($handle);
|
||||
} else {
|
||||
echo "Could not open $file";
|
||||
}
|
||||
|
||||
$handle = @fopen($file, 'w');
|
||||
if ($handle) {
|
||||
foreach ($output as $line){
|
||||
fwrite($handle, $line);
|
||||
}
|
||||
fclose($handle);
|
||||
} else {
|
||||
echo "Could not open $file";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$values = parse_ini_file(AirtimeIni194::CONF_FILE_AIRTIME, true);
|
||||
$values = parse_ini_file(Airtime194Upgrade::CONF_FILE_AIRTIME, true);
|
||||
$phpDir = $values['general']['airtime_dir'];
|
||||
Airtime194Upgrade::InstallAirtimePhpServerCode($phpDir);
|
||||
Airtime194Upgrade::ModifyHtAccessTimezone($phpDir);
|
||||
Airtime194Upgrade::upgradeLiquidsoapCfgPerms();
|
||||
|
||||
|
|
|
@ -84,10 +84,8 @@ def checkOtherOption(args):
|
|||
def errorIfMultipleOption(args, msg=''):
|
||||
if(checkOtherOption(args)):
|
||||
if(msg != ''):
|
||||
printHelp()
|
||||
raise OptionValueError(msg)
|
||||
else:
|
||||
printHelp()
|
||||
raise OptionValueError("This option cannot be combined with other options")
|
||||
|
||||
def printHelp():
|
||||
|
@ -123,18 +121,17 @@ There are two ways to import audio files into Airtime:
|
|||
def CopyAction(option, opt, value, parser):
|
||||
errorIfMultipleOption(parser.rargs)
|
||||
if(len(parser.rargs) == 0 ):
|
||||
printHelp()
|
||||
raise OptionValueError("No argument found. This option requires at least one argument.")
|
||||
stor = helper_get_stor_dir()
|
||||
if(stor is None):
|
||||
exit("Unable to connect to the Airtime server.")
|
||||
print "Unable to connect to the Airtime server."
|
||||
return
|
||||
dest = stor+"organize/"
|
||||
copy_or_move_files_to(parser.rargs, dest, 'copy')
|
||||
|
||||
def MoveAction(option, opt, value, parser):
|
||||
errorIfMultipleOption(parser.rargs)
|
||||
if(len(parser.rargs) == 0 ):
|
||||
printHelp()
|
||||
raise OptionValueError("No argument found. This option requires at least one argument.")
|
||||
stor = helper_get_stor_dir()
|
||||
if(stor is None):
|
||||
|
@ -145,10 +142,8 @@ def MoveAction(option, opt, value, parser):
|
|||
def WatchAddAction(option, opt, value, parser):
|
||||
errorIfMultipleOption(parser.rargs)
|
||||
if(len(parser.rargs) > 1):
|
||||
printHelp()
|
||||
raise OptionValueError("Too many arguments. This option requires exactly one argument.")
|
||||
elif(len(parser.rargs) == 0 ):
|
||||
printHelp()
|
||||
raise OptionValueError("No argument found. This option requires exactly one argument.")
|
||||
path = parser.rargs[0]
|
||||
if (path[0] == "/" or path[0] == "~"):
|
||||
|
@ -171,7 +166,6 @@ def WatchAddAction(option, opt, value, parser):
|
|||
def WatchListAction(option, opt, value, parser):
|
||||
errorIfMultipleOption(parser.rargs)
|
||||
if(len(parser.rargs) > 0):
|
||||
printHelp()
|
||||
raise OptionValueError("This option doesn't take any arguments.")
|
||||
res = api_client.list_all_watched_dirs()
|
||||
if(res is None):
|
||||
|
@ -188,10 +182,8 @@ def WatchListAction(option, opt, value, parser):
|
|||
def WatchRemoveAction(option, opt, value, parser):
|
||||
errorIfMultipleOption(parser.rargs)
|
||||
if(len(parser.rargs) > 1):
|
||||
printHelp()
|
||||
raise OptionValueError("Too many arguments. This option requires exactly one argument.")
|
||||
elif(len(parser.rargs) == 0 ):
|
||||
printHelp()
|
||||
raise OptionValueError("No argument found. This option requires exactly one argument.")
|
||||
path = parser.rargs[0]
|
||||
if (path[0] == "/" or path[0] == "~"):
|
||||
|
@ -234,10 +226,8 @@ def StorageSetAction(option, opt, value, parser):
|
|||
sys.exit(1)
|
||||
|
||||
if(len(parser.rargs) > 1):
|
||||
printHelp()
|
||||
raise OptionValueError("Too many arguments. This option requires exactly one argument.")
|
||||
elif(len(parser.rargs) == 0 ):
|
||||
printHelp()
|
||||
raise OptionValueError("No argument found. This option requires exactly one argument.")
|
||||
|
||||
path = parser.rargs[0]
|
||||
|
@ -261,10 +251,13 @@ def StorageSetAction(option, opt, value, parser):
|
|||
def StorageGetAction(option, opt, value, parser):
|
||||
errorIfMultipleOption(parser.rargs)
|
||||
if(len(parser.rargs) > 0):
|
||||
printHelp()
|
||||
raise OptionValueError("This option does not take any arguments.")
|
||||
print helper_get_stor_dir()
|
||||
|
||||
class OptionValueError(RuntimeError):
|
||||
def __init__(self, msg):
|
||||
self.msg = msg
|
||||
|
||||
usage = """[-c|--copy FILE/DIR [FILE/DIR...]] [-m|--move FILE/DIR [FILE/DIR...]]
|
||||
[--watch-add DIR] [--watch-list] [--watch-remove DIR]
|
||||
[--storage-dir-set DIR] [--storage-dir-get]"""
|
||||
|
@ -294,7 +287,19 @@ if(len(sys.argv) == 1 or '-' not in sys.argv[1]):
|
|||
printHelp()
|
||||
sys.exit()
|
||||
|
||||
(option, args) = parser.parse_args()
|
||||
try:
|
||||
(option, args) = parser.parse_args()
|
||||
except Exception, e:
|
||||
printHelp()
|
||||
if hasattr(e, 'msg'):
|
||||
print "Error: "+e.msg
|
||||
else:
|
||||
print "Error: "+e
|
||||
sys.exit()
|
||||
except SystemExit:
|
||||
printHelp()
|
||||
sys.exit()
|
||||
|
||||
if option.help:
|
||||
printHelp()
|
||||
sys.exit()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue