本文整理汇总了Python中tornado.version_info方法的典型用法代码示例。如果您正苦于以下问题:Python tornado.version_info方法的具体用法?Python tornado.version_info怎么用?Python tornado.version_info使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tornado
的用法示例。
在下文中一共展示了tornado.version_info方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: import tornado [as 别名]
# 或者: from tornado import version_info [as 别名]
def __init__(self, handlers=None,
default_host="",
transforms=None,
wsgi=False,
middlewares=None,
**settings):
super(Application, self).__init__(
handlers=handlers,
default_host=default_host,
transforms=transforms,
wsgi=wsgi, **settings)
self.middleware_fac = Manager()
if middlewares:
self.middleware_fac.register_all(middlewares)
self.middleware_fac.run_init(self)
if version_info[0] > 3:
this = self
class HttpRequest(httputil.HTTPServerRequest):
def __init__(self, *args, **kwargs):
super(HttpRequest, self).__init__(*args, **kwargs)
this.middleware_fac.set_request(self)
try:
this.middleware_fac.run_call(self)
except Exception:
SysLogger.trace_logger.error(traceback.format_exc())
httputil.HTTPServerRequest = HttpRequest
示例2: __call__
# 需要导入模块: import tornado [as 别名]
# 或者: from tornado import version_info [as 别名]
def __call__(self, request):
if version_info[0] < 4:
try:
self.middleware_fac.set_request(request)
self.middleware_fac.run_call(request)
return web.Application.__call__(self, request)
except Exception, e:
SysLogger.trace_logger.error(e)
raise
示例3: __init__
# 需要导入模块: import tornado [as 别名]
# 或者: from tornado import version_info [as 别名]
def __init__(self, callback, schedule, io_loop=None, is_utc=False):
""" CrontabCallback initializer
:type callback: func
:param callback: target schedule function
:type schedule: str
:param schedule: crotab expression
:type io_loop: tornado.ioloop.IOLoop
:param io_loop: tornado IOLoop
:type is_utc: bool
:param is_utc: schedule timezone is UTC. (True:UTC, False:Local Timezone)
"""
# If Timezone is not supported and `is_utc` is set to `True`,
# a warning is output and `is_utc` is ignored.
if not IS_TZ_SUPPORTED and is_utc:
warnings.warn(UNSUPPORTED_TZ_MESSAGE)
is_utc = False
self.__crontab = CronTab(schedule)
self.__is_utc = is_utc
arguments = dict(
callback=callback, callback_time=self._calc_callbacktime())
if tornado_version_info >= (5,):
if io_loop is not None:
warnings.warn(UNSUPPORTED_IOLOOP_MESSAGE)
else:
arguments.update(io_loop=io_loop)
super(CronTabCallback, self).__init__(**arguments)
self.pid = os.getpid()
if os.name == "nt":
self.user = os.environ.get("USERNAME")
else:
import pwd
self.user = pwd.getpwuid(os.geteuid()).pw_name
示例4: pingable_ws_connect
# 需要导入模块: import tornado [as 别名]
# 或者: from tornado import version_info [as 别名]
def pingable_ws_connect(request=None,on_message_callback=None,
on_ping_callback=None, subprotocols=None):
"""
A variation on websocket_connect that returns a PingableWSClientConnection
with on_ping_callback.
"""
# Copy and convert the headers dict/object (see comments in
# AsyncHTTPClient.fetch)
request.headers = httputil.HTTPHeaders(request.headers)
request = httpclient._RequestProxy(
request, httpclient.HTTPRequest._DEFAULTS)
# for tornado 4.5.x compatibility
if version_info[0] == 4:
conn = PingableWSClientConnection(io_loop=ioloop.IOLoop.current(),
compression_options={},
request=request,
on_message_callback=on_message_callback,
on_ping_callback=on_ping_callback)
else:
conn = PingableWSClientConnection(request=request,
compression_options={},
on_message_callback=on_message_callback,
on_ping_callback=on_ping_callback,
max_message_size=getattr(websocket, '_default_max_message_size', 10 * 1024 * 1024),
subprotocols=subprotocols)
return conn.connect_future
# from https://stackoverflow.com/questions/38663666/how-can-i-serve-a-http-page-and-a-websocket-on-the-same-url-in-tornado
示例5: _newer_or_equal_
# 需要导入模块: import tornado [as 别名]
# 或者: from tornado import version_info [as 别名]
def _newer_or_equal_(v):
for i in six.moves.xrange(min(len(v), len(version_info))):
expected, tnd = v[i], version_info[i]
if tnd > expected:
return True
elif tnd == expected:
continue
else:
return False
return True
示例6: _equal_
# 需要导入模块: import tornado [as 别名]
# 或者: from tornado import version_info [as 别名]
def _equal_(v):
for i in six.moves.xrange(min(len(v), len(version_info))):
if v[i] != version_info[i]:
return False
return True