From da83af092a0d64242b772591f3928782b8ac95d6 Mon Sep 17 00:00:00 2001 From: OzzieIsaacs Date: Wed, 3 Aug 2016 07:35:58 +0200 Subject: [PATCH 1/2] Fix for #46 encoding issue --- cps/config.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/cps/config.py b/cps/config.py index 1cfddf9c..27e794b6 100755 --- a/cps/config.py +++ b/cps/config.py @@ -8,6 +8,7 @@ from configobj import ConfigObj CONFIG_FILE= os.path.join(os.getcwd(), "config.ini") CFG = ConfigObj(CONFIG_FILE) +CFG.encoding='UTF-8' def CheckSection(sec): """ Check if INI section exists, if not create it """ @@ -20,8 +21,8 @@ def CheckSection(sec): def check_setting_str(config, cfg_name, item_name, def_val, log=True): try: - my_val = config[cfg_name][item_name] - if my_val == "": + my_val = config[cfg_name][item_name].decode('UTF-8') + if my_val == u"": my_val = def_val config[cfg_name][item_name] = my_val except: @@ -82,7 +83,7 @@ configval["UPLOADING"] = UPLOADING configval["ANON_BROWSE"] = ANON_BROWSE def save_config(configval): - new_config = ConfigObj() + new_config = ConfigObj(encoding='UTF-8') new_config.filename = CONFIG_FILE new_config['General'] = {} new_config['General']['DB_ROOT'] = configval["DB_ROOT"] From 3b5be5dbc4cdc60a78752694e55846e324942768 Mon Sep 17 00:00:00 2001 From: OzzieIsaacs Date: Wed, 3 Aug 2016 07:37:53 +0200 Subject: [PATCH 2/2] Update db.py --- cps/db.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cps/db.py b/cps/db.py index 2cebe7bf..a621a5ae 100755 --- a/cps/db.py +++ b/cps/db.py @@ -20,7 +20,7 @@ def title_sort(title): dbpath = os.path.join(config.DB_ROOT, "metadata.db") -engine = create_engine('sqlite:///{0}'.format(dbpath), echo=False) +engine = create_engine('sqlite:///{0}'.format(dbpath.encode('utf-8')), echo=False) conn = engine.connect() conn.connection.create_function('title_sort', 1, title_sort) Base = declarative_base()