diff --git a/conf.py b/conf.py index 81bd6b6..9ee2d81 100644 --- a/conf.py +++ b/conf.py @@ -4,19 +4,6 @@ from collections import defaultdict import world -global confname -try: - # Get the config name from the command line, falling back to config.yml - # if not given. - fname = sys.argv[1] - confname = fname.split('.', 1)[0] -except IndexError: - # confname is used for logging and PID writing, so that each - # instance uses its own files. fname is the actual name of the file - # we load. - confname = 'pylink' - fname = 'config.yml' - global testconf testconf = {'bot': { @@ -43,13 +30,22 @@ testconf = {'bot': 'maxnicklen': 20 }) } - -with open(fname, 'r') as f: - global conf - if world.testing: - conf = testconf - confname = 'testconf' - else: +if world.testing: + conf = testconf + confname = 'testconf' +else: + try: + # Get the config name from the command line, falling back to config.yml + # if not given. + fname = sys.argv[1] + confname = fname.split('.', 1)[0] + except IndexError: + # confname is used for logging and PID writing, so that each + # instance uses its own files. fname is the actual name of the file + # we load. + confname = 'pylink' + fname = 'config.yml' + with open(fname, 'r') as f: try: conf = yaml.load(f) except Exception as e: diff --git a/main.py b/main.py index 235b08d..493983d 100755 --- a/main.py +++ b/main.py @@ -4,15 +4,17 @@ import imp import os import sys -from log import log +# This must be done before conf imports, so we get the real conf instead of testing one. +import world +world.testing = False + import conf +from log import log import classes import utils import coreplugin -import world if __name__ == '__main__': - world.testing = False log.info('PyLink starting...') if conf.conf['login']['password'] == 'changeme': log.critical("You have not set the login details correctly! Exiting...")