2007-06-04 04:00:08 +00:00
|
|
|
import os
|
2007-06-06 12:37:34 +00:00
|
|
|
from traceback import format_exc
|
|
|
|
|
|
|
|
|
|
from apps.config.models import ConfigValue
|
|
|
|
|
import functions_general
|
2006-12-22 06:17:17 +00:00
|
|
|
"""
|
|
|
|
|
Handle the setting/retrieving of server config directives.
|
|
|
|
|
"""
|
|
|
|
|
|
2007-06-04 04:00:08 +00:00
|
|
|
def host_os_is(osname):
|
|
|
|
|
"""
|
|
|
|
|
Check to see if the host OS matches the query.
|
|
|
|
|
"""
|
2007-06-04 15:11:15 +00:00
|
|
|
if os.name == osname:
|
2007-06-04 04:00:08 +00:00
|
|
|
return True
|
|
|
|
|
return False
|
|
|
|
|
|
2006-12-22 06:17:17 +00:00
|
|
|
def get_configvalue(configname):
|
|
|
|
|
"""
|
|
|
|
|
Retrieve a configuration value.
|
|
|
|
|
"""
|
2007-06-06 12:37:34 +00:00
|
|
|
try:
|
2007-07-17 13:26:00 +00:00
|
|
|
return ConfigValue.objects.get(conf_key__iexact=configname).conf_value
|
2007-06-06 12:37:34 +00:00
|
|
|
except:
|
2007-06-11 02:36:34 +00:00
|
|
|
functions_general.log_errmsg("Unable to get config value for %s:\n%s" % (configname, (format_exc())))
|
2007-04-25 19:39:15 +00:00
|
|
|
|
|
|
|
|
def set_configvalue(configname, newvalue):
|
|
|
|
|
"""
|
|
|
|
|
Sets a configuration value with the specified name.
|
|
|
|
|
"""
|
|
|
|
|
conf = ConfigValue.objects.get(conf_key=configname)
|
|
|
|
|
conf.conf_value = newvalue
|
2007-06-04 15:11:15 +00:00
|
|
|
conf.save()
|