From c397a6f797800fee3d158b8ac83a0a1f363f88e3 Mon Sep 17 00:00:00 2001 From: Martin Konecny Date: Mon, 14 May 2012 19:46:53 -0400 Subject: [PATCH] CC-3791: Media Monitor crash when there are media files with non-ascii name in watched folder -move utf-8 locale check to bash --- python_apps/media-monitor/airtime-media-monitor | 10 +++++++++- python_apps/media-monitor/media_monitor.py | 8 +------- python_apps/pypo/airtime-playout | 10 +++++++++- python_apps/pypo/pypocli.py | 8 +------- 4 files changed, 20 insertions(+), 16 deletions(-) diff --git a/python_apps/media-monitor/airtime-media-monitor b/python_apps/media-monitor/airtime-media-monitor index 4af3f4be8..9fb0ce262 100755 --- a/python_apps/media-monitor/airtime-media-monitor +++ b/python_apps/media-monitor/airtime-media-monitor @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/bash -e # Location of pypo_cli.py Python script @@ -14,6 +14,14 @@ cd ${media_monitor_path} 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 LC_ALL=`cat /etc/default/locale | grep "LANG=" | cut -d= -f2 | tr -d "\n\""` diff --git a/python_apps/media-monitor/media_monitor.py b/python_apps/media-monitor/media_monitor.py index 024b5ae41..3fbb681bd 100644 --- a/python_apps/media-monitor/media_monitor.py +++ b/python_apps/media-monitor/media_monitor.py @@ -8,7 +8,6 @@ import os import signal import traceback import locale -import re from configobj import ConfigObj @@ -48,12 +47,7 @@ def configure_locale(): else: new_locale = default_locale - test = re.compile(r"UTF-?8", re.IGNORECASE) - 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) + logger.info("New locale set to: %s", locale.setlocale(locale.LC_ALL, new_locale)) diff --git a/python_apps/pypo/airtime-playout b/python_apps/pypo/airtime-playout index 101977596..f6d11df11 100755 --- a/python_apps/pypo/airtime-playout +++ b/python_apps/pypo/airtime-playout @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/bash -e virtualenv_bin="/usr/lib/airtime/airtime_virtualenv/bin/" . ${virtualenv_bin}activate @@ -12,6 +12,14 @@ pypo_script="pypocli.py" cd ${pypo_path} 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 PYTHONPATH=${api_client_path}:$PYTHONPATH export LC_ALL=`cat /etc/default/locale | grep "LANG=" | cut -d= -f2 | tr -d "\n\""` diff --git a/python_apps/pypo/pypocli.py b/python_apps/pypo/pypocli.py index 0f804fd30..1cc8ff2c8 100644 --- a/python_apps/pypo/pypocli.py +++ b/python_apps/pypo/pypocli.py @@ -11,7 +11,6 @@ import logging.config import logging.handlers import locale import os -import re from Queue import Queue from threading import Lock @@ -71,12 +70,7 @@ def configure_locale(): else: new_locale = default_locale - test = re.compile(r"UTF-?8", re.IGNORECASE) - 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) + logger.info("New locale set to: %s", locale.setlocale(locale.LC_ALL, new_locale))