moved some constants to the right scope

This commit is contained in:
lars 2007-01-08 02:23:04 +00:00
parent d9d28d2c58
commit 2cbd564f09

View file

@ -31,20 +31,20 @@ import configobj, validate
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:
"""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):
self.log = logging.getLogger("CryptoBox")
config_file = self.__get_config_filename(config_file)
@ -283,7 +283,7 @@ class CryptoBoxSettings:
try:
try:
plugin_conf_file = os.path.join(
self.prefs["Locations"]["SettingsDir"], self.PLUGINCONF_FILE)
self.prefs["Locations"]["SettingsDir"], PLUGINCONF_FILE)
except KeyError:
raise CBConfigUndefinedError("Locations", "SettingsDir")
except SyntaxError:
@ -312,7 +312,7 @@ class CryptoBoxSettings:
try:
try:
conf_file = os.path.join(
self.prefs["Locations"]["SettingsDir"], self.VOLUMESDB_FILE)
self.prefs["Locations"]["SettingsDir"], VOLUMESDB_FILE)
except KeyError:
raise CBConfigUndefinedError("Locations", "SettingsDir")
except SyntaxError:
@ -339,7 +339,7 @@ class CryptoBoxSettings:
try:
try:
user_db_file = os.path.join(
self.prefs["Locations"]["SettingsDir"], self.USERDB_FILE)
self.prefs["Locations"]["SettingsDir"], USERDB_FILE)
except KeyError:
raise CBConfigUndefinedError("Locations", "SettingsDir")
except SyntaxError:
@ -384,7 +384,7 @@ class CryptoBoxSettings:
if config_file is None:
# no config file was specified - we will look for it in the ususal locations
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 not conf_file_list:
# no possible config file found in the usual locations
@ -653,6 +653,6 @@ class LocalSysLogHandler(logging.Handler):
msg = "%s: %s" % (record.levelname, record.getMessage())
try:
syslog.syslog(record.levelno, msg)
except:
except Exception:
self.handleError(record)