CC-3789: Need to place rejected files into /problem_files directory
-make test_file_playability() a class method
This commit is contained in:
parent
032fb4e981
commit
0c6144a0f6
|
@ -138,7 +138,6 @@ class MediaMonitorCommon:
|
||||||
#moves file from source to dest but also recursively removes the
|
#moves file from source to dest but also recursively removes the
|
||||||
#the source file's parent directories if they are now empty.
|
#the source file's parent directories if they are now empty.
|
||||||
def move_file(self, source, dest):
|
def move_file(self, source, dest):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
omask = os.umask(0)
|
omask = os.umask(0)
|
||||||
os.rename(source, dest)
|
os.rename(source, dest)
|
||||||
|
@ -321,22 +320,15 @@ class MediaMonitorCommon:
|
||||||
|
|
||||||
return filepath
|
return filepath
|
||||||
|
|
||||||
def test_file_playability(pathname):
|
def test_file_playability(self, pathname):
|
||||||
"""
|
|
||||||
Test if the file can be played by Liquidsoap. Return "True" if Liquidsoap
|
|
||||||
can play it, or if Liquidsoap is not found.
|
|
||||||
"""
|
|
||||||
liquidsoap_found = subprocess.call("which liquidsoap", shell=True)
|
|
||||||
if liquidsoap_found == 0:
|
|
||||||
#return_code = subprocess.call("liquidsoap -r \"%s\"" % pathname.replace('"', '\\"'), shell=True)
|
|
||||||
|
|
||||||
#when there is an single apostrophe inside of a string quoted by apostrophes, we can only escape it by replace that apostrophe
|
#when there is an single apostrophe inside of a string quoted by apostrophes, we can only escape it by replace that apostrophe
|
||||||
#with '\''. This breaks the string into two, and inserts an escaped single quote in between them.
|
#with '\''. This breaks the string into two, and inserts an escaped single quote in between them.
|
||||||
#We run the command as pypo because otherwise the target file is opened with write permissions, and this causes an inotify ON_CLOSE_WRITE event
|
#We run the command as pypo because otherwise the target file is opened with write permissions, and this causes an inotify ON_CLOSE_WRITE event
|
||||||
#to be fired :/
|
#to be fired :/
|
||||||
command = "sudo -u pypo liquidsoap -c 'output.dummy(audio_to_stereo(single(\"%s\")))'" % pathname.replace("'", "'\\''")
|
command = "sudo -u pypo liquidsoap -c 'output.dummy(audio_to_stereo(single(\"%s\")))' > /dev/null 2>&1" % pathname.replace("'", "'\\''")
|
||||||
return_code = subprocess.call(command, shell=True)
|
return_code = subprocess.call(command, shell=True)
|
||||||
else:
|
if return_code != 0:
|
||||||
return_code = 0
|
#print pathname for py-interpreter.log
|
||||||
|
print pathname
|
||||||
|
|
||||||
return (return_code == 0)
|
return (return_code == 0)
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
from mediaconfig import AirtimeMediaConfig
|
from mediaconfig import AirtimeMediaConfig
|
||||||
import mediamonitorcommon
|
|
||||||
import traceback
|
import traceback
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
@ -18,7 +17,7 @@ class MediaMonitorWorkerProcess:
|
||||||
notifier.logger.info("received event %s", event)
|
notifier.logger.info("received event %s", event)
|
||||||
if event['mode'] == AirtimeMediaConfig.MODE_CREATE:
|
if event['mode'] == AirtimeMediaConfig.MODE_CREATE:
|
||||||
filepath = event['filepath']
|
filepath = event['filepath']
|
||||||
if mediamonitorcommon.test_file_playability(filepath):
|
if self.mmc.test_file_playability(filepath):
|
||||||
notifier.update_airtime(event)
|
notifier.update_airtime(event)
|
||||||
else:
|
else:
|
||||||
notifier.logger.warn("Liquidsoap integrity check for file at %s failed. Not adding to media library.", filepath)
|
notifier.logger.warn("Liquidsoap integrity check for file at %s failed. Not adding to media library.", filepath)
|
||||||
|
|
Loading…
Reference in New Issue