From df68bb48961574436c1ffc2463a31cd7d8227606 Mon Sep 17 00:00:00 2001 From: Emmanuel Gil Peyrot Date: Sat, 16 Aug 2014 22:37:29 +0200 Subject: Remove raw_input usage and other python2 support in examples --- examples/IoT_TestDevice.py | 12 +----------- examples/adhoc_provider.py | 13 +------------ examples/adhoc_user.py | 17 +++-------------- examples/admin_commands.py | 19 ++++--------------- examples/custom_stanzas/custom_stanza_provider.py | 13 +------------ examples/custom_stanzas/custom_stanza_user.py | 15 ++------------- examples/disco_browser.py | 14 +------------- examples/download_avatars.py | 14 +------------- examples/echo_client.py | 13 +------------ examples/echo_component.py | 17 +++-------------- examples/gtalk_custom_domain.py | 14 +------------- examples/ibb_transfer/ibb_receiver.py | 13 +------------ examples/ibb_transfer/ibb_sender.py | 17 +++-------------- examples/migrate_roster.py | 14 ++------------ examples/muc.py | 17 +++-------------- examples/ping.py | 13 +------------ examples/proxy_echo_client.py | 19 ++++--------------- examples/pubsub_client.py | 14 +------------- examples/pubsub_events.py | 14 +------------- examples/register_account.py | 13 +------------ examples/roster_browser.py | 14 +------------- examples/send_client.py | 17 +++-------------- examples/set_avatar.py | 16 ++-------------- examples/thirdparty_auth.py | 12 +----------- examples/user_location.py | 2 +- examples/user_tune.py | 2 +- 26 files changed, 45 insertions(+), 313 deletions(-) diff --git a/examples/IoT_TestDevice.py b/examples/IoT_TestDevice.py index aff2d945..795d782a 100755 --- a/examples/IoT_TestDevice.py +++ b/examples/IoT_TestDevice.py @@ -27,16 +27,6 @@ from optparse import OptionParser from urllib import urlopen 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.exceptions import IqError, IqTimeout @@ -160,7 +150,7 @@ if __name__ == '__main__': format='%(levelname)-8s %(message)s') if opts.jid is None: - opts.jid = raw_input("Username: ") + opts.jid = input("Username: ") if opts.password is None: opts.password = getpass.getpass("Password: ") diff --git a/examples/adhoc_provider.py b/examples/adhoc_provider.py index 689ea2a6..e0a7effd 100755 --- a/examples/adhoc_provider.py +++ b/examples/adhoc_provider.py @@ -9,23 +9,12 @@ See the file LICENSE for copying permission. """ -import sys import logging import getpass from optparse import OptionParser 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): @@ -169,7 +158,7 @@ if __name__ == '__main__': format='%(levelname)-8s %(message)s') if opts.jid is None: - opts.jid = raw_input("Username: ") + opts.jid = input("Username: ") if opts.password is None: opts.password = getpass.getpass("Password: ") diff --git a/examples/adhoc_user.py b/examples/adhoc_user.py index be587e41..646b41ac 100755 --- a/examples/adhoc_user.py +++ b/examples/adhoc_user.py @@ -9,23 +9,12 @@ See the file LICENSE for copying permission. """ -import sys import logging import getpass from optparse import OptionParser 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): @@ -172,13 +161,13 @@ if __name__ == '__main__': format='%(levelname)-8s %(message)s') if opts.jid is None: - opts.jid = raw_input("Username: ") + opts.jid = input("Username: ") if opts.password is None: opts.password = getpass.getpass("Password: ") if opts.other is None: - opts.other = raw_input("JID Providing Commands: ") + opts.other = input("JID Providing Commands: ") 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 # have interdependencies, the order in which you register them does diff --git a/examples/admin_commands.py b/examples/admin_commands.py index 5ee7079e..e6415a45 100755 --- a/examples/admin_commands.py +++ b/examples/admin_commands.py @@ -9,23 +9,12 @@ See the file LICENSE for copying permission. """ -import sys import logging import getpass from optparse import OptionParser 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): @@ -81,13 +70,13 @@ class AdminCommands(slixmpp.ClientXMPP): for var, field in form['fields'].items(): if var != 'FORM_TYPE': 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'): answers[var] = '1' else: answers[var] = '0' else: - answers[var] = raw_input('%s: ' % field['label']) + answers[var] = input('%s: ' % field['label']) else: answers['FORM_TYPE'] = field['value'] form['type'] = 'submit' @@ -144,11 +133,11 @@ if __name__ == '__main__': format='%(levelname)-8s %(message)s') if opts.jid is None: - opts.jid = raw_input("Username: ") + opts.jid = input("Username: ") if opts.password is None: opts.password = getpass.getpass("Password: ") 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 # have interdependencies, the order in which you register them does diff --git a/examples/custom_stanzas/custom_stanza_provider.py b/examples/custom_stanzas/custom_stanza_provider.py index 0356b973..5782b671 100755 --- a/examples/custom_stanzas/custom_stanza_provider.py +++ b/examples/custom_stanzas/custom_stanza_provider.py @@ -9,7 +9,6 @@ See the file LICENSE for copying permission. """ -import sys import logging import getpass from optparse import OptionParser @@ -23,16 +22,6 @@ from slixmpp.xmlstream.handler import Callback from slixmpp.xmlstream.matcher import StanzaPath 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): @@ -138,7 +127,7 @@ if __name__ == '__main__': format='%(levelname)-8s %(message)s') if opts.jid is None: - opts.jid = raw_input("Username: ") + opts.jid = input("Username: ") if opts.password is None: opts.password = getpass.getpass("Password: ") diff --git a/examples/custom_stanzas/custom_stanza_user.py b/examples/custom_stanzas/custom_stanza_user.py index a7388cff..21722196 100755 --- a/examples/custom_stanzas/custom_stanza_user.py +++ b/examples/custom_stanzas/custom_stanza_user.py @@ -9,7 +9,6 @@ See the file LICENSE for copying permission. """ -import sys import logging import getpass from optparse import OptionParser @@ -21,16 +20,6 @@ from slixmpp.xmlstream import register_stanza_plugin 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): @@ -139,11 +128,11 @@ if __name__ == '__main__': format='%(levelname)-8s %(message)s') if opts.jid is None: - opts.jid = raw_input("Username: ") + opts.jid = input("Username: ") if opts.password is None: opts.password = getpass.getpass("Password: ") 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 # have interdependencies, the order in which you register them does diff --git a/examples/disco_browser.py b/examples/disco_browser.py index ec2e6ede..b088fdc0 100755 --- a/examples/disco_browser.py +++ b/examples/disco_browser.py @@ -9,7 +9,6 @@ See the file LICENSE for copying permission. """ -import sys import logging import getpass from optparse import OptionParser @@ -18,17 +17,6 @@ import slixmpp 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): """ @@ -176,7 +164,7 @@ if __name__ == '__main__': args = (args[0], args[1], '') if opts.jid is None: - opts.jid = raw_input("Username: ") + opts.jid = input("Username: ") if opts.password is None: opts.password = getpass.getpass("Password: ") diff --git a/examples/download_avatars.py b/examples/download_avatars.py index 9dd0283f..dc35df80 100755 --- a/examples/download_avatars.py +++ b/examples/download_avatars.py @@ -9,7 +9,6 @@ See the file LICENSE for copying permission. """ -import sys import logging import getpass import threading @@ -19,17 +18,6 @@ import slixmpp 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 = { 'image/png': 'png', 'image/gif': 'gif', @@ -154,7 +142,7 @@ if __name__ == '__main__': format='%(levelname)-8s %(message)s') if opts.jid is None: - opts.jid = raw_input("Username: ") + opts.jid = input("Username: ") if opts.password is None: opts.password = getpass.getpass("Password: ") diff --git a/examples/echo_client.py b/examples/echo_client.py index cf79867b..733b541d 100755 --- a/examples/echo_client.py +++ b/examples/echo_client.py @@ -9,23 +9,12 @@ See the file LICENSE for copying permission. """ -import sys import logging import getpass from optparse import OptionParser 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): @@ -109,7 +98,7 @@ if __name__ == '__main__': format='%(levelname)-8s %(message)s') if opts.jid is None: - opts.jid = raw_input("Username: ") + opts.jid = input("Username: ") if opts.password is None: opts.password = getpass.getpass("Password: ") diff --git a/examples/echo_component.py b/examples/echo_component.py index 79de3e99..d56935f8 100755 --- a/examples/echo_component.py +++ b/examples/echo_component.py @@ -9,7 +9,6 @@ See the file LICENSE for copying permission. """ -import sys import logging import getpass from optparse import OptionParser @@ -17,16 +16,6 @@ from optparse import OptionParser import slixmpp 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): @@ -93,13 +82,13 @@ if __name__ == '__main__': opts, args = optp.parse_args() if opts.jid is None: - opts.jid = raw_input("Component JID: ") + opts.jid = input("Component JID: ") if opts.password is None: opts.password = getpass.getpass("Password: ") if opts.server is None: - opts.server = raw_input("Server: ") + opts.server = input("Server: ") if opts.port is None: - opts.port = int(raw_input("Port: ")) + opts.port = int(input("Port: ")) # Setup logging. logging.basicConfig(level=opts.loglevel, diff --git a/examples/gtalk_custom_domain.py b/examples/gtalk_custom_domain.py index e6bde69a..92d9fea3 100755 --- a/examples/gtalk_custom_domain.py +++ b/examples/gtalk_custom_domain.py @@ -9,7 +9,6 @@ See the file LICENSE for copying permission. """ -import sys import logging import getpass from optparse import OptionParser @@ -20,17 +19,6 @@ import ssl 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): """ @@ -130,7 +118,7 @@ if __name__ == '__main__': format='%(levelname)-8s %(message)s') if opts.jid is None: - opts.jid = raw_input("Username: ") + opts.jid = input("Username: ") if opts.password is None: opts.password = getpass.getpass("Password: ") diff --git a/examples/ibb_transfer/ibb_receiver.py b/examples/ibb_transfer/ibb_receiver.py index 1f78ce05..dd9171d2 100755 --- a/examples/ibb_transfer/ibb_receiver.py +++ b/examples/ibb_transfer/ibb_receiver.py @@ -9,23 +9,12 @@ See the file LICENSE for copying permission. """ -import sys import logging import getpass from optparse import OptionParser 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): @@ -119,7 +108,7 @@ if __name__ == '__main__': format='%(levelname)-8s %(message)s') if opts.jid is None: - opts.jid = raw_input("Username: ") + opts.jid = input("Username: ") if opts.password is None: opts.password = getpass.getpass("Password: ") diff --git a/examples/ibb_transfer/ibb_sender.py b/examples/ibb_transfer/ibb_sender.py index 5366c6ff..2d88d4ce 100755 --- a/examples/ibb_transfer/ibb_sender.py +++ b/examples/ibb_transfer/ibb_sender.py @@ -9,23 +9,12 @@ See the file LICENSE for copying permission. """ -import sys import logging import getpass from optparse import OptionParser 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): @@ -105,13 +94,13 @@ if __name__ == '__main__': format='%(levelname)-8s %(message)s') if opts.jid is None: - opts.jid = raw_input("Username: ") + opts.jid = input("Username: ") if opts.password is None: opts.password = getpass.getpass("Password: ") if opts.receiver is None: - opts.receiver = raw_input("Receiver: ") + opts.receiver = input("Receiver: ") 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 # have interdependencies, the order in which you register them does diff --git a/examples/migrate_roster.py b/examples/migrate_roster.py index 8e923362..e7849135 100755 --- a/examples/migrate_roster.py +++ b/examples/migrate_roster.py @@ -8,16 +8,6 @@ from optparse import OptionParser 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. optp = OptionParser() @@ -52,12 +42,12 @@ logging.basicConfig(level=opts.loglevel, format='%(levelname)-8s %(message)s') 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: opts.old_password = getpass.getpass("Old Password: ") 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: opts.new_password = getpass.getpass("New Password: ") diff --git a/examples/muc.py b/examples/muc.py index e67196dd..08a71a44 100755 --- a/examples/muc.py +++ b/examples/muc.py @@ -9,23 +9,12 @@ See the file LICENSE for copying permission. """ -import sys import logging import getpass from optparse import OptionParser 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): @@ -162,13 +151,13 @@ if __name__ == '__main__': format='%(levelname)-8s %(message)s') if opts.jid is None: - opts.jid = raw_input("Username: ") + opts.jid = input("Username: ") if opts.password is None: opts.password = getpass.getpass("Password: ") if opts.room is None: - opts.room = raw_input("MUC room: ") + opts.room = input("MUC room: ") 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 # have interdependencies, the order in which you register them does diff --git a/examples/ping.py b/examples/ping.py index 5bcd0086..85cf722b 100755 --- a/examples/ping.py +++ b/examples/ping.py @@ -9,23 +9,12 @@ See the file LICENSE for copying permission. """ -import sys import logging import getpass from optparse import OptionParser 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): @@ -108,7 +97,7 @@ if __name__ == '__main__': format='%(levelname)-8s %(message)s') if opts.jid is None: - opts.jid = raw_input("Username: ") + opts.jid = input("Username: ") if opts.password is None: opts.password = getpass.getpass("Password: ") diff --git a/examples/proxy_echo_client.py b/examples/proxy_echo_client.py index 161d6d70..b4b4dab4 100755 --- a/examples/proxy_echo_client.py +++ b/examples/proxy_echo_client.py @@ -9,23 +9,12 @@ See the file LICENSE for copying permission. """ -import sys import logging import getpass from optparse import OptionParser 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): @@ -118,15 +107,15 @@ if __name__ == '__main__': format='%(levelname)-8s %(message)s') if opts.jid is None: - opts.jid = raw_input("Username: ") + opts.jid = input("Username: ") if opts.password is None: opts.password = getpass.getpass("Password: ") 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: - opts.proxy_port = raw_input("Proxy port: ") + opts.proxy_port = input("Proxy port: ") 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: opts.proxy_pass = getpass.getpass("Proxy password: ") diff --git a/examples/pubsub_client.py b/examples/pubsub_client.py index afbb437f..3b413e24 100755 --- a/examples/pubsub_client.py +++ b/examples/pubsub_client.py @@ -1,7 +1,6 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- -import sys import logging import getpass from optparse import OptionParser @@ -10,17 +9,6 @@ import slixmpp 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): def __init__(self, jid, password, server, @@ -161,7 +149,7 @@ if __name__ == '__main__': exit() if opts.jid is None: - opts.jid = raw_input("Username: ") + opts.jid = input("Username: ") if opts.password is None: opts.password = getpass.getpass("Password: ") diff --git a/examples/pubsub_events.py b/examples/pubsub_events.py index 6464db97..f2384db8 100755 --- a/examples/pubsub_events.py +++ b/examples/pubsub_events.py @@ -1,7 +1,6 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- -import sys import logging import getpass from optparse import OptionParser @@ -12,17 +11,6 @@ from slixmpp.xmlstream.matcher import StanzaPath 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): def __init__(self, jid, password): @@ -122,7 +110,7 @@ if __name__ == '__main__': format='%(levelname)-8s %(message)s') if opts.jid is None: - opts.jid = raw_input("Username: ") + opts.jid = input("Username: ") if opts.password is None: opts.password = getpass.getpass("Password: ") diff --git a/examples/register_account.py b/examples/register_account.py index 7b8a2514..00bdfd0f 100755 --- a/examples/register_account.py +++ b/examples/register_account.py @@ -9,7 +9,6 @@ See the file LICENSE for copying permission. """ -import sys import logging import getpass from optparse import OptionParser @@ -17,16 +16,6 @@ from optparse import OptionParser import slixmpp 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): @@ -140,7 +129,7 @@ if __name__ == '__main__': format='%(levelname)-8s %(message)s') if opts.jid is None: - opts.jid = raw_input("Username: ") + opts.jid = input("Username: ") if opts.password is None: opts.password = getpass.getpass("Password: ") diff --git a/examples/roster_browser.py b/examples/roster_browser.py index ca53769b..785221da 100755 --- a/examples/roster_browser.py +++ b/examples/roster_browser.py @@ -9,7 +9,6 @@ See the file LICENSE for copying permission. """ -import sys import logging import getpass import threading @@ -19,17 +18,6 @@ import slixmpp 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): """ @@ -144,7 +132,7 @@ if __name__ == '__main__': format='%(levelname)-8s %(message)s') if opts.jid is None: - opts.jid = raw_input("Username: ") + opts.jid = input("Username: ") if opts.password is None: opts.password = getpass.getpass("Password: ") diff --git a/examples/send_client.py b/examples/send_client.py index 579807b1..60c589e4 100755 --- a/examples/send_client.py +++ b/examples/send_client.py @@ -9,23 +9,12 @@ See the file LICENSE for copying permission. """ -import sys import logging import getpass from optparse import OptionParser 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): @@ -106,13 +95,13 @@ if __name__ == '__main__': format='%(levelname)-8s %(message)s') if opts.jid is None: - opts.jid = raw_input("Username: ") + opts.jid = input("Username: ") if opts.password is None: opts.password = getpass.getpass("Password: ") if opts.to is None: - opts.to = raw_input("Send To: ") + opts.to = input("Send To: ") 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 # have interdependencies, the order in which you register them does diff --git a/examples/set_avatar.py b/examples/set_avatar.py index db189413..e687e6e0 100755 --- a/examples/set_avatar.py +++ b/examples/set_avatar.py @@ -10,7 +10,6 @@ """ import os -import sys import imghdr import logging import getpass @@ -21,17 +20,6 @@ import slixmpp 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): """ @@ -142,11 +130,11 @@ if __name__ == '__main__': format='%(levelname)-8s %(message)s') if opts.jid is None: - opts.jid = raw_input("Username: ") + opts.jid = input("Username: ") if opts.password is None: opts.password = getpass.getpass("Password: ") 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.register_plugin('xep_0054') diff --git a/examples/thirdparty_auth.py b/examples/thirdparty_auth.py index 6772e298..fbe49f8b 100755 --- a/examples/thirdparty_auth.py +++ b/examples/thirdparty_auth.py @@ -24,16 +24,6 @@ except ImportError: import slixmpp 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): @@ -130,7 +120,7 @@ if __name__ == '__main__': format='%(levelname)-8s %(message)s') if opts.jid is None: - opts.jid = raw_input("Username: ") + opts.jid = input("Username: ") if opts.password is None: opts.password = getpass.getpass("Password: ") diff --git a/examples/user_location.py b/examples/user_location.py index 823beb0a..5fa4f560 100755 --- a/examples/user_location.py +++ b/examples/user_location.py @@ -97,7 +97,7 @@ if __name__ == '__main__': format='%(levelname)-8s %(message)s') if opts.jid is None: - opts.jid = raw_input("Username: ") + opts.jid = input("Username: ") if opts.password is None: opts.password = getpass.getpass("Password: ") diff --git a/examples/user_tune.py b/examples/user_tune.py index 528a8d45..96548514 100755 --- a/examples/user_tune.py +++ b/examples/user_tune.py @@ -109,7 +109,7 @@ if __name__ == '__main__': format='%(levelname)-8s %(message)s') if opts.jid is None: - opts.jid = raw_input("Username: ") + opts.jid = input("Username: ") if opts.password is None: opts.password = getpass.getpass("Password: ") -- cgit v1.2.3