aboutsummaryrefslogtreecommitdiffstats
path: root/server/server.py
diff options
context:
space:
mode:
authorGuillaume Horel <guillaume.horel@gmail.com>2011-04-24 11:38:37 -0400
committerGuillaume Horel <guillaume.horel@gmail.com>2011-04-24 11:38:37 -0400
commit31d5c3bc03fd50c076026c4954a1cdb5bcef40b0 (patch)
tree52da868b151e0a135ddeaff92b5de33de8815a7a /server/server.py
parentb0a365ec96927f6076e08004ec2a73f1eb83370d (diff)
downloadalias-31d5c3bc03fd50c076026c4954a1cdb5bcef40b0.tar.gz
Plugged the logging facility into the daemon.
need more work, think it's broken as it is.
Diffstat (limited to 'server/server.py')
-rwxr-xr-xserver/server.py58
1 files changed, 0 insertions, 58 deletions
diff --git a/server/server.py b/server/server.py
index 7b39330..de1ffbe 100755
--- a/server/server.py
+++ b/server/server.py
@@ -1,14 +1,8 @@
-#!/usr/bin/python2
import logging
-from argparse import ArgumentParser
-
from sleekxmpp.componentxmpp import ComponentXMPP
from sleekxmpp.xmlstream.xmlstream import XMLStream
from user import UserHandler
-from config import filename, config
-import daemon
-from lockfile.pidlockfile import PIDLockFile
class ObjectComponent(ComponentXMPP):
@@ -52,56 +46,4 @@ class ObjectComponent(ComponentXMPP):
self.send_presence(pto = event["from"].full)
-if __name__ == '__main__':
- commandline = ArgumentParser(description = 'Connect the alias \
- component to a given server')
- commandline.add_argument('-p', '--port',
- help = 'Port to connect to',
- type = int)
- commandline.add_argument('-s', '--secret',
- help = 'password')
- commandline.add_argument('-n', '--name',
- 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('-o', '--host',
- help = 'Host to connect to')
- commandline.add_argument('-b', '--background',
- help = 'run the server in the background',
- action = 'store_true')
-
- args = commandline.parse_args()
-
- 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
- config.background = args.background
- else:
- filename = args.config
- logging.basicConfig(level = args.debug)
- config.read(filename)
-
-with daemon.DaemonContext(detach_process = config.background,
- pidfile = PIDLockFile('alias.pid'),
- working_directory = '.'):
- component = ObjectComponent(config.name, config.secret,
- config.host, config.port,
- config.root)
- if component.connect():
- logging.info('Component {} connected'.format(component.boundjid))
- component.process(False)
- else :
- logging.error("Component {} couldn't connect".format(component.boundjid))
-