|
|
@ -2,6 +2,7 @@
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
|
|
|
|
import os
|
|
|
|
import os
|
|
|
|
|
|
|
|
import sys
|
|
|
|
from configobj import ConfigObj
|
|
|
|
from configobj import ConfigObj
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -20,6 +21,9 @@ def CheckSection(sec):
|
|
|
|
def check_setting_str(config, cfg_name, item_name, def_val, log=True):
|
|
|
|
def check_setting_str(config, cfg_name, item_name, def_val, log=True):
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
my_val = config[cfg_name][item_name]
|
|
|
|
my_val = config[cfg_name][item_name]
|
|
|
|
|
|
|
|
if my_val == "":
|
|
|
|
|
|
|
|
my_val = def_val
|
|
|
|
|
|
|
|
config[cfg_name][item_name] = my_val
|
|
|
|
except:
|
|
|
|
except:
|
|
|
|
my_val = def_val
|
|
|
|
my_val = def_val
|
|
|
|
try:
|
|
|
|
try:
|
|
|
@ -43,9 +47,10 @@ def check_setting_int(config, cfg_name, item_name, def_val):
|
|
|
|
return my_val
|
|
|
|
return my_val
|
|
|
|
|
|
|
|
|
|
|
|
CheckSection('General')
|
|
|
|
CheckSection('General')
|
|
|
|
DB_ROOT = check_setting_str(CFG, 'General', 'DB_ROOT', os.path.join(os.getcwd(), "Calibre Library"))
|
|
|
|
DB_ROOT = check_setting_str(CFG, 'General', 'DB_ROOT', "")
|
|
|
|
APP_DB_ROOT = check_setting_str(CFG, 'General', 'APP_DB_ROOT', os.getcwd())
|
|
|
|
APP_DB_ROOT = check_setting_str(CFG, 'General', 'APP_DB_ROOT', os.getcwd())
|
|
|
|
MAIN_DIR = check_setting_str(CFG, 'General', 'MAIN_DIR', os.getcwd())
|
|
|
|
MAIN_DIR = check_setting_str(CFG, 'General', 'MAIN_DIR', os.getcwd())
|
|
|
|
|
|
|
|
LOG_DIR = check_setting_str(CFG, 'General', 'LOG_DIR', os.getcwd())
|
|
|
|
PORT = check_setting_int(CFG, 'General', 'PORT', 8083)
|
|
|
|
PORT = check_setting_int(CFG, 'General', 'PORT', 8083)
|
|
|
|
NEWEST_BOOKS = check_setting_str(CFG, 'General', 'NEWEST_BOOKS', 60)
|
|
|
|
NEWEST_BOOKS = check_setting_str(CFG, 'General', 'NEWEST_BOOKS', 60)
|
|
|
|
RANDOM_BOOKS = check_setting_int(CFG, 'General', 'RANDOM_BOOKS', 4)
|
|
|
|
RANDOM_BOOKS = check_setting_int(CFG, 'General', 'RANDOM_BOOKS', 4)
|
|
|
@ -57,10 +62,15 @@ PUBLIC_REG = bool(check_setting_int(CFG, 'Advanced', 'PUBLIC_REG', 0))
|
|
|
|
|
|
|
|
|
|
|
|
SYS_ENCODING="UTF-8"
|
|
|
|
SYS_ENCODING="UTF-8"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if DB_ROOT == "":
|
|
|
|
|
|
|
|
print "Calibre database directory (DB_ROOT) is not configured"
|
|
|
|
|
|
|
|
sys.exit(1)
|
|
|
|
|
|
|
|
|
|
|
|
configval={}
|
|
|
|
configval={}
|
|
|
|
configval["DB_ROOT"] = DB_ROOT
|
|
|
|
configval["DB_ROOT"] = DB_ROOT
|
|
|
|
configval["APP_DB_ROOT"] = APP_DB_ROOT
|
|
|
|
configval["APP_DB_ROOT"] = APP_DB_ROOT
|
|
|
|
configval["MAIN_DIR"] = MAIN_DIR
|
|
|
|
configval["MAIN_DIR"] = MAIN_DIR
|
|
|
|
|
|
|
|
configval["LOG_DIR"] = LOG_DIR
|
|
|
|
configval["PORT"] = PORT
|
|
|
|
configval["PORT"] = PORT
|
|
|
|
configval["NEWEST_BOOKS"] = NEWEST_BOOKS
|
|
|
|
configval["NEWEST_BOOKS"] = NEWEST_BOOKS
|
|
|
|
configval["DEVELOPMENT"] = DEVELOPMENT
|
|
|
|
configval["DEVELOPMENT"] = DEVELOPMENT
|
|
|
@ -74,6 +84,7 @@ def save_config(configval):
|
|
|
|
new_config['General']['DB_ROOT'] = configval["DB_ROOT"]
|
|
|
|
new_config['General']['DB_ROOT'] = configval["DB_ROOT"]
|
|
|
|
new_config['General']['APP_DB_ROOT'] = configval["APP_DB_ROOT"]
|
|
|
|
new_config['General']['APP_DB_ROOT'] = configval["APP_DB_ROOT"]
|
|
|
|
new_config['General']['MAIN_DIR'] = configval["MAIN_DIR"]
|
|
|
|
new_config['General']['MAIN_DIR'] = configval["MAIN_DIR"]
|
|
|
|
|
|
|
|
new_config['General']['LOG_DIR'] = configval["LOG_DIR"]
|
|
|
|
new_config['General']['PORT'] = configval["PORT"]
|
|
|
|
new_config['General']['PORT'] = configval["PORT"]
|
|
|
|
new_config['General']['NEWEST_BOOKS'] = configval["NEWEST_BOOKS"]
|
|
|
|
new_config['General']['NEWEST_BOOKS'] = configval["NEWEST_BOOKS"]
|
|
|
|
new_config['Advanced'] = {}
|
|
|
|
new_config['Advanced'] = {}
|
|
|
|