• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python misc_ops.setdefaultencoding函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中sleekxmpp.util.misc_ops.setdefaultencoding函数的典型用法代码示例。如果您正苦于以下问题:Python setdefaultencoding函数的具体用法?Python setdefaultencoding怎么用?Python setdefaultencoding使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了setdefaultencoding函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: main

def main(args=None, _bot_cls=MucChatBot, _cmd_cls=JibberCmd):
    if args is None:
        args = sys.argv[1:]

    _default = 'console'
    parser, sp = get_argparsers()

    # workaround for python2.7's incorrect(?) default usage.
    # won't be needed in python3.3.
    if not set.intersection(set(args), set(sp.choices.keys())):
        args.append(_default)

    parsed_args = parser.parse_args(args)

    # Python versions before 3.0 do not use UTF-8 encoding
    # by default. To ensure that Unicode is handled properly
    # throughout SleekXMPP, we will set the default encoding
    # ourselves to UTF-8.

    if sys.version_info < (3, 0): # pragma: no cover
        from sleekxmpp.util.misc_ops import setdefaultencoding
        setdefaultencoding('utf8')

    bot = _bot_cls()
    if bot.load_server_config_from_path(parsed_args.server_config) is None:
        print("Server config file `%s` not found." % parsed_args.server_config)
        return
    if bot.load_client_config_from_path(parsed_args.client_config) is None:
        print("Client config file `%s` not found." % parsed_args.client_config)
        return

    c = _cmd_cls(bot)

    # TODO make these logging configurable from the client_config
    logging.basicConfig(
        level='INFO',
        format='%(asctime)s %(levelname)s %(name)s %(message)s'
    )

    try:
        import readline
    except ImportError:  # pragma: no cover
        pass

    if parsed_args.command and parsed_args.command != _default:
        cmdarg = getattr(parsed_args, 'cmdarg', '')
        return c.onecmd(parsed_args.command + ' ' + cmdarg)
    else:  # interactive mode
        c.cmdloop()
开发者ID:metatoaster,项目名称:mtj.jibber,代码行数:49,代码来源:ctrl.py


示例2: setdefaultencoding

#!/usr/bin/env python
# -*- coding: utf-8 -*-

import firenado.core
import firenado.core.websocket
import logging
import tornado.escape
import uuid
import sys
from diaspora_jetpack.handlers import JetpackHandler

# Study this https://gist.github.com/mywaiting/4643396

if sys.version_info < (3, 0):
    from sleekxmpp.util.misc_ops import setdefaultencoding
    setdefaultencoding('utf8')
else:
    raw_input = input


class ChatHandler(firenado.core.TornadoHandler):

    def get(self):
        cache = []
        if self.session.id in self.component.xmpp_manager.connections:
            cache = self.component.xmpp_manager.connections[
                self.session.id]['cache']
        self.render("jetpack:chat/demo.html", messages=cache)


class ChatSocketHandler(firenado.core.websocket.TornadoWebSocketHandler, JetpackHandler):
开发者ID:piraz,项目名称:diaspora_jetpack,代码行数:31,代码来源:handlers.py


示例3: setdefaultencoding

from glob import glob
from os.path import splitext, basename, join as pjoin
from optparse import OptionParser
from urllib import urlopen

import sleekxmpp

# Python versions before 3.0 do not use UTF-8 encoding
# by default. To ensure that Unicode is handled properly
# throughout SleekXMPP, we will set the default encoding
# ourselves to UTF-8.
if sys.version_info < (3, 0):
    from sleekxmpp.util.misc_ops import setdefaultencoding

    setdefaultencoding("utf8")
else:
    raw_input = input

from sleekxmpp.plugins.xep_0323.device import Device

# from sleekxmpp.exceptions import IqError, IqTimeout


class IoT_TestDevice(sleekxmpp.ClientXMPP):

    """
    A simple IoT device that can act as server or client
    """

    def __init__(self, jid, password):
开发者ID:NickBMetaswitch,项目名称:SleekXMPP,代码行数:30,代码来源:IoT_TestDevice.py



注:本文中的sleekxmpp.util.misc_ops.setdefaultencoding函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python xmlstream.register_stanza_plugin函数代码示例发布时间:2022-05-27
下一篇:
Python util.bytes函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap