diff options
Diffstat (limited to 'server.py')
| -rw-r--r-- | server.py | 28 |
1 files changed, 22 insertions, 6 deletions
@@ -1,11 +1,11 @@ import logging -import ConfigParser from argparse import ArgumentParser from sleekxmpp.componentxmpp import ComponentXMPP from sleekxmpp.xmlstream.xmlstream import XMLStream from user import UserHandler +from config import filename, config class ObjectComponent(ComponentXMPP): @@ -58,20 +58,36 @@ if __name__ == '__main__': help = 'Name the component will have') commandline.add_argument('-r', '--root', help = 'Root directory of the user files') + commandline.add_argument('-c', '--config', + help = 'Name of the config file to use') commandline.add_argument('-d', '--debug', help = 'Set log level to DEBUG', action = 'store_const', const = logging.DEBUG, default = logging.INFO) - commandline.add_argument('host', + commandline.add_argument('-o', '--host', help = 'Host to connect to') + args = commandline.parse_args() - logging.basicConfig(level = args.debug) - component = ObjectComponent(args.name, args.secret, - args.host, args.port, args.root) + + if args.config is None: + logging.basicConfig(level = args.debug) + config.name = args.name + config.port = args.port + config.secret = args.secret + config.root = args.root + config.host = args.host + else: + filename = args.config + logging.basicConfig(level = args.debug) + config.read(filename) + + component = ObjectComponent(config.name, config.secret, + config.host, config.port, + config.root) if component.connect(): - logging.info('Component {} connected'.format(args.name)) + logging.info('Component {} connected'.format(component.boundjid)) component.process(False) else : print "Couldn't connect" |
