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 // Backup the config files
$suffix = date("Ymdhis")."-1.8.1"; $suffix = date("Ymdhis")."-1.8.1";
foreach ($configFiles as $conf) { foreach ($configFiles as $conf) {
@ -245,6 +227,3 @@ echo "* Initializing INI files".PHP_EOL;
MergeConfigFiles($configFiles, $suffix); MergeConfigFiles($configFiles, $suffix);
$CC_CONFIG = LoadConfig($CC_CONFIG); $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"; $suffix = date("Ymdhis")."-1.8.2";
foreach ($configFiles as $conf) { foreach ($configFiles as $conf) {
if (file_exists($conf)) { if (file_exists($conf)) {
@ -243,6 +226,3 @@ echo "* Initializing INI files".PHP_EOL;
MergeConfigFiles($configFiles, $suffix); MergeConfigFiles($configFiles, $suffix);
$CC_CONFIG = LoadConfig($CC_CONFIG); $CC_CONFIG = LoadConfig($CC_CONFIG);
InstallPhpCode();
InstallBinaries();

View file

@ -621,6 +621,8 @@ class Airtime190Upgrade{
exec($command, $output); exec($command, $output);
print_r($output); print_r($output);
if (isset($output[0])) {
$oldAndNewFileNames = json_decode($output[0]); $oldAndNewFileNames = json_decode($output[0]);
$stor_dir_id = $propel_stor_dir->getId(); $stor_dir_id = $propel_stor_dir->getId();
@ -631,6 +633,7 @@ class Airtime190Upgrade{
echo $sql.PHP_EOL; echo $sql.PHP_EOL;
Airtime190Upgrade::execSqlQuery($sql); Airtime190Upgrade::execSqlQuery($sql);
} }
}
echo "Upgrading Linked Files".PHP_EOL; echo "Upgrading Linked Files".PHP_EOL;

View file

@ -3,6 +3,7 @@ import hashlib
import mutagen import mutagen
import logging import logging
import math import math
import re
""" """
list of supported easy tags in mutagen version 1.20 list of supported easy tags in mutagen version 1.20
@ -102,6 +103,7 @@ class AirtimeMetadata:
def get_md_from_file(self, filepath): def get_md_from_file(self, filepath):
self.logger.debug("testing upgrade")
self.logger.info("getting info from filepath %s", filepath) self.logger.info("getting info from filepath %s", filepath)
try: try:
@ -133,9 +135,28 @@ class AirtimeMetadata:
md['MDATA_KEY_TITLE'] = original_name md['MDATA_KEY_TITLE'] = original_name
#incase track number is in format u'4/11' #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: 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): 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_BITRATE'] = file_info.info.bitrate
md['MDATA_KEY_SAMPLERATE'] = file_info.info.sample_rate md['MDATA_KEY_SAMPLERATE'] = file_info.info.sample_rate
@ -152,4 +173,7 @@ class AirtimeMetadata:
if(isinstance(md[key], basestring)): if(isinstance(md[key], basestring)):
md[key] = md[key].encode('utf-8') md[key] = md[key].encode('utf-8')
self.logger.info("MD after parsing.")
self.logger.debug(md)
return md return md

View file

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

View file

@ -38,7 +38,8 @@ mmc = MediaMonitorCommon(mmconfig)
try: try:
os.makedirs(organize_dir) os.makedirs(organize_dir)
except Exception, e: 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" #older versions of Airtime installed from repository at least had owner of stor dir as "root"
mmc.set_needed_file_permissions(stor_dir, True) mmc.set_needed_file_permissions(stor_dir, True)
@ -50,10 +51,17 @@ pairs = []
for root, dirs, files in os.walk(mmconfig.storage_directory): for root, dirs, files in os.walk(mmconfig.storage_directory):
for f in files: for f in files:
old_filepath = os.path.join(root, f) old_filepath = os.path.join(root, f)
new_filepath = mmc.organize_new_file(os.path.join(root, f)) new_filepath = mmc.organize_new_file(old_filepath)
if new_filepath is not None:
pair = old_filepath, new_filepath pair = old_filepath, new_filepath
pairs.append(pair) pairs.append(pair)
mmc.set_needed_file_permissions(new_filepath, False) 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. #need to set all the dirs in imported to be owned by www-data.
command = "chown -R www-data " + stor_dir 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 command = "find %s -type f -iname '*.ogg' -o -iname '*.mp3' -readable" % dir
stdout = self.mmc.exec_command(command) stdout = self.mmc.exec_command(command)
self.logger.info(stdout) #self.logger.info(stdout)
new_files = stdout.splitlines() new_files = stdout.splitlines()

View file

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