From c287e11bee8dc50a3129d5bef3d17b12755386e0 Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Mon, 5 Nov 2012 14:02:55 -0500 Subject: [PATCH] moved setting up unicde into it's own routine --- python_apps/api_clients/api_client.py | 1 + python_apps/media-monitor2/mm2.py | 34 +++++++++++++++------------ 2 files changed, 20 insertions(+), 15 deletions(-) diff --git a/python_apps/api_clients/api_client.py b/python_apps/api_clients/api_client.py index ac93aa4c6..633993903 100644 --- a/python_apps/api_clients/api_client.py +++ b/python_apps/api_clients/api_client.py @@ -389,3 +389,4 @@ class AirtimeApiClient(object): """ self.logger.info( self.notify_webstream_data.req( _post_data={'data':data}, media_id=str(media_id)).retry(5)) + diff --git a/python_apps/media-monitor2/mm2.py b/python_apps/media-monitor2/mm2.py index 2abace71c..dc9cd160a 100644 --- a/python_apps/media-monitor2/mm2.py +++ b/python_apps/media-monitor2/mm2.py @@ -24,6 +24,24 @@ import media.monitor.pure as mmp from api_clients import api_client as apc +def setup_global(log): + """ setup unicode and other stuff """ + log.info("Attempting to set the locale...") + try: + mmp.configure_locale(mmp.get_system_locale()) + except FailedToSetLocale as e: + log.info("Failed to set the locale...") + sys.exit(1) + except FailedToObtainLocale as e: + log.info("Failed to obtain the locale form the default path: \ + '/etc/default/locale'") + sys.exit(1) + except Exception as e: + log.info("Failed to set the locale for unknown reason. \ + Logging exception.") + log.info(str(e)) + + def main(global_config, api_client_config, log_config, index_create_attempt=False): @@ -72,21 +90,7 @@ def main(global_config, api_client_config, log_config, if not os.path.exists(config['index_path']): log.info("Index file does not exist. Terminating") - log.info("Attempting to set the locale...") - - try: - mmp.configure_locale(mmp.get_system_locale()) - except FailedToSetLocale as e: - log.info("Failed to set the locale...") - sys.exit(1) - except FailedToObtainLocale as e: - log.info("Failed to obtain the locale form the default path: \ - '/etc/default/locale'") - sys.exit(1) - except Exception as e: - log.info("Failed to set the locale for unknown reason. \ - Logging exception.") - log.info(str(e)) + setup_global(log) watch_syncer = WatchSyncer(signal='watch', chunking_number=config['chunking_number'],