Add encoding to Env

This commit is contained in:
Ruud
2012-01-14 13:40:02 +01:00
parent fe29e30bb0
commit ea3d91e34e
2 changed files with 12 additions and 0 deletions
+1
View File
@@ -5,6 +5,7 @@ from couchpotato.core.settings import Settings
class Env(object): class Env(object):
''' Environment variables ''' ''' Environment variables '''
_encoding = ''
_uses_git = False _uses_git = False
_debug = False _debug = False
_settings = Settings() _settings = Settings()
+11
View File
@@ -5,6 +5,7 @@ from couchpotato.core.event import fireEventAsync, fireEvent
from couchpotato.core.helpers.variable import getDataDir, tryInt from couchpotato.core.helpers.variable import getDataDir, tryInt
from logging import handlers from logging import handlers
from werkzeug.contrib.cache import FileSystemCache from werkzeug.contrib.cache import FileSystemCache
import locale
import logging import logging
import os.path import os.path
import socket import socket
@@ -61,8 +62,18 @@ def runCouchPotato(options, base_path, args, handle = None):
if not os.path.isdir(log_dir): if not os.path.isdir(log_dir):
os.mkdir(log_dir) os.mkdir(log_dir)
try:
locale.setlocale(locale.LC_ALL, "")
encoding = locale.getpreferredencoding()
except (locale.Error, IOError):
pass
# for OSes that are poorly configured I'll just force UTF-8
if not encoding or encoding in ('ANSI_X3.4-1968', 'US-ASCII', 'ASCII'):
encoding = 'UTF-8'
# Register environment settings # Register environment settings
Env.set('encoding', encoding)
Env.set('uses_git', not options.nogit) Env.set('uses_git', not options.nogit)
Env.set('app_dir', base_path) Env.set('app_dir', base_path)
Env.set('data_dir', data_dir) Env.set('data_dir', data_dir)