aboutsummaryrefslogtreecommitdiffstats
path: root/server.py
diff options
context:
space:
mode:
Diffstat (limited to 'server.py')
-rw-r--r--server.py24
1 files changed, 20 insertions, 4 deletions
diff --git a/server.py b/server.py
index fcc4d89..705ebb7 100644
--- a/server.py
+++ b/server.py
@@ -1,4 +1,5 @@
-from sleekxmpp.componentxmpp import ComponentXMPP
+from sleekxmpp.componentxmpp import ComponentXMPP
+from argparse import ArgumentParser
class ObjectComponent(ComponentXMPP):
@@ -14,7 +15,22 @@ class ObjectComponent(ComponentXMPP):
msg.reply("Thanks for sending\n%(body)s" % msg).send()
if __name__ == '__main__' :
- component = ObjectComponent("object.alias.fr.nf", "toto", "localhost", 5347)
- component.connect()
- component.process()
+ 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('host',
+ help='Host to connect to')
+ args = commandline.parse_args()
+ component = ObjectComponent(args.name, args.secret,args.host,args.port)
+
+ if component.connect() :
+ print 'Component', args.name, 'connected to', args.host + ':' + str(args.port)
+ component.process()
+ else :
+ print "Couldn't connect"