当前位置: 首页>>代码示例>>Python>>正文


Python _compat.text_type方法代码示例

本文整理汇总了Python中werkzeug._compat.text_type方法的典型用法代码示例。如果您正苦于以下问题:Python _compat.text_type方法的具体用法?Python _compat.text_type怎么用?Python _compat.text_type使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在werkzeug._compat的用法示例。


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

示例1: restart_with_reloader

# 需要导入模块: from werkzeug import _compat [as 别名]
# 或者: from werkzeug._compat import text_type [as 别名]
def restart_with_reloader(self):
        """Spawn a new Python interpreter with the same arguments as this one,
        but running the reloader thread.
        """
        while 1:
            _log('info', ' * Restarting with %s' % self.name)
            args = [sys.executable] + sys.argv
            new_environ = os.environ.copy()
            new_environ['WERKZEUG_RUN_MAIN'] = 'true'

            # a weird bug on windows. sometimes unicode strings end up in the
            # environment and subprocess.call does not like this, encode them
            # to latin1 and continue.
            if os.name == 'nt' and PY2:
                for key, value in iteritems(new_environ):
                    if isinstance(value, text_type):
                        new_environ[key] = value.encode('iso-8859-1')

            exit_code = subprocess.call(args, env=new_environ,
                                        close_fds=False)
            if exit_code != 3:
                return exit_code 
开发者ID:jpush,项目名称:jbox,代码行数:24,代码来源:_reloader.py

示例2: restart_with_reloader

# 需要导入模块: from werkzeug import _compat [as 别名]
# 或者: from werkzeug._compat import text_type [as 别名]
def restart_with_reloader(self):
        """Spawn a new Python interpreter with the same arguments as this one,
        but running the reloader thread.
        """
        while 1:
            _log('info', ' * Restarting with %s' % self.name)
            args = _get_args_for_reloading()
            new_environ = os.environ.copy()
            new_environ['WERKZEUG_RUN_MAIN'] = 'true'

            # a weird bug on windows. sometimes unicode strings end up in the
            # environment and subprocess.call does not like this, encode them
            # to latin1 and continue.
            if os.name == 'nt' and PY2:
                for key, value in iteritems(new_environ):
                    if isinstance(value, text_type):
                        new_environ[key] = value.encode('iso-8859-1')

            exit_code = subprocess.call(args, env=new_environ,
                                        close_fds=False)
            if exit_code != 3:
                return exit_code 
开发者ID:ryfeus,项目名称:lambda-packs,代码行数:24,代码来源:_reloader.py

示例3: restart_with_reloader

# 需要导入模块: from werkzeug import _compat [as 别名]
# 或者: from werkzeug._compat import text_type [as 别名]
def restart_with_reloader(self):
        """Spawn a new Python interpreter with the same arguments as this one,
        but running the reloader thread.
        """
        while 1:
            _log('info', ' * Restarting with %s' % self.name)
            args = [sys.executable] + sys.argv
            new_environ = os.environ.copy()
            new_environ['WERKZEUG_RUN_MAIN'] = 'true'

            # a weird bug on windows. sometimes unicode strings end up in the
            # environment and subprocess.call does not like this, encode them
            # to latin1 and continue.
            if os.name == 'nt' and PY2:
                for key, value in iteritems(new_environ):
                    if isinstance(value, text_type):
                        new_environ[key] = value.encode('iso-8859-1')

            exit_code = subprocess.call(args, env=new_environ)
            if exit_code != 3:
                return exit_code 
开发者ID:chalasr,项目名称:Flask-P2P,代码行数:23,代码来源:_reloader.py

示例4: hash_pin

# 需要导入模块: from werkzeug import _compat [as 别名]
# 或者: from werkzeug._compat import text_type [as 别名]
def hash_pin(pin):
    if isinstance(pin, text_type):
        pin = pin.encode('utf-8', 'replace')
    return hashlib.md5(pin + b'shittysalt').hexdigest()[:12] 
开发者ID:jpush,项目名称:jbox,代码行数:6,代码来源:__init__.py

示例5: _parse_multipart

# 需要导入模块: from werkzeug import _compat [as 别名]
# 或者: from werkzeug._compat import text_type [as 别名]
def _parse_multipart(self, stream, mimetype, content_length, options):
        parser = MultiPartParser(self.stream_factory, self.charset, self.errors,
                                 max_form_memory_size=self.max_form_memory_size,
                                 cls=self.cls)
        boundary = options.get('boundary')
        if boundary is None:
            raise ValueError('Missing boundary')
        if isinstance(boundary, text_type):
            boundary = boundary.encode('ascii')
        form, files = parser.parse(stream, boundary, content_length)
        return stream, form, files 
开发者ID:jpush,项目名称:jbox,代码行数:13,代码来源:formparser.py

示例6: _urandom

# 需要导入模块: from werkzeug import _compat [as 别名]
# 或者: from werkzeug._compat import text_type [as 别名]
def _urandom():
    if hasattr(os, 'urandom'):
        return os.urandom(30)
    return text_type(random()).encode('ascii') 
开发者ID:jpush,项目名称:jbox,代码行数:6,代码来源:sessions.py

示例7: __init__

# 需要导入模块: from werkzeug import _compat [as 别名]
# 或者: from werkzeug._compat import text_type [as 别名]
def __init__(self, path=None, filename_template='werkzeug_%s.sess',
                 session_class=None, renew_missing=False, mode=0o644):
        SessionStore.__init__(self, session_class)
        if path is None:
            path = tempfile.gettempdir()
        self.path = path
        if isinstance(filename_template, text_type) and PY2:
            filename_template = filename_template.encode(
                get_filesystem_encoding())
        assert not filename_template.endswith(_fs_transaction_suffix), \
            'filename templates may not end with %s' % _fs_transaction_suffix
        self.filename_template = filename_template
        self.renew_missing = renew_missing
        self.mode = mode 
开发者ID:jpush,项目名称:jbox,代码行数:16,代码来源:sessions.py


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