[Nym3-commit] r455 - trunk/nymbaron/Server
jr at conuropsis.org
jr at conuropsis.org
Mon Mar 6 21:49:43 CET 2006
Author: jr
Date: 2006-03-06 21:49:42 +0100 (Mon, 06 Mar 2006)
New Revision: 455
Modified:
trunk/nymbaron/Server/Main.py
Log:
- put the configuration loading in a specific function
Modified: trunk/nymbaron/Server/Main.py
===================================================================
--- trunk/nymbaron/Server/Main.py 2006-03-06 15:48:22 UTC (rev 454)
+++ trunk/nymbaron/Server/Main.py 2006-03-06 20:49:42 UTC (rev 455)
@@ -73,6 +73,19 @@
sys.exit(2)
return msg
+def load_config():
+ """Load the configuration"""
+ global config
+ try:
+ os.stat(Config.SYSFILE)
+ config = Config.Config(Config.SYSFILE)
+ except OSError:
+ try:
+ os.stat(Config.userfile())
+ config = Config.Config(Config.userfile())
+ except OSError:
+ config = Config.Config()
+
def mapAccount(fun, funargs = None):
"""Applies the function fun to each account of the server. The signature of
fun is: fun(account[, tuple of arguments specific to fun]), returns nothing
@@ -303,23 +316,15 @@
except Message.ParseError, inst:
logger.error("Parse error in incoming control message %s" % str(inst))
sys.exit(2) #TODO error code
-
+
def main(args):
if len(args) < 2:
print usage_string
sys.exit(1)
# Try to load the configuration file.
- global config, logger
- try:
- os.stat(Config.SYSFILE)
- config = Config.Config(Config.SYSFILE)
- except OSError:
- try:
- os.stat(Config.userfile())
- config = Config.Config(Config.userfile())
- except OSError:
- config = Config.Config()
+ load_config()
# The main logger object :
+ global logger
logger = logging.getLogger('nymbaron')
hdlr = logging.FileHandler(config.logfile)
formatter = logging.Formatter('%(asctime)s %(levelname)s %(message)s')
More information about the Nym3-commit
mailing list