CC-3791: Media Monitor crash when there are media files with non-ascii name in watched folder

-move utf-8 locale check to bash
This commit is contained in:
Martin Konecny 2012-05-14 19:46:53 -04:00
parent c1d33e9f72
commit c397a6f797
4 changed files with 20 additions and 16 deletions

View File

@ -1,4 +1,4 @@
#!/bin/bash #!/bin/bash -e
# Location of pypo_cli.py Python script # Location of pypo_cli.py Python script
@ -14,6 +14,14 @@ cd ${media_monitor_path}
exec 2>&1 exec 2>&1
set +e
cat /etc/default/locale | grep -i "LANG=.*UTF-\?8"
set -e
if [ "$?" != "0" ]; then
echo "non UTF-8 default locale found in /etc/default/locale." > /var/log/airtime/pypo/error.log
exit 1
fi
export PYTHONPATH=${api_client_path} export PYTHONPATH=${api_client_path}
export LC_ALL=`cat /etc/default/locale | grep "LANG=" | cut -d= -f2 | tr -d "\n\""` export LC_ALL=`cat /etc/default/locale | grep "LANG=" | cut -d= -f2 | tr -d "\n\""`

View File

@ -8,7 +8,6 @@ import os
import signal import signal
import traceback import traceback
import locale import locale
import re
from configobj import ConfigObj from configobj import ConfigObj
@ -48,12 +47,7 @@ def configure_locale():
else: else:
new_locale = default_locale new_locale = default_locale
test = re.compile(r"UTF-?8", re.IGNORECASE) logger.info("New locale set to: %s", locale.setlocale(locale.LC_ALL, new_locale))
if test.findall(new_locale):
logger.info("New locale set to: %s", locale.setlocale(locale.LC_ALL, new_locale))
else:
logger.info("Invalid locale %s", new_locale)
sys.exit(1)

View File

@ -1,4 +1,4 @@
#!/bin/bash #!/bin/bash -e
virtualenv_bin="/usr/lib/airtime/airtime_virtualenv/bin/" virtualenv_bin="/usr/lib/airtime/airtime_virtualenv/bin/"
. ${virtualenv_bin}activate . ${virtualenv_bin}activate
@ -12,6 +12,14 @@ pypo_script="pypocli.py"
cd ${pypo_path} cd ${pypo_path}
exec 2>&1 exec 2>&1
set +e
cat /etc/default/locale | grep -i "LANG=.*UTF-\?8"
set -e
if [ "$?" != "0" ]; then
echo "non UTF-8 default locale found in /etc/default/locale." > /var/log/airtime/pypo/error.log
exit 1
fi
export HOME="/var/tmp/airtime/pypo/" export HOME="/var/tmp/airtime/pypo/"
export PYTHONPATH=${api_client_path}:$PYTHONPATH export PYTHONPATH=${api_client_path}:$PYTHONPATH
export LC_ALL=`cat /etc/default/locale | grep "LANG=" | cut -d= -f2 | tr -d "\n\""` export LC_ALL=`cat /etc/default/locale | grep "LANG=" | cut -d= -f2 | tr -d "\n\""`

View File

@ -11,7 +11,6 @@ import logging.config
import logging.handlers import logging.handlers
import locale import locale
import os import os
import re
from Queue import Queue from Queue import Queue
from threading import Lock from threading import Lock
@ -71,12 +70,7 @@ def configure_locale():
else: else:
new_locale = default_locale new_locale = default_locale
test = re.compile(r"UTF-?8", re.IGNORECASE) logger.info("New locale set to: %s", locale.setlocale(locale.LC_ALL, new_locale))
if test.findall(new_locale):
logger.info("New locale set to: %s", locale.setlocale(locale.LC_ALL, new_locale))
else:
logger.info("Invalid locale %s", new_locale)
sys.exit(1)