mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-23 11:09:23 +01:00
Added ability to override conf.py defaults with -c option
This commit is contained in:
parent
2719dcd8bd
commit
5e785ba212
42
src/bot.py
42
src/bot.py
@ -37,16 +37,9 @@ from fix import *
|
|||||||
|
|
||||||
import sys
|
import sys
|
||||||
import email
|
import email
|
||||||
|
import getopt
|
||||||
|
|
||||||
import conf
|
import conf
|
||||||
import world
|
|
||||||
import debug
|
|
||||||
import irclib
|
|
||||||
import ircmsgs
|
|
||||||
import drivers
|
|
||||||
import schedule
|
|
||||||
import privmsgs
|
|
||||||
import asyncoreDrivers
|
|
||||||
|
|
||||||
sys.path.append(conf.pluginDir)
|
sys.path.append(conf.pluginDir)
|
||||||
|
|
||||||
@ -69,6 +62,16 @@ class ConfigurationDict(dict):
|
|||||||
return dict.__contains__(self, key.lower())
|
return dict.__contains__(self, key.lower())
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def processConfigFile(filename):
|
||||||
|
import debug
|
||||||
|
import world
|
||||||
|
import irclib
|
||||||
|
import ircmsgs
|
||||||
|
import privmsgs
|
||||||
|
import asyncoreDrivers
|
||||||
|
def reportConfigError(filename, msg):
|
||||||
|
debug.recoverableError('%s: %s' % (filename, msg))
|
||||||
class ConfigAfter376(irclib.IrcCallback):
|
class ConfigAfter376(irclib.IrcCallback):
|
||||||
public = False
|
public = False
|
||||||
def __init__(self, msgs):
|
def __init__(self, msgs):
|
||||||
@ -80,11 +83,6 @@ class ConfigAfter376(irclib.IrcCallback):
|
|||||||
irc.queueMsg(msg)
|
irc.queueMsg(msg)
|
||||||
|
|
||||||
do377 = do376
|
do377 = do376
|
||||||
|
|
||||||
def reportConfigError(filename, msg):
|
|
||||||
debug.recoverableError('%s: %s' % (filename, msg))
|
|
||||||
|
|
||||||
def processConfigFile(filename):
|
|
||||||
try:
|
try:
|
||||||
fd = file(filename)
|
fd = file(filename)
|
||||||
m = email.message_from_file(fd)
|
m = email.message_from_file(fd)
|
||||||
@ -134,7 +132,23 @@ def processConfigFile(filename):
|
|||||||
reportConfigError(filename, msg)
|
reportConfigError(filename, msg)
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
for filename in sys.argv[1:]:
|
(optlist, filenames) = getopt.getopt(sys.argv[1:], 'c:')
|
||||||
|
for (option, argument) in optlist:
|
||||||
|
if option == '-c':
|
||||||
|
myLocals = {}
|
||||||
|
myGlobals = {}
|
||||||
|
execfile(argument, myGlobals, myLocals)
|
||||||
|
for (key, value) in myGlobals.iteritems():
|
||||||
|
setattr(conf, key, value)
|
||||||
|
for (key, value) in myLocals.iteritems():
|
||||||
|
setattr(conf, key, value)
|
||||||
|
else:
|
||||||
|
print 'Unexpected argument %s; ignoring.' % option
|
||||||
|
import debug
|
||||||
|
import world
|
||||||
|
import drivers
|
||||||
|
import schedule
|
||||||
|
for filename in filenames:
|
||||||
processConfigFile(filename)
|
processConfigFile(filename)
|
||||||
schedule.addPeriodicEvent(world.upkeep, 300)
|
schedule.addPeriodicEvent(world.upkeep, 300)
|
||||||
try:
|
try:
|
||||||
|
Loading…
Reference in New Issue
Block a user