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


Python options.port方法代码示例

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


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

示例1: load_httpserver

# 需要导入模块: from tornado import options [as 别名]
# 或者: from tornado.options import port [as 别名]
def load_httpserver(self, sockets=None, **kwargs):
        if not sockets:
            from tornado.netutil import bind_sockets

            if settings.IPV4_ONLY:
                import socket

                sockets = bind_sockets(options.port, options.address, family=socket.AF_INET)
            else:
                sockets = bind_sockets(options.port, options.address)

        http_server = tornado.httpserver.HTTPServer(self.application, **kwargs)

        http_server.add_sockets(sockets)
        self.httpserver = http_server
        return self.httpserver 
开发者ID:mqingyn,项目名称:torngas,代码行数:18,代码来源:webserver.py

示例2: main

# 需要导入模块: from tornado import options [as 别名]
# 或者: from tornado.options import port [as 别名]
def main():
    logging.basicConfig(level=logging.DEBUG, format="%(levelname)8s %(asctime)s %(message)s ")
    logging.debug('Starting up server')
    from tornado.options import define, options
    define("certfile", default="", help="certificate file for secured SSL connection")
    define("keyfile", default="", help="key file for secured SSL connection")

    tornado.options.parse_command_line()
    app = Application()
    if options.certfile and options.keyfile:
        ssl_options = {
          "certfile": options.certfile,
          "keyfile": options.keyfile,
        }
        logging.info("Using SSL for serving requests")
        app.listen(options.port, ssl_options=ssl_options)
    else:
        app.listen(options.port)
    tornado.ioloop.IOLoop.instance().start() 
开发者ID:alumae,项目名称:kaldi-gstreamer-server,代码行数:21,代码来源:master_server.py

示例3: main

# 需要导入模块: from tornado import options [as 别名]
# 或者: from tornado.options import port [as 别名]
def main():
    tornado.options.parse_command_line()

    # Create the global connection pool.
    async with aiopg.create_pool(
        host=options.db_host,
        port=options.db_port,
        user=options.db_user,
        password=options.db_password,
        dbname=options.db_database,
    ) as db:
        await maybe_create_tables(db)
        app = Application(db)
        app.listen(options.port)

        # In this demo the server will simply run until interrupted
        # with Ctrl-C, but if you want to shut down more gracefully,
        # call shutdown_event.set().
        shutdown_event = tornado.locks.Event()
        await shutdown_event.wait() 
开发者ID:DataDog,项目名称:trace-examples,代码行数:22,代码来源:blog.py

示例4: get

# 需要导入模块: from tornado import options [as 别名]
# 或者: from tornado.options import port [as 别名]
def get(self, input):
        try:
            r = redis.StrictRedis(host='127.0.0.1', port=8323)
        except:
            print "Unable to connect to the Redis server"
            sys.exit(255)
	fp = input.lower()
	if not checksha1(value=fp):
            self.clear()
            self.set_status(400)
            self.finish('Incorrect format of the certificate fingerprint (expected SHA1 in hex format)')

	out = {}
	out['certificate'] = fp
	out['seen'] = []
	ips = r.smembers('s:{}'.format(fp))
	out['hits'] = len(ips)
	for ip in ips:
		out['seen'].append(ip)

	if not self._finished:
            self.set_header('Content-Type', 'application/json')
            self.set_header('Server', servername)
            self.write(json.dumps(out)) 
开发者ID:adulau,项目名称:crl-monitor,代码行数:26,代码来源:ip-ssl-subject-api.py

示例5: run_request

# 需要导入模块: from tornado import options [as 别名]
# 或者: from tornado.options import port [as 别名]
def run_request(self, q):
        try:
            r = redis.StrictRedis(host='127.0.0.1', port=8323)
        except:
            print("Unable to connect to the Redis server")
            sys.exit(255)
        fp = q.lower()
        if not checksha1(value=fp):
            self.clear()
            self.set_status(400)
            self.finish('Incorrect format of the certificate fingerprint (expected SHA1 in hex format)')

        out = {}
        out['certificate'] = fp
        out['seen'] = []
        ips = r.smembers('s:{}'.format(fp))
        out['hits'] = len(ips)
        for ip in ips:
                out['seen'].append(ip)

        if not self._finished:
            self.set_header('Content-Type', 'application/json')
            self.set_header('Server', servername)
            return json.dumps(out) 
开发者ID:adulau,项目名称:crl-monitor,代码行数:26,代码来源:ip-ssl-subject-api.py

示例6: main

# 需要导入模块: from tornado import options [as 别名]
# 或者: from tornado.options import port [as 别名]
def main():
    tornado.options.parse_command_line()
    app = Application()
    app.listen(options.port)
    tornado.ioloop.IOLoop.current().start() 
开发者ID:tao12345666333,项目名称:tornado-zh,代码行数:7,代码来源:chatdemo.py

示例7: main

# 需要导入模块: from tornado import options [as 别名]
# 或者: from tornado.options import port [as 别名]
def main():
    tornado.options.parse_command_line()
    application = tornado.web.Application([
        (r"/", MainHandler),
    ])
    http_server = tornado.httpserver.HTTPServer(application)
    http_server.listen(options.port)
    tornado.ioloop.IOLoop.current().start() 
开发者ID:tao12345666333,项目名称:tornado-zh,代码行数:10,代码来源:helloworld.py

示例8: main

# 需要导入模块: from tornado import options [as 别名]
# 或者: from tornado.options import port [as 别名]
def main():
    tornado.options.parse_command_line()
    http_server = tornado.httpserver.HTTPServer(Application())
    http_server.listen(options.port)
    tornado.ioloop.IOLoop.current().start() 
开发者ID:tao12345666333,项目名称:tornado-zh,代码行数:7,代码来源:blog.py

示例9: main

# 需要导入模块: from tornado import options [as 别名]
# 或者: from tornado.options import port [as 别名]
def main():
    tornado.options.parse_command_line()
    if not (options.facebook_api_key and options.facebook_secret):
        print("--facebook_api_key and --facebook_secret must be set")
        return
    http_server = tornado.httpserver.HTTPServer(Application())
    http_server.listen(options.port)
    tornado.ioloop.IOLoop.current().start() 
开发者ID:tao12345666333,项目名称:tornado-zh,代码行数:10,代码来源:facebook.py

示例10: get

# 需要导入模块: from tornado import options [as 别名]
# 或者: from tornado.options import port [as 别名]
def get(self):
        connect = MySQLdb.connect(user='root',
                                  passwd='',
                                  db='test',
                                  host='localhost',
                                  port=3306,
                                  charset='utf8')
        cursor = connect.cursor()
        cursor.execute('SELECT * FROM app_blog LIMIT 1')
        result = cursor.fetchone()
        cursor.close()
        connect.close()
        self.finish(u'<p>{}</p><p>{}</p>'.format(result[1], result[2])) 
开发者ID:zhu327,项目名称:greentor,代码行数:15,代码来源:hello.py

示例11: main

# 需要导入模块: from tornado import options [as 别名]
# 或者: from tornado.options import port [as 别名]
def main():
    tornado.options.parse_command_line()
    application = tornado.web.Application([(r"/", MainHandler),
                                           (r"/pool/", ConnectionPoolHandler)],
                                          debug=True)
    http_server = tornado.httpserver.HTTPServer(application)
    http_server.listen(options.port)
    tornado.ioloop.IOLoop.instance().start() 
开发者ID:zhu327,项目名称:greentor,代码行数:10,代码来源:hello.py

示例12: main

# 需要导入模块: from tornado import options [as 别名]
# 或者: from tornado.options import port [as 别名]
def main():
    # 该方法会将根日志的级别设置为INFO
    tornado.options.parse_command_line()
    # 将日志的级别重新设置为LOGGING_LEVEL指定的级别
    logger.setLevel(config.LOGGING_LEVEL)

    http_server = tornado.httpserver.HTTPServer(app)
    http_server.listen(options.port)

    logger.info('tornado server is running on %s' % options.port)
    tornado.ioloop.IOLoop.instance().start() 
开发者ID:restran,项目名称:web-proxy,代码行数:13,代码来源:proxy.py

示例13: print_settings_info

# 需要导入模块: from tornado import options [as 别名]
# 或者: from tornado.options import port [as 别名]
def print_settings_info(self):
        if settings.DEBUG:
            print('tornado version: %s' % tornado.version)
            print('locale support: %s' % settings.TRANSLATIONS)
            print('load apps:')
            for app in settings.INSTALLED_APPS:
                print(' - %s' % str(app))
            print('template engine: %s' % (settings.TEMPLATE_CONFIG.template_engine or 'default'))
            print('server started. development server at http://%s:%s/' % (options.address, options.port)) 
开发者ID:mqingyn,项目名称:torngas,代码行数:11,代码来源:webserver.py

示例14: parse_logger_callback

# 需要导入模块: from tornado import options [as 别名]
# 或者: from tornado.options import port [as 别名]
def parse_logger_callback(self):
        if options.disable_log:
            options.logging = None
        if options.log_file_prefix and options.log_port_prefix:
            options.log_file_prefix += ".%s" % options.port
        if options.log_patch:
            logging.handlers.TimedRotatingFileHandler = ProcessLogTimedFileHandler
        tornado_logger = logging.getLogger('tornado')
        enable_pretty_logging(logger=tornado_logger)
        logdir = options.logging_dir or settings.LOGGING_DIR
        for log in settings.LOGGING:
            opt = OptionParser()
            define_logging_options(opt)
            self.define(opt)
            opt.log_rotate_when = log.get('when', 'midnight')
            opt.log_to_stderr = log.get('log_to_stderr', False) if options.log_to_stderr is None else options.log_to_stderr
            opt.logging = log.get('level', 'INFO')
            opt.log_file_prefix = os.path.join(logdir, log['filename'])
            if log.get('backups'):
                opt.log_file_num_backups = log.get('backups')
            if opt.log_port_prefix:
                opt.log_file_prefix += ".%s" % options.port
            opt.log_rotate_interval = log.get('interval', 1)
            opt.log_rotate_mode = 'time'
            logger = logging.getLogger(log['name'])
            logger.propagate = 0
            enable_pretty_logging(options=opt, logger=logger)
            map(lambda h: h.setFormatter(LogFormatter(fmt=log.get("formatter", LogFormatter.DEFAULT_FORMAT),
                                                      color=settings.DEBUG)), logger.handlers) 
开发者ID:mqingyn,项目名称:torngas,代码行数:31,代码来源:webserver.py

示例15: define

# 需要导入模块: from tornado import options [as 别名]
# 或者: from tornado.options import port [as 别名]
def define(self, options=options):
        """
        定义命令行参数,你可以自定义很多自己的命令行参数,或重写此方法覆盖默认参数
        :return:
        """
        try:
            # 增加timerotating日志配置
            options.define("log_rotate_when", type=str, default='midnight',
                           help=("specify the type of TimedRotatingFileHandler interval "
                                 "other options:('S', 'M', 'H', 'D', 'W0'-'W6')"))
            options.define("log_rotate_interval", type=int, default=1,
                           help="The interval value of timed rotating")

            options.define("log_rotate_mode", type=str, default='time',
                           help="The mode of rotating files(time or size)")
        except:
            pass
        options.define("port", default=8000, help="run server on it", type=int)
        options.define("settings", default='', help="setting module name", type=str)
        options.define("address", default='0.0.0.0', help='listen host,default:0.0.0.0', type=str)
        options.define("log_patch", default=True,
                       help='Use ProcessTimedRotatingFileHandler instead of the default TimedRotatingFileHandler.',
                       type=bool)

        options.define("log_port_prefix", default=None, help='add port to log file prefix.', type=bool)
        options.define("logging_dir", default='', help='custom log dir.')
        options.define("disable_log", default=True, help='disable tornado log function.') 
开发者ID:mqingyn,项目名称:torngas,代码行数:29,代码来源:webserver.py


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