Remove raw_input usage and other python2 support in examples

This commit is contained in:
Emmanuel Gil Peyrot 2014-08-16 22:37:29 +02:00 committed by Florent Le Coz
parent 815e647c97
commit df68bb4896
26 changed files with 45 additions and 313 deletions

View File

@ -27,16 +27,6 @@ from optparse import OptionParser
from urllib import urlopen from urllib import urlopen
import slixmpp import slixmpp
# Python versions before 3.0 do not use UTF-8 encoding
# by default. To ensure that Unicode is handled properly
# throughout Slixmpp, we will set the default encoding
# ourselves to UTF-8.
if sys.version_info < (3, 0):
from slixmpp.util.misc_ops import setdefaultencoding
setdefaultencoding('utf8')
else:
raw_input = input
from slixmpp.plugins.xep_0323.device import Device from slixmpp.plugins.xep_0323.device import Device
#from slixmpp.exceptions import IqError, IqTimeout #from slixmpp.exceptions import IqError, IqTimeout
@ -160,7 +150,7 @@ if __name__ == '__main__':
format='%(levelname)-8s %(message)s') format='%(levelname)-8s %(message)s')
if opts.jid is None: if opts.jid is None:
opts.jid = raw_input("Username: ") opts.jid = input("Username: ")
if opts.password is None: if opts.password is None:
opts.password = getpass.getpass("Password: ") opts.password = getpass.getpass("Password: ")

View File

@ -9,23 +9,12 @@
See the file LICENSE for copying permission. See the file LICENSE for copying permission.
""" """
import sys
import logging import logging
import getpass import getpass
from optparse import OptionParser from optparse import OptionParser
import slixmpp import slixmpp
# Python versions before 3.0 do not use UTF-8 encoding
# by default. To ensure that Unicode is handled properly
# throughout Slixmpp, we will set the default encoding
# ourselves to UTF-8.
if sys.version_info < (3, 0):
from slixmpp.util.misc_ops import setdefaultencoding
setdefaultencoding('utf8')
else:
raw_input = input
class CommandBot(slixmpp.ClientXMPP): class CommandBot(slixmpp.ClientXMPP):
@ -169,7 +158,7 @@ if __name__ == '__main__':
format='%(levelname)-8s %(message)s') format='%(levelname)-8s %(message)s')
if opts.jid is None: if opts.jid is None:
opts.jid = raw_input("Username: ") opts.jid = input("Username: ")
if opts.password is None: if opts.password is None:
opts.password = getpass.getpass("Password: ") opts.password = getpass.getpass("Password: ")

View File

@ -9,23 +9,12 @@
See the file LICENSE for copying permission. See the file LICENSE for copying permission.
""" """
import sys
import logging import logging
import getpass import getpass
from optparse import OptionParser from optparse import OptionParser
import slixmpp import slixmpp
# Python versions before 3.0 do not use UTF-8 encoding
# by default. To ensure that Unicode is handled properly
# throughout Slixmpp, we will set the default encoding
# ourselves to UTF-8.
if sys.version_info < (3, 0):
from slixmpp.util.misc_ops import setdefaultencoding
setdefaultencoding('utf8')
else:
raw_input = input
class CommandUserBot(slixmpp.ClientXMPP): class CommandUserBot(slixmpp.ClientXMPP):
@ -172,13 +161,13 @@ if __name__ == '__main__':
format='%(levelname)-8s %(message)s') format='%(levelname)-8s %(message)s')
if opts.jid is None: if opts.jid is None:
opts.jid = raw_input("Username: ") opts.jid = input("Username: ")
if opts.password is None: if opts.password is None:
opts.password = getpass.getpass("Password: ") opts.password = getpass.getpass("Password: ")
if opts.other is None: if opts.other is None:
opts.other = raw_input("JID Providing Commands: ") opts.other = input("JID Providing Commands: ")
if opts.greeting is None: if opts.greeting is None:
opts.greeting = raw_input("Greeting: ") opts.greeting = input("Greeting: ")
# Setup the CommandBot and register plugins. Note that while plugins may # Setup the CommandBot and register plugins. Note that while plugins may
# have interdependencies, the order in which you register them does # have interdependencies, the order in which you register them does

View File

@ -9,23 +9,12 @@
See the file LICENSE for copying permission. See the file LICENSE for copying permission.
""" """
import sys
import logging import logging
import getpass import getpass
from optparse import OptionParser from optparse import OptionParser
import slixmpp import slixmpp
# Python versions before 3.0 do not use UTF-8 encoding
# by default. To ensure that Unicode is handled properly
# throughout Slixmpp, we will set the default encoding
# ourselves to UTF-8.
if sys.version_info < (3, 0):
from slixmpp.util.misc_ops import setdefaultencoding
setdefaultencoding('utf8')
else:
raw_input = input
class AdminCommands(slixmpp.ClientXMPP): class AdminCommands(slixmpp.ClientXMPP):
@ -81,13 +70,13 @@ class AdminCommands(slixmpp.ClientXMPP):
for var, field in form['fields'].items(): for var, field in form['fields'].items():
if var != 'FORM_TYPE': if var != 'FORM_TYPE':
if field['type'] == 'boolean': if field['type'] == 'boolean':
answers[var] = raw_input('%s (y/n): ' % field['label']) answers[var] = input('%s (y/n): ' % field['label'])
if answers[var].lower() in ('1', 'true', 'y', 'yes'): if answers[var].lower() in ('1', 'true', 'y', 'yes'):
answers[var] = '1' answers[var] = '1'
else: else:
answers[var] = '0' answers[var] = '0'
else: else:
answers[var] = raw_input('%s: ' % field['label']) answers[var] = input('%s: ' % field['label'])
else: else:
answers['FORM_TYPE'] = field['value'] answers['FORM_TYPE'] = field['value']
form['type'] = 'submit' form['type'] = 'submit'
@ -144,11 +133,11 @@ if __name__ == '__main__':
format='%(levelname)-8s %(message)s') format='%(levelname)-8s %(message)s')
if opts.jid is None: if opts.jid is None:
opts.jid = raw_input("Username: ") opts.jid = input("Username: ")
if opts.password is None: if opts.password is None:
opts.password = getpass.getpass("Password: ") opts.password = getpass.getpass("Password: ")
if opts.command is None: if opts.command is None:
opts.command = raw_input("Admin command: ") opts.command = input("Admin command: ")
# Setup the CommandBot and register plugins. Note that while plugins may # Setup the CommandBot and register plugins. Note that while plugins may
# have interdependencies, the order in which you register them does # have interdependencies, the order in which you register them does

View File

@ -9,7 +9,6 @@
See the file LICENSE for copying permission. See the file LICENSE for copying permission.
""" """
import sys
import logging import logging
import getpass import getpass
from optparse import OptionParser from optparse import OptionParser
@ -23,16 +22,6 @@ from slixmpp.xmlstream.handler import Callback
from slixmpp.xmlstream.matcher import StanzaPath from slixmpp.xmlstream.matcher import StanzaPath
from stanza import Action from stanza import Action
# Python versions before 3.0 do not use UTF-8 encoding
# by default. To ensure that Unicode is handled properly
# throughout Slixmpp, we will set the default encoding
# ourselves to UTF-8.
if sys.version_info < (3, 0):
from slixmpp.util.misc_ops import setdefaultencoding
setdefaultencoding('utf8')
else:
raw_input = input
class ActionBot(slixmpp.ClientXMPP): class ActionBot(slixmpp.ClientXMPP):
@ -138,7 +127,7 @@ if __name__ == '__main__':
format='%(levelname)-8s %(message)s') format='%(levelname)-8s %(message)s')
if opts.jid is None: if opts.jid is None:
opts.jid = raw_input("Username: ") opts.jid = input("Username: ")
if opts.password is None: if opts.password is None:
opts.password = getpass.getpass("Password: ") opts.password = getpass.getpass("Password: ")

View File

@ -9,7 +9,6 @@
See the file LICENSE for copying permission. See the file LICENSE for copying permission.
""" """
import sys
import logging import logging
import getpass import getpass
from optparse import OptionParser from optparse import OptionParser
@ -21,16 +20,6 @@ from slixmpp.xmlstream import register_stanza_plugin
from stanza import Action from stanza import Action
# Python versions before 3.0 do not use UTF-8 encoding
# by default. To ensure that Unicode is handled properly
# throughout Slixmpp, we will set the default encoding
# ourselves to UTF-8.
if sys.version_info < (3, 0):
from slixmpp.util.misc_ops import setdefaultencoding
setdefaultencoding('utf8')
else:
raw_input = input
class ActionUserBot(slixmpp.ClientXMPP): class ActionUserBot(slixmpp.ClientXMPP):
@ -139,11 +128,11 @@ if __name__ == '__main__':
format='%(levelname)-8s %(message)s') format='%(levelname)-8s %(message)s')
if opts.jid is None: if opts.jid is None:
opts.jid = raw_input("Username: ") opts.jid = input("Username: ")
if opts.password is None: if opts.password is None:
opts.password = getpass.getpass("Password: ") opts.password = getpass.getpass("Password: ")
if opts.other is None: if opts.other is None:
opts.other = raw_input("JID Providing custom stanza: ") opts.other = input("JID Providing custom stanza: ")
# Setup the CommandBot and register plugins. Note that while plugins may # Setup the CommandBot and register plugins. Note that while plugins may
# have interdependencies, the order in which you register them does # have interdependencies, the order in which you register them does

View File

@ -9,7 +9,6 @@
See the file LICENSE for copying permission. See the file LICENSE for copying permission.
""" """
import sys
import logging import logging
import getpass import getpass
from optparse import OptionParser from optparse import OptionParser
@ -18,17 +17,6 @@ import slixmpp
from slixmpp.exceptions import IqError, IqTimeout from slixmpp.exceptions import IqError, IqTimeout
# Python versions before 3.0 do not use UTF-8 encoding
# by default. To ensure that Unicode is handled properly
# throughout Slixmpp, we will set the default encoding
# ourselves to UTF-8.
if sys.version_info < (3, 0):
from slixmpp.util.misc_ops import setdefaultencoding
setdefaultencoding('utf8')
else:
raw_input = input
class Disco(slixmpp.ClientXMPP): class Disco(slixmpp.ClientXMPP):
""" """
@ -176,7 +164,7 @@ if __name__ == '__main__':
args = (args[0], args[1], '') args = (args[0], args[1], '')
if opts.jid is None: if opts.jid is None:
opts.jid = raw_input("Username: ") opts.jid = input("Username: ")
if opts.password is None: if opts.password is None:
opts.password = getpass.getpass("Password: ") opts.password = getpass.getpass("Password: ")

View File

@ -9,7 +9,6 @@
See the file LICENSE for copying permission. See the file LICENSE for copying permission.
""" """
import sys
import logging import logging
import getpass import getpass
import threading import threading
@ -19,17 +18,6 @@ import slixmpp
from slixmpp.exceptions import XMPPError from slixmpp.exceptions import XMPPError
# Python versions before 3.0 do not use UTF-8 encoding
# by default. To ensure that Unicode is handled properly
# throughout Slixmpp, we will set the default encoding
# ourselves to UTF-8.
if sys.version_info < (3, 0):
from slixmpp.util.misc_ops import setdefaultencoding
setdefaultencoding('utf8')
else:
raw_input = input
FILE_TYPES = { FILE_TYPES = {
'image/png': 'png', 'image/png': 'png',
'image/gif': 'gif', 'image/gif': 'gif',
@ -154,7 +142,7 @@ if __name__ == '__main__':
format='%(levelname)-8s %(message)s') format='%(levelname)-8s %(message)s')
if opts.jid is None: if opts.jid is None:
opts.jid = raw_input("Username: ") opts.jid = input("Username: ")
if opts.password is None: if opts.password is None:
opts.password = getpass.getpass("Password: ") opts.password = getpass.getpass("Password: ")

View File

@ -9,23 +9,12 @@
See the file LICENSE for copying permission. See the file LICENSE for copying permission.
""" """
import sys
import logging import logging
import getpass import getpass
from optparse import OptionParser from optparse import OptionParser
import slixmpp import slixmpp
# Python versions before 3.0 do not use UTF-8 encoding
# by default. To ensure that Unicode is handled properly
# throughout Slixmpp, we will set the default encoding
# ourselves to UTF-8.
if sys.version_info < (3, 0):
from slixmpp.util.misc_ops import setdefaultencoding
setdefaultencoding('utf8')
else:
raw_input = input
class EchoBot(slixmpp.ClientXMPP): class EchoBot(slixmpp.ClientXMPP):
@ -109,7 +98,7 @@ if __name__ == '__main__':
format='%(levelname)-8s %(message)s') format='%(levelname)-8s %(message)s')
if opts.jid is None: if opts.jid is None:
opts.jid = raw_input("Username: ") opts.jid = input("Username: ")
if opts.password is None: if opts.password is None:
opts.password = getpass.getpass("Password: ") opts.password = getpass.getpass("Password: ")

View File

@ -9,7 +9,6 @@
See the file LICENSE for copying permission. See the file LICENSE for copying permission.
""" """
import sys
import logging import logging
import getpass import getpass
from optparse import OptionParser from optparse import OptionParser
@ -17,16 +16,6 @@ from optparse import OptionParser
import slixmpp import slixmpp
from slixmpp.componentxmpp import ComponentXMPP from slixmpp.componentxmpp import ComponentXMPP
# Python versions before 3.0 do not use UTF-8 encoding
# by default. To ensure that Unicode is handled properly
# throughout Slixmpp, we will set the default encoding
# ourselves to UTF-8.
if sys.version_info < (3, 0):
from slixmpp.util.misc_ops import setdefaultencoding
setdefaultencoding('utf8')
else:
raw_input = input
class EchoComponent(ComponentXMPP): class EchoComponent(ComponentXMPP):
@ -93,13 +82,13 @@ if __name__ == '__main__':
opts, args = optp.parse_args() opts, args = optp.parse_args()
if opts.jid is None: if opts.jid is None:
opts.jid = raw_input("Component JID: ") opts.jid = input("Component JID: ")
if opts.password is None: if opts.password is None:
opts.password = getpass.getpass("Password: ") opts.password = getpass.getpass("Password: ")
if opts.server is None: if opts.server is None:
opts.server = raw_input("Server: ") opts.server = input("Server: ")
if opts.port is None: if opts.port is None:
opts.port = int(raw_input("Port: ")) opts.port = int(input("Port: "))
# Setup logging. # Setup logging.
logging.basicConfig(level=opts.loglevel, logging.basicConfig(level=opts.loglevel,

View File

@ -9,7 +9,6 @@
See the file LICENSE for copying permission. See the file LICENSE for copying permission.
""" """
import sys
import logging import logging
import getpass import getpass
from optparse import OptionParser from optparse import OptionParser
@ -20,17 +19,6 @@ import ssl
from slixmpp.xmlstream import cert from slixmpp.xmlstream import cert
# Python versions before 3.0 do not use UTF-8 encoding
# by default. To ensure that Unicode is handled properly
# throughout Slixmpp, we will set the default encoding
# ourselves to UTF-8.
if sys.version_info < (3, 0):
from slixmpp.util.misc_ops import setdefaultencoding
setdefaultencoding('utf8')
else:
raw_input = input
class GTalkBot(slixmpp.ClientXMPP): class GTalkBot(slixmpp.ClientXMPP):
""" """
@ -130,7 +118,7 @@ if __name__ == '__main__':
format='%(levelname)-8s %(message)s') format='%(levelname)-8s %(message)s')
if opts.jid is None: if opts.jid is None:
opts.jid = raw_input("Username: ") opts.jid = input("Username: ")
if opts.password is None: if opts.password is None:
opts.password = getpass.getpass("Password: ") opts.password = getpass.getpass("Password: ")

View File

@ -9,23 +9,12 @@
See the file LICENSE for copying permission. See the file LICENSE for copying permission.
""" """
import sys
import logging import logging
import getpass import getpass
from optparse import OptionParser from optparse import OptionParser
import slixmpp import slixmpp
# Python versions before 3.0 do not use UTF-8 encoding
# by default. To ensure that Unicode is handled properly
# throughout Slixmpp, we will set the default encoding
# ourselves to UTF-8.
if sys.version_info < (3, 0):
from slixmpp.util.misc_ops import setdefaultencoding
setdefaultencoding('utf8')
else:
raw_input = input
class IBBReceiver(slixmpp.ClientXMPP): class IBBReceiver(slixmpp.ClientXMPP):
@ -119,7 +108,7 @@ if __name__ == '__main__':
format='%(levelname)-8s %(message)s') format='%(levelname)-8s %(message)s')
if opts.jid is None: if opts.jid is None:
opts.jid = raw_input("Username: ") opts.jid = input("Username: ")
if opts.password is None: if opts.password is None:
opts.password = getpass.getpass("Password: ") opts.password = getpass.getpass("Password: ")

View File

@ -9,23 +9,12 @@
See the file LICENSE for copying permission. See the file LICENSE for copying permission.
""" """
import sys
import logging import logging
import getpass import getpass
from optparse import OptionParser from optparse import OptionParser
import slixmpp import slixmpp
# Python versions before 3.0 do not use UTF-8 encoding
# by default. To ensure that Unicode is handled properly
# throughout Slixmpp, we will set the default encoding
# ourselves to UTF-8.
if sys.version_info < (3, 0):
from slixmpp.util.misc_ops import setdefaultencoding
setdefaultencoding('utf8')
else:
raw_input = input
class IBBSender(slixmpp.ClientXMPP): class IBBSender(slixmpp.ClientXMPP):
@ -105,13 +94,13 @@ if __name__ == '__main__':
format='%(levelname)-8s %(message)s') format='%(levelname)-8s %(message)s')
if opts.jid is None: if opts.jid is None:
opts.jid = raw_input("Username: ") opts.jid = input("Username: ")
if opts.password is None: if opts.password is None:
opts.password = getpass.getpass("Password: ") opts.password = getpass.getpass("Password: ")
if opts.receiver is None: if opts.receiver is None:
opts.receiver = raw_input("Receiver: ") opts.receiver = input("Receiver: ")
if opts.filename is None: if opts.filename is None:
opts.filename = raw_input("File path: ") opts.filename = input("File path: ")
# Setup the EchoBot and register plugins. Note that while plugins may # Setup the EchoBot and register plugins. Note that while plugins may
# have interdependencies, the order in which you register them does # have interdependencies, the order in which you register them does

View File

@ -8,16 +8,6 @@ from optparse import OptionParser
import slixmpp import slixmpp
# Python versions before 3.0 do not use UTF-8 encoding
# by default. To ensure that Unicode is handled properly
# throughout Slixmpp, we will set the default encoding
# ourselves to UTF-8.
if sys.version_info < (3, 0):
from slixmpp.util.misc_ops import setdefaultencoding
setdefaultencoding('utf8')
else:
raw_input = input
# Setup the command line arguments. # Setup the command line arguments.
optp = OptionParser() optp = OptionParser()
@ -52,12 +42,12 @@ logging.basicConfig(level=opts.loglevel,
format='%(levelname)-8s %(message)s') format='%(levelname)-8s %(message)s')
if opts.old_jid is None: if opts.old_jid is None:
opts.old_jid = raw_input("Old JID: ") opts.old_jid = input("Old JID: ")
if opts.old_password is None: if opts.old_password is None:
opts.old_password = getpass.getpass("Old Password: ") opts.old_password = getpass.getpass("Old Password: ")
if opts.new_jid is None: if opts.new_jid is None:
opts.new_jid = raw_input("New JID: ") opts.new_jid = input("New JID: ")
if opts.new_password is None: if opts.new_password is None:
opts.new_password = getpass.getpass("New Password: ") opts.new_password = getpass.getpass("New Password: ")

View File

@ -9,23 +9,12 @@
See the file LICENSE for copying permission. See the file LICENSE for copying permission.
""" """
import sys
import logging import logging
import getpass import getpass
from optparse import OptionParser from optparse import OptionParser
import slixmpp import slixmpp
# Python versions before 3.0 do not use UTF-8 encoding
# by default. To ensure that Unicode is handled properly
# throughout Slixmpp, we will set the default encoding
# ourselves to UTF-8.
if sys.version_info < (3, 0):
from slixmpp.util.misc_ops import setdefaultencoding
setdefaultencoding('utf8')
else:
raw_input = input
class MUCBot(slixmpp.ClientXMPP): class MUCBot(slixmpp.ClientXMPP):
@ -162,13 +151,13 @@ if __name__ == '__main__':
format='%(levelname)-8s %(message)s') format='%(levelname)-8s %(message)s')
if opts.jid is None: if opts.jid is None:
opts.jid = raw_input("Username: ") opts.jid = input("Username: ")
if opts.password is None: if opts.password is None:
opts.password = getpass.getpass("Password: ") opts.password = getpass.getpass("Password: ")
if opts.room is None: if opts.room is None:
opts.room = raw_input("MUC room: ") opts.room = input("MUC room: ")
if opts.nick is None: if opts.nick is None:
opts.nick = raw_input("MUC nickname: ") opts.nick = input("MUC nickname: ")
# Setup the MUCBot and register plugins. Note that while plugins may # Setup the MUCBot and register plugins. Note that while plugins may
# have interdependencies, the order in which you register them does # have interdependencies, the order in which you register them does

View File

@ -9,23 +9,12 @@
See the file LICENSE for copying permission. See the file LICENSE for copying permission.
""" """
import sys
import logging import logging
import getpass import getpass
from optparse import OptionParser from optparse import OptionParser
import slixmpp import slixmpp
# Python versions before 3.0 do not use UTF-8 encoding
# by default. To ensure that Unicode is handled properly
# throughout Slixmpp, we will set the default encoding
# ourselves to UTF-8.
if sys.version_info < (3, 0):
from slixmpp.util.misc_ops import setdefaultencoding
setdefaultencoding('utf8')
else:
raw_input = input
class PingTest(slixmpp.ClientXMPP): class PingTest(slixmpp.ClientXMPP):
@ -108,7 +97,7 @@ if __name__ == '__main__':
format='%(levelname)-8s %(message)s') format='%(levelname)-8s %(message)s')
if opts.jid is None: if opts.jid is None:
opts.jid = raw_input("Username: ") opts.jid = input("Username: ")
if opts.password is None: if opts.password is None:
opts.password = getpass.getpass("Password: ") opts.password = getpass.getpass("Password: ")

View File

@ -9,23 +9,12 @@
See the file LICENSE for copying permission. See the file LICENSE for copying permission.
""" """
import sys
import logging import logging
import getpass import getpass
from optparse import OptionParser from optparse import OptionParser
import slixmpp import slixmpp
# Python versions before 3.0 do not use UTF-8 encoding
# by default. To ensure that Unicode is handled properly
# throughout Slixmpp, we will set the default encoding
# ourselves to UTF-8.
if sys.version_info < (3, 0):
from slixmpp.util.misc_ops import setdefaultencoding
setdefaultencoding('utf8')
else:
raw_input = input
class EchoBot(slixmpp.ClientXMPP): class EchoBot(slixmpp.ClientXMPP):
@ -118,15 +107,15 @@ if __name__ == '__main__':
format='%(levelname)-8s %(message)s') format='%(levelname)-8s %(message)s')
if opts.jid is None: if opts.jid is None:
opts.jid = raw_input("Username: ") opts.jid = input("Username: ")
if opts.password is None: if opts.password is None:
opts.password = getpass.getpass("Password: ") opts.password = getpass.getpass("Password: ")
if opts.proxy_host is None: if opts.proxy_host is None:
opts.proxy_host = raw_input("Proxy host: ") opts.proxy_host = input("Proxy host: ")
if opts.proxy_port is None: if opts.proxy_port is None:
opts.proxy_port = raw_input("Proxy port: ") opts.proxy_port = input("Proxy port: ")
if opts.proxy_user is None: if opts.proxy_user is None:
opts.proxy_user = raw_input("Proxy username: ") opts.proxy_user = input("Proxy username: ")
if opts.proxy_pass is None and opts.proxy_user: if opts.proxy_pass is None and opts.proxy_user:
opts.proxy_pass = getpass.getpass("Proxy password: ") opts.proxy_pass = getpass.getpass("Proxy password: ")

View File

@ -1,7 +1,6 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
import sys
import logging import logging
import getpass import getpass
from optparse import OptionParser from optparse import OptionParser
@ -10,17 +9,6 @@ import slixmpp
from slixmpp.xmlstream import ET, tostring from slixmpp.xmlstream import ET, tostring
# Python versions before 3.0 do not use UTF-8 encoding
# by default. To ensure that Unicode is handled properly
# throughout Slixmpp, we will set the default encoding
# ourselves to UTF-8.
if sys.version_info < (3, 0):
from slixmpp.util.misc_ops import setdefaultencoding
setdefaultencoding('utf8')
else:
raw_input = input
class PubsubClient(slixmpp.ClientXMPP): class PubsubClient(slixmpp.ClientXMPP):
def __init__(self, jid, password, server, def __init__(self, jid, password, server,
@ -161,7 +149,7 @@ if __name__ == '__main__':
exit() exit()
if opts.jid is None: if opts.jid is None:
opts.jid = raw_input("Username: ") opts.jid = input("Username: ")
if opts.password is None: if opts.password is None:
opts.password = getpass.getpass("Password: ") opts.password = getpass.getpass("Password: ")

View File

@ -1,7 +1,6 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
import sys
import logging import logging
import getpass import getpass
from optparse import OptionParser from optparse import OptionParser
@ -12,17 +11,6 @@ from slixmpp.xmlstream.matcher import StanzaPath
from slixmpp.xmlstream.handler import Callback from slixmpp.xmlstream.handler import Callback
# Python versions before 3.0 do not use UTF-8 encoding
# by default. To ensure that Unicode is handled properly
# throughout Slixmpp, we will set the default encoding
# ourselves to UTF-8.
if sys.version_info < (3, 0):
from slixmpp.util.misc_ops import setdefaultencoding
setdefaultencoding('utf8')
else:
raw_input = input
class PubsubEvents(slixmpp.ClientXMPP): class PubsubEvents(slixmpp.ClientXMPP):
def __init__(self, jid, password): def __init__(self, jid, password):
@ -122,7 +110,7 @@ if __name__ == '__main__':
format='%(levelname)-8s %(message)s') format='%(levelname)-8s %(message)s')
if opts.jid is None: if opts.jid is None:
opts.jid = raw_input("Username: ") opts.jid = input("Username: ")
if opts.password is None: if opts.password is None:
opts.password = getpass.getpass("Password: ") opts.password = getpass.getpass("Password: ")

View File

@ -9,7 +9,6 @@
See the file LICENSE for copying permission. See the file LICENSE for copying permission.
""" """
import sys
import logging import logging
import getpass import getpass
from optparse import OptionParser from optparse import OptionParser
@ -17,16 +16,6 @@ from optparse import OptionParser
import slixmpp import slixmpp
from slixmpp.exceptions import IqError, IqTimeout from slixmpp.exceptions import IqError, IqTimeout
# Python versions before 3.0 do not use UTF-8 encoding
# by default. To ensure that Unicode is handled properly
# throughout Slixmpp, we will set the default encoding
# ourselves to UTF-8.
if sys.version_info < (3, 0):
from slixmpp.util.misc_ops import setdefaultencoding
setdefaultencoding('utf8')
else:
raw_input = input
class RegisterBot(slixmpp.ClientXMPP): class RegisterBot(slixmpp.ClientXMPP):
@ -140,7 +129,7 @@ if __name__ == '__main__':
format='%(levelname)-8s %(message)s') format='%(levelname)-8s %(message)s')
if opts.jid is None: if opts.jid is None:
opts.jid = raw_input("Username: ") opts.jid = input("Username: ")
if opts.password is None: if opts.password is None:
opts.password = getpass.getpass("Password: ") opts.password = getpass.getpass("Password: ")

View File

@ -9,7 +9,6 @@
See the file LICENSE for copying permission. See the file LICENSE for copying permission.
""" """
import sys
import logging import logging
import getpass import getpass
import threading import threading
@ -19,17 +18,6 @@ import slixmpp
from slixmpp.exceptions import IqError, IqTimeout from slixmpp.exceptions import IqError, IqTimeout
# Python versions before 3.0 do not use UTF-8 encoding
# by default. To ensure that Unicode is handled properly
# throughout Slixmpp, we will set the default encoding
# ourselves to UTF-8.
if sys.version_info < (3, 0):
from slixmpp.util.misc_ops import setdefaultencoding
setdefaultencoding('utf8')
else:
raw_input = input
class RosterBrowser(slixmpp.ClientXMPP): class RosterBrowser(slixmpp.ClientXMPP):
""" """
@ -144,7 +132,7 @@ if __name__ == '__main__':
format='%(levelname)-8s %(message)s') format='%(levelname)-8s %(message)s')
if opts.jid is None: if opts.jid is None:
opts.jid = raw_input("Username: ") opts.jid = input("Username: ")
if opts.password is None: if opts.password is None:
opts.password = getpass.getpass("Password: ") opts.password = getpass.getpass("Password: ")

View File

@ -9,23 +9,12 @@
See the file LICENSE for copying permission. See the file LICENSE for copying permission.
""" """
import sys
import logging import logging
import getpass import getpass
from optparse import OptionParser from optparse import OptionParser
import slixmpp import slixmpp
# Python versions before 3.0 do not use UTF-8 encoding
# by default. To ensure that Unicode is handled properly
# throughout Slixmpp, we will set the default encoding
# ourselves to UTF-8.
if sys.version_info < (3, 0):
from slixmpp.util.misc_ops import setdefaultencoding
setdefaultencoding('utf8')
else:
raw_input = input
class SendMsgBot(slixmpp.ClientXMPP): class SendMsgBot(slixmpp.ClientXMPP):
@ -106,13 +95,13 @@ if __name__ == '__main__':
format='%(levelname)-8s %(message)s') format='%(levelname)-8s %(message)s')
if opts.jid is None: if opts.jid is None:
opts.jid = raw_input("Username: ") opts.jid = input("Username: ")
if opts.password is None: if opts.password is None:
opts.password = getpass.getpass("Password: ") opts.password = getpass.getpass("Password: ")
if opts.to is None: if opts.to is None:
opts.to = raw_input("Send To: ") opts.to = input("Send To: ")
if opts.message is None: if opts.message is None:
opts.message = raw_input("Message: ") opts.message = input("Message: ")
# Setup the EchoBot and register plugins. Note that while plugins may # Setup the EchoBot and register plugins. Note that while plugins may
# have interdependencies, the order in which you register them does # have interdependencies, the order in which you register them does

View File

@ -10,7 +10,6 @@
""" """
import os import os
import sys
import imghdr import imghdr
import logging import logging
import getpass import getpass
@ -21,17 +20,6 @@ import slixmpp
from slixmpp.exceptions import XMPPError from slixmpp.exceptions import XMPPError
# Python versions before 3.0 do not use UTF-8 encoding
# by default. To ensure that Unicode is handled properly
# throughout Slixmpp, we will set the default encoding
# ourselves to UTF-8.
if sys.version_info < (3, 0):
from slixmpp.util.misc_ops import setdefaultencoding
setdefaultencoding('utf8')
else:
raw_input = input
class AvatarSetter(slixmpp.ClientXMPP): class AvatarSetter(slixmpp.ClientXMPP):
""" """
@ -142,11 +130,11 @@ if __name__ == '__main__':
format='%(levelname)-8s %(message)s') format='%(levelname)-8s %(message)s')
if opts.jid is None: if opts.jid is None:
opts.jid = raw_input("Username: ") opts.jid = input("Username: ")
if opts.password is None: if opts.password is None:
opts.password = getpass.getpass("Password: ") opts.password = getpass.getpass("Password: ")
if opts.filepath is None: if opts.filepath is None:
opts.filepath = raw_input("Avatar file location: ") opts.filepath = input("Avatar file location: ")
xmpp = AvatarSetter(opts.jid, opts.password, opts.filepath) xmpp = AvatarSetter(opts.jid, opts.password, opts.filepath)
xmpp.register_plugin('xep_0054') xmpp.register_plugin('xep_0054')

View File

@ -24,16 +24,6 @@ except ImportError:
import slixmpp import slixmpp
from slixmpp.xmlstream import JID from slixmpp.xmlstream import JID
# Python versions before 3.0 do not use UTF-8 encoding
# by default. To ensure that Unicode is handled properly
# throughout Slixmpp, we will set the default encoding
# ourselves to UTF-8.
if sys.version_info < (3, 0):
from slixmpp.util.misc_ops import setdefaultencoding
setdefaultencoding('utf8')
else:
raw_input = input
class ThirdPartyAuthBot(slixmpp.ClientXMPP): class ThirdPartyAuthBot(slixmpp.ClientXMPP):
@ -130,7 +120,7 @@ if __name__ == '__main__':
format='%(levelname)-8s %(message)s') format='%(levelname)-8s %(message)s')
if opts.jid is None: if opts.jid is None:
opts.jid = raw_input("Username: ") opts.jid = input("Username: ")
if opts.password is None: if opts.password is None:
opts.password = getpass.getpass("Password: ") opts.password = getpass.getpass("Password: ")

View File

@ -97,7 +97,7 @@ if __name__ == '__main__':
format='%(levelname)-8s %(message)s') format='%(levelname)-8s %(message)s')
if opts.jid is None: if opts.jid is None:
opts.jid = raw_input("Username: ") opts.jid = input("Username: ")
if opts.password is None: if opts.password is None:
opts.password = getpass.getpass("Password: ") opts.password = getpass.getpass("Password: ")

View File

@ -109,7 +109,7 @@ if __name__ == '__main__':
format='%(levelname)-8s %(message)s') format='%(levelname)-8s %(message)s')
if opts.jid is None: if opts.jid is None:
opts.jid = raw_input("Username: ") opts.jid = input("Username: ")
if opts.password is None: if opts.password is None:
opts.password = getpass.getpass("Password: ") opts.password = getpass.getpass("Password: ")