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

This commit is contained in:
James 2011-07-29 10:33:55 -04:00
commit 2bde3298e4
8 changed files with 56 additions and 63 deletions

View file

@ -213,24 +213,6 @@ function MergeConfigFiles($configFiles, $suffix)
}
}
function InstallPhpCode()
{
global $CC_CONFIG;
global $AIRTIME_SRC;
echo "* Installing PHP code to ".$CC_CONFIG['phpDir'].PHP_EOL;
exec("mkdir -p ".$CC_CONFIG['phpDir']);
exec("cp -R ".$AIRTIME_SRC."/* ".$CC_CONFIG['phpDir']);
}
function InstallBinaries()
{
global $AIRTIME_UTILS;
echo "* Installing binaries to ".CONF_DIR_BINARIES.PHP_EOL;
exec("mkdir -p ".CONF_DIR_BINARIES);
exec("cp -R ".$AIRTIME_UTILS." ".CONF_DIR_BINARIES);
}
// Backup the config files
$suffix = date("Ymdhis")."-1.8.1";
foreach ($configFiles as $conf) {
@ -245,6 +227,3 @@ echo "* Initializing INI files".PHP_EOL;
MergeConfigFiles($configFiles, $suffix);
$CC_CONFIG = LoadConfig($CC_CONFIG);
InstallPhpCode();
InstallBinaries();

View file

@ -213,23 +213,6 @@ function MergeConfigFiles($configFiles, $suffix)
}
}
function InstallPhpCode()
{
global $CC_CONFIG;
global $AIRTIME_SRC;
echo "* Installing PHP code to ".$CC_CONFIG['phpDir'].PHP_EOL;
exec("mkdir -p ".$CC_CONFIG['phpDir']);
exec("cp -R ".$AIRTIME_SRC."/* ".$CC_CONFIG['phpDir']);
}
function InstallBinaries()
{
global $AIRTIME_UTILS;
echo "* Installing binaries to ".CONF_DIR_BINARIES.PHP_EOL;
exec("mkdir -p ".CONF_DIR_BINARIES);
exec("cp -R ".$AIRTIME_UTILS." ".CONF_DIR_BINARIES);
}
$suffix = date("Ymdhis")."-1.8.2";
foreach ($configFiles as $conf) {
if (file_exists($conf)) {
@ -243,6 +226,3 @@ echo "* Initializing INI files".PHP_EOL;
MergeConfigFiles($configFiles, $suffix);
$CC_CONFIG = LoadConfig($CC_CONFIG);
InstallPhpCode();
InstallBinaries();

View file

@ -621,15 +621,18 @@ class Airtime190Upgrade{
exec($command, $output);
print_r($output);
$oldAndNewFileNames = json_decode($output[0]);
if (isset($output[0])) {
$stor_dir_id = $propel_stor_dir->getId();
foreach ($oldAndNewFileNames as $pair){
$relPathNew = pg_escape_string(substr($pair[1], strlen($stor_dir)));
$absPathOld = pg_escape_string($pair[0]);
$sql = "UPDATE cc_files SET filepath = '$relPathNew', directory=$stor_dir_id WHERE filepath = '$absPathOld'";
echo $sql.PHP_EOL;
Airtime190Upgrade::execSqlQuery($sql);
$oldAndNewFileNames = json_decode($output[0]);
$stor_dir_id = $propel_stor_dir->getId();
foreach ($oldAndNewFileNames as $pair){
$relPathNew = pg_escape_string(substr($pair[1], strlen($stor_dir)));
$absPathOld = pg_escape_string($pair[0]);
$sql = "UPDATE cc_files SET filepath = '$relPathNew', directory=$stor_dir_id WHERE filepath = '$absPathOld'";
echo $sql.PHP_EOL;
Airtime190Upgrade::execSqlQuery($sql);
}
}
echo "Upgrading Linked Files".PHP_EOL;

View file

@ -3,6 +3,7 @@ import hashlib
import mutagen
import logging
import math
import re
"""
list of supported easy tags in mutagen version 1.20
@ -102,6 +103,7 @@ class AirtimeMetadata:
def get_md_from_file(self, filepath):
self.logger.debug("testing upgrade")
self.logger.info("getting info from filepath %s", filepath)
try:
@ -133,9 +135,28 @@ class AirtimeMetadata:
md['MDATA_KEY_TITLE'] = original_name
#incase track number is in format u'4/11'
#need to also check that the tracknumber is even a tracknumber (cc-2582)
if 'MDATA_KEY_TRACKNUMBER' in md:
try:
md['MDATA_KEY_TRACKNUMBER'] = int(md['MDATA_KEY_TRACKNUMBER'])
except Exception, e:
pass
if isinstance(md['MDATA_KEY_TRACKNUMBER'], basestring):
md['MDATA_KEY_TRACKNUMBER'] = md['MDATA_KEY_TRACKNUMBER'].split("/")[0]
match = re.search('^(\d*/\d*)?', md['MDATA_KEY_TRACKNUMBER'])
if match.group(0) is not u'':
md['MDATA_KEY_TRACKNUMBER'] = int(md['MDATA_KEY_TRACKNUMBER'].split("/")[0])
else:
del md['MDATA_KEY_TRACKNUMBER']
#make sure bpm is valid, need to check more types of formats for this tag to assure correct parsing.
if 'MDATA_KEY_BPM' in md:
if isinstance(md['MDATA_KEY_BPM'], basestring):
try:
md['MDATA_KEY_BPM'] = int(md['MDATA_KEY_BPM'])
except Exception, e:
del md['MDATA_KEY_BPM']
md['MDATA_KEY_BITRATE'] = file_info.info.bitrate
md['MDATA_KEY_SAMPLERATE'] = file_info.info.sample_rate
@ -152,4 +173,7 @@ class AirtimeMetadata:
if(isinstance(md[key], basestring)):
md[key] = md[key].encode('utf-8')
self.logger.info("MD after parsing.")
self.logger.debug(md)
return md

View file

@ -207,18 +207,18 @@ class MediaMonitorCommon:
return filepath
def execCommandAndReturnStdOut(self, command):
p = Popen(command, shell=True, stdout=PIPE)
stdout = p.communicate()[0]
def exec_command(self, command):
p = Popen(command, shell=True, stdout=PIPE, stderr=PIPE)
stdout, stderr = p.communicate()
if p.returncode != 0:
self.logger.warn("command \n%s\n return with a non-zero return value", command)
self.logger.error(stderr)
return stdout
def scan_dir_for_new_files(self, dir):
command = 'find "%s" -type f -iname "*.ogg" -o -iname "*.mp3" -readable' % dir.replace('"', '\\"')
self.logger.debug(command)
stdout = self.execCommandAndReturnStdOut(command)
stdout = unicode(stdout, "utf_8")
stdout = self.exec_command(command)
return stdout.splitlines()
@ -230,8 +230,6 @@ class MediaMonitorCommon:
file_md = self.md_manager.get_md_from_file(pathname)
if file_md is not None:
#is_recorded_show = 'MDATA_KEY_CREATOR' in file_md and \
# file_md['MDATA_KEY_CREATOR'] == "AIRTIMERECORDERSOURCEFABRIC".encode('utf-8')
filepath = self.create_file_path(pathname, file_md)
self.logger.debug("Moving from %s to %s", pathname, filepath)

View file

@ -38,7 +38,8 @@ mmc = MediaMonitorCommon(mmconfig)
try:
os.makedirs(organize_dir)
except Exception, e:
print e
#organize dir already exists. ( really shouldn't though )
pass
#older versions of Airtime installed from repository at least had owner of stor dir as "root"
mmc.set_needed_file_permissions(stor_dir, True)
@ -50,10 +51,17 @@ pairs = []
for root, dirs, files in os.walk(mmconfig.storage_directory):
for f in files:
old_filepath = os.path.join(root, f)
new_filepath = mmc.organize_new_file(os.path.join(root, f))
pair = old_filepath, new_filepath
pairs.append(pair)
mmc.set_needed_file_permissions(new_filepath, False)
new_filepath = mmc.organize_new_file(old_filepath)
if new_filepath is not None:
pair = old_filepath, new_filepath
pairs.append(pair)
mmc.set_needed_file_permissions(new_filepath, False)
#incase file has a metadata problem.
else:
pair = old_filepath, old_filepath
pairs.append(pair)
mmc.set_needed_file_permissions(old_filepath, False)
#need to set all the dirs in imported to be owned by www-data.
command = "chown -R www-data " + stor_dir

View file

@ -86,7 +86,7 @@ class AirtimeMediaMonitorBootstrap():
command = "find %s -type f -iname '*.ogg' -o -iname '*.mp3' -readable" % dir
stdout = self.mmc.exec_command(command)
self.logger.info(stdout)
#self.logger.info(stdout)
new_files = stdout.splitlines()

View file

@ -103,6 +103,7 @@ class AirtimeMetadata:
def get_md_from_file(self, filepath):
self.logger.debug("testing upgrade")
self.logger.info("getting info from filepath %s", filepath)
try: