Browse Source

Fix component enabling/disabling

tags/v0.1^2
Ben Kurtovic 12 years ago
parent
commit
64c7a1a8a7
2 changed files with 6 additions and 6 deletions
  1. +1
    -1
      earwigbot/config.py
  2. +5
    -5
      earwigbot/main.py

+ 1
- 1
earwigbot/config.py View File

@@ -66,7 +66,7 @@ class _ConfigNode(object):
data = self.__dict__.copy() data = self.__dict__.copy()
for key, val in data.iteritems(): for key, val in data.iteritems():
if isinstance(val, _ConfigNode): if isinstance(val, _ConfigNode):
data[key] = val.dump()
data[key] = val._dump()
return data return data


def _load(self, data): def _load(self, data):


+ 5
- 5
earwigbot/main.py View File

@@ -88,7 +88,7 @@ def irc_frontend():
logger.info("Starting IRC frontend") logger.info("Starting IRC frontend")
frontend = Frontend() frontend = Frontend()


if "wiki_schedule" in config.components:
if config.components.get("wiki_schedule"):
logger.info("Starting wiki scheduler") logger.info("Starting wiki scheduler")
tasks.load() tasks.load()
t_scheduler = threading.Thread(target=wiki_scheduler) t_scheduler = threading.Thread(target=wiki_scheduler)
@@ -96,7 +96,7 @@ def irc_frontend():
t_scheduler.daemon = True t_scheduler.daemon = True
t_scheduler.start() t_scheduler.start()


if "irc_watcher" in config.components:
if config.components.get("irc_watcher"):
logger.info("Starting IRC watcher") logger.info("Starting IRC watcher")
t_watcher = threading.Thread(target=irc_watcher, args=(frontend,)) t_watcher = threading.Thread(target=irc_watcher, args=(frontend,))
t_watcher.name = "irc-watcher" t_watcher.name = "irc-watcher"
@@ -110,12 +110,12 @@ def irc_frontend():
f_conn.close() f_conn.close()


def main(): def main():
if "irc_frontend" in config.components:
if config.components.get("irc_frontend"):
# Make the frontend run on our primary thread if enabled, and enable # Make the frontend run on our primary thread if enabled, and enable
# additional components through that function: # additional components through that function:
irc_frontend() irc_frontend()


elif "wiki_schedule" in config.components:
elif config.components.get("wiki_schedule"):
# Run the scheduler on the main thread, but also run the IRC watcher on # Run the scheduler on the main thread, but also run the IRC watcher on
# another thread iff it is enabled: # another thread iff it is enabled:
logger.info("Starting wiki scheduler") logger.info("Starting wiki scheduler")
@@ -128,7 +128,7 @@ def main():
t_watcher.start() t_watcher.start()
wiki_scheduler() wiki_scheduler()


elif "irc_watcher" in config.components:
elif config.components.get("irc_watcher"):
# The IRC watcher is our only enabled component, so run its function # The IRC watcher is our only enabled component, so run its function
# only and don't worry about anything else: # only and don't worry about anything else:
logger.info("Starting IRC watcher") logger.info("Starting IRC watcher")


Loading…
Cancel
Save