moved some constants to the right scope
This commit is contained in:
parent
d9d28d2c58
commit
2cbd564f09
|
@ -31,20 +31,20 @@ import configobj, validate
|
||||||
import syslog
|
import syslog
|
||||||
|
|
||||||
|
|
||||||
|
CONF_LOCATIONS = [
|
||||||
|
"./cryptobox.conf",
|
||||||
|
"~/.cryptobox.conf",
|
||||||
|
"/etc/cryptobox-server/cryptobox.conf"]
|
||||||
|
|
||||||
|
VOLUMESDB_FILE = "cryptobox_volumes.db"
|
||||||
|
PLUGINCONF_FILE = "cryptobox_plugins.conf"
|
||||||
|
USERDB_FILE = "cryptobox_users.db"
|
||||||
|
|
||||||
|
|
||||||
class CryptoBoxSettings:
|
class CryptoBoxSettings:
|
||||||
"""Manage the various configuration files of the CryptoBox
|
"""Manage the various configuration files of the CryptoBox
|
||||||
"""
|
"""
|
||||||
|
|
||||||
CONF_LOCATIONS = [
|
|
||||||
"./cryptobox.conf",
|
|
||||||
"~/.cryptobox.conf",
|
|
||||||
"/etc/cryptobox-server/cryptobox.conf"]
|
|
||||||
|
|
||||||
VOLUMESDB_FILE = "cryptobox_volumes.db"
|
|
||||||
PLUGINCONF_FILE = "cryptobox_plugins.conf"
|
|
||||||
USERDB_FILE = "cryptobox_users.db"
|
|
||||||
|
|
||||||
|
|
||||||
def __init__(self, config_file=None):
|
def __init__(self, config_file=None):
|
||||||
self.log = logging.getLogger("CryptoBox")
|
self.log = logging.getLogger("CryptoBox")
|
||||||
config_file = self.__get_config_filename(config_file)
|
config_file = self.__get_config_filename(config_file)
|
||||||
|
@ -283,7 +283,7 @@ class CryptoBoxSettings:
|
||||||
try:
|
try:
|
||||||
try:
|
try:
|
||||||
plugin_conf_file = os.path.join(
|
plugin_conf_file = os.path.join(
|
||||||
self.prefs["Locations"]["SettingsDir"], self.PLUGINCONF_FILE)
|
self.prefs["Locations"]["SettingsDir"], PLUGINCONF_FILE)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
raise CBConfigUndefinedError("Locations", "SettingsDir")
|
raise CBConfigUndefinedError("Locations", "SettingsDir")
|
||||||
except SyntaxError:
|
except SyntaxError:
|
||||||
|
@ -312,7 +312,7 @@ class CryptoBoxSettings:
|
||||||
try:
|
try:
|
||||||
try:
|
try:
|
||||||
conf_file = os.path.join(
|
conf_file = os.path.join(
|
||||||
self.prefs["Locations"]["SettingsDir"], self.VOLUMESDB_FILE)
|
self.prefs["Locations"]["SettingsDir"], VOLUMESDB_FILE)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
raise CBConfigUndefinedError("Locations", "SettingsDir")
|
raise CBConfigUndefinedError("Locations", "SettingsDir")
|
||||||
except SyntaxError:
|
except SyntaxError:
|
||||||
|
@ -339,7 +339,7 @@ class CryptoBoxSettings:
|
||||||
try:
|
try:
|
||||||
try:
|
try:
|
||||||
user_db_file = os.path.join(
|
user_db_file = os.path.join(
|
||||||
self.prefs["Locations"]["SettingsDir"], self.USERDB_FILE)
|
self.prefs["Locations"]["SettingsDir"], USERDB_FILE)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
raise CBConfigUndefinedError("Locations", "SettingsDir")
|
raise CBConfigUndefinedError("Locations", "SettingsDir")
|
||||||
except SyntaxError:
|
except SyntaxError:
|
||||||
|
@ -384,7 +384,7 @@ class CryptoBoxSettings:
|
||||||
if config_file is None:
|
if config_file is None:
|
||||||
# no config file was specified - we will look for it in the ususal locations
|
# no config file was specified - we will look for it in the ususal locations
|
||||||
conf_file_list = [os.path.expanduser(f)
|
conf_file_list = [os.path.expanduser(f)
|
||||||
for f in self.CONF_LOCATIONS
|
for f in CONF_LOCATIONS
|
||||||
if os.path.exists(os.path.expanduser(f))]
|
if os.path.exists(os.path.expanduser(f))]
|
||||||
if not conf_file_list:
|
if not conf_file_list:
|
||||||
# no possible config file found in the usual locations
|
# no possible config file found in the usual locations
|
||||||
|
@ -653,6 +653,6 @@ class LocalSysLogHandler(logging.Handler):
|
||||||
msg = "%s: %s" % (record.levelname, record.getMessage())
|
msg = "%s: %s" % (record.levelname, record.getMessage())
|
||||||
try:
|
try:
|
||||||
syslog.syslog(record.levelno, msg)
|
syslog.syslog(record.levelno, msg)
|
||||||
except:
|
except Exception:
|
||||||
self.handleError(record)
|
self.handleError(record)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue