CC-1799 : Live Studio Playout from media library (pytagsfs)
-code cleanup
This commit is contained in:
parent
2be05a8004
commit
3424dcc12d
|
@ -121,34 +121,38 @@ class AirtimeInstall
|
|||
{
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
echo "* Storage directory setup".PHP_EOL;
|
||||
|
||||
$stor_dir = $CC_CONFIG['storageDir'];
|
||||
|
||||
if (!file_exists($stor_dir)) {
|
||||
@mkdir($stor_dir, 02777, true);
|
||||
if (file_exists($stor_dir)) {
|
||||
$rp = realpath($stor_dir);
|
||||
echo "* Directory $rp created".PHP_EOL;
|
||||
} else {
|
||||
echo "* Failed creating {$stor_dir}".PHP_EOL;
|
||||
|
||||
$dirs = array($CC_CONFIG['storageDir'], $CC_CONFIG['storageDir']."/organize");
|
||||
|
||||
foreach ($dirs as $dir){
|
||||
if (!file_exists($dir)) {
|
||||
@mkdir($dir, 02777, true);
|
||||
if (file_exists($dir)) {
|
||||
$rp = realpath($dir);
|
||||
echo "* Directory $rp created".PHP_EOL;
|
||||
} else {
|
||||
echo "* Failed creating {$dir}".PHP_EOL;
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
else if (is_writable($dir)) {
|
||||
$rp = realpath($dir);
|
||||
echo "* Skipping directory already exists: $rp".PHP_EOL;
|
||||
}
|
||||
else {
|
||||
$rp = realpath($dir);
|
||||
echo "* Error: Directory already exists, but is not writable: $rp".PHP_EOL;
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
else if (is_writable($stor_dir)) {
|
||||
$rp = realpath($stor_dir);
|
||||
echo "* Skipping directory already exists: $rp".PHP_EOL;
|
||||
}
|
||||
else {
|
||||
$rp = realpath($stor_dir);
|
||||
echo "* WARNING: Directory already exists, but is not writable: $rp".PHP_EOL;
|
||||
return;
|
||||
}
|
||||
|
||||
echo "* Giving Apache permission to access $rp".PHP_EOL;
|
||||
$success = chgrp($rp, $CC_CONFIG["webServerUser"]);
|
||||
$success = chown($rp, "pypo");
|
||||
$success = chmod($rp, 02777);
|
||||
$CC_CONFIG['storageDir'] = $rp;
|
||||
echo "* Giving Apache permission to access $rp".PHP_EOL;
|
||||
$success = chgrp($rp, $CC_CONFIG["webServerUser"]);
|
||||
$success = chown($rp, "pypo");
|
||||
$success = chmod($rp, 02777);
|
||||
}
|
||||
|
||||
//July 5th, 2011: Why is this here - MK?????
|
||||
//$CC_CONFIG['storageDir'] = $rp;
|
||||
}
|
||||
|
||||
public static function CreateDatabaseUser()
|
||||
|
|
|
@ -52,6 +52,7 @@ try:
|
|||
logger.info("Storage Directory is: %s", storage_directory)
|
||||
config.storage_directory = storage_directory
|
||||
config.imported_directory = storage_directory + '/imported'
|
||||
config.organize_directory = storage_directory + '/organize'
|
||||
|
||||
multi_queue = mpQueue()
|
||||
logger.info("Initializing event processor")
|
||||
|
|
|
@ -220,18 +220,20 @@ class AirtimeProcessEvent(ProcessEvent):
|
|||
def handle_created_file(self, dir, name, pathname):
|
||||
self.logger.debug("dir: %s, name: %s, pathname: %s ", dir, name, pathname)
|
||||
storage_directory = self.config.storage_directory
|
||||
organize_directory = self.config.organize_directory
|
||||
if not dir:
|
||||
#event is because of a created file
|
||||
if self.is_temp_file(name) :
|
||||
#file created is a tmp file which will be modified and then moved back to the original filename.
|
||||
self.temp_files[pathname] = None
|
||||
elif self.is_audio_file(pathname):
|
||||
if self.is_parent_directory(pathname, storage_directory):
|
||||
#file was created in /srv/airtime/stor. Need to process and copy
|
||||
if self.is_parent_directory(pathname, organize_directory):
|
||||
#file was created in /srv/airtime/stor/organize. Need to process and copy
|
||||
#to /srv/airtime/stor/imported
|
||||
self.set_needed_file_permissions(pathname, dir)
|
||||
self.process_new_file(pathname)
|
||||
self.organize_new_file(pathname)
|
||||
else:
|
||||
self.set_needed_file_permissions(pathname, dir)
|
||||
self.file_events.append({'mode': self.config.MODE_CREATE, 'filepath': pathname, 'is_recorded_show': False})
|
||||
|
||||
else:
|
||||
|
@ -240,7 +242,7 @@ class AirtimeProcessEvent(ProcessEvent):
|
|||
self.set_needed_file_permissions(pathname, dir)
|
||||
|
||||
|
||||
def process_new_file(self, pathname):
|
||||
def organize_new_file(self, pathname):
|
||||
self.logger.info("Processing new file: %s", pathname)
|
||||
file_md = self.md_manager.get_md_from_file(pathname)
|
||||
|
||||
|
@ -377,6 +379,8 @@ class AirtimeProcessEvent(ProcessEvent):
|
|||
|
||||
self.file_events = []
|
||||
|
||||
#use items() because we are going to be modifying this
|
||||
#dictionary while iterating over it.
|
||||
for k, pair in self.cookies_IN_MOVED_FROM.items():
|
||||
event = pair[0]
|
||||
timestamp = pair[1]
|
||||
|
|
Loading…
Reference in New Issue