summaryrefslogtreecommitdiff
path: root/examples/http_over_xmpp.py
diff options
context:
space:
mode:
authorEmmanuel Gil Peyrot <linkmauve@linkmauve.fr>2016-12-29 18:34:37 +0100
committerEmmanuel Gil Peyrot <linkmauve@linkmauve.fr>2016-12-29 18:34:37 +0100
commitc372f3071aca66c964971df6b6b148a93477588d (patch)
treef1d36cc75479cd49951b97618be950adc996843e /examples/http_over_xmpp.py
parent829c8b27b6e97a1ad1006bb7ec1720cbc47fccf3 (diff)
downloadslixmpp-c372f3071aca66c964971df6b6b148a93477588d.tar.gz
slixmpp-c372f3071aca66c964971df6b6b148a93477588d.tar.bz2
slixmpp-c372f3071aca66c964971df6b6b148a93477588d.tar.xz
slixmpp-c372f3071aca66c964971df6b6b148a93477588d.zip
Examples: Use argparse for http_over_xmpp.
Diffstat (limited to 'examples/http_over_xmpp.py')
-rw-r--r--examples/http_over_xmpp.py28
1 files changed, 14 insertions, 14 deletions
diff --git a/examples/http_over_xmpp.py b/examples/http_over_xmpp.py
index 73e4a612..2b7f68bc 100644
--- a/examples/http_over_xmpp.py
+++ b/examples/http_over_xmpp.py
@@ -13,7 +13,7 @@
from slixmpp import ClientXMPP
-from optparse import OptionParser
+from argparse import ArgumentParser
import logging
import getpass
@@ -58,40 +58,40 @@ if __name__ == '__main__':
# ./http_over_xmpp.py -J <jid> -P <pwd> -i <ip> -p <port> [-v]
#
- parser = OptionParser()
+ parser = ArgumentParser()
# Output verbosity options.
- parser.add_option(
+ parser.add_argument(
'-v', '--verbose', help='set logging to DEBUG', action='store_const',
dest='loglevel', const=logging.DEBUG, default=logging.ERROR
)
# JID and password options.
- parser.add_option('-J', '--jid', dest='jid', help='JID')
- parser.add_option('-P', '--password', dest='password', help='Password')
+ parser.add_argument('-J', '--jid', dest='jid', help='JID')
+ parser.add_argument('-P', '--password', dest='password', help='Password')
# XMPP server ip and port options.
- parser.add_option(
+ parser.add_argument(
'-i', '--ipaddr', dest='ipaddr',
help='IP Address of the XMPP server', default=None
)
- parser.add_option(
+ parser.add_argument(
'-p', '--port', dest='port',
help='Port of the XMPP server', default=None
)
- opts, args = parser.parse_args()
+ args = parser.parse_args()
# Setup logging.
- logging.basicConfig(level=opts.loglevel,
+ logging.basicConfig(level=args.loglevel,
format='%(levelname)-8s %(message)s')
- if opts.jid is None:
- opts.jid = input('Username: ')
- if opts.password is None:
- opts.password = getpass.getpass('Password: ')
+ if args.jid is None:
+ args.jid = input('Username: ')
+ if args.password is None:
+ args.password = getpass.getpass('Password: ')
- xmpp = HTTPOverXMPPClient(opts.jid, opts.password)
+ xmpp = HTTPOverXMPPClient(args.jid, args.password)
xmpp.connect()
xmpp.process()