Python tornado.options.options 模块,address() 实例源码

我们从Python开源项目中,提取了以下10个代码示例,用于说明如何使用tornado.options.options.address()

项目:tornadopy    作者:xubigshu    | 项目源码 | 文件源码
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
项目:BGmi    作者:RicterZ    | 项目源码 | 文件源码
def main():
    tornado.options.parse_command_line()
    print('BGmi HTTP Server listening on %s:%d' % (options.address, options.port))
    http_server = tornado.httpserver.HTTPServer(make_app())
    http_server.listen(options.port, address=options.address)
    tornado.ioloop.IOLoop.current().start()
项目:incubator-milagro-mfa-server    作者:apache    | 项目源码 | 文件源码
def main():
    options.parse_command_line()

    if os.path.exists(options.configFile):
        try:
            options.parse_config_file(options.configFile)
            options.parse_command_line()
        except Exception, E:
            print("Invalid config file {0}".format(options.configFile))
            print(E)
            sys.exit(1)

    # Set Log level
    log.setLevel(getLogLevel(options.logLevel))

    if not options.cookieSecret:
        log.error("cookieSecret option required")
        sys.exit(1)

    detectProxy()
    mailer.setup(options.smtpServer, options.smtpPort, options.emailSender, options.smtpUseTLS)

    log.info("Server starting on {0}:{1}...".format(options.address, options.port))

    http_server = Application()
    http_server.listen(options.port, options.address, xheaders=True)
    io_loop = tornado.ioloop.IOLoop.instance()

    if options.autoReload:
        log.debug("Starting autoreloader")

        tornado.autoreload.watch(CONFIG_FILE)
        for f in os.listdir(http_server.settings["template_path"]):
            fn = os.path.join(http_server.settings["template_path"], f)
            if os.path.isfile(fn):
                tornado.autoreload.watch(fn)
        tornado.autoreload.start(io_loop)

    log.info("Server started. Listening on {0}:{1}".format(options.address, options.port))
    io_loop.start()
项目:texoid    作者:DMOJ    | 项目源码 | 文件源码
def main():
    tornado.options.parse_command_line()
    application = tornado.web.Application([
        (r"/", MainHandler),
    ])
    http_server = tornado.httpserver.HTTPServer(application)
    http_server.listen(options.port, address=options.address)
    tornado.ioloop.IOLoop.current().start()
项目:wscelery    作者:johan-sports    | 项目源码 | 文件源码
def test_address(self):
        with self.mock_option('address', '127.0.0.1'):
            command = WsCeleryCommand()
            command.apply_options('wscelery', argv=['--address=foobar'])
            self.assertEqual(options.address, 'foobar')
项目:bind-restapi    作者:jvdiago    | 项目源码 | 文件源码
def run(self):
        while True:
            app = Application()
            app.listen(options.port, options.address)
            IOLoop.instance().start()
项目:tornadopy    作者:xubigshu    | 项目源码 | 文件源码
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))
项目:tornadopy    作者:xubigshu    | 项目源码 | 文件源码
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='size',
                           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.')
项目:incubator-milagro-mfa-server    作者:apache    | 项目源码 | 文件源码
def main():
    options.parse_command_line()

    if os.path.exists(options.configFile):
        try:
            options.parse_config_file(options.configFile)
            options.parse_command_line()
        except Exception, E:
            print("Invalid config file {0}".format(options.configFile))
            print(E)
            sys.exit(1)

    # Set Log level
    log.setLevel(getLogLevel(options.logLevel))

    detectProxy()

    # Load the credentials from file
    log.info("Loading credentials")
    try:
        credentialsFile = options.credentialsFile
        Keys.loadFromFile(credentialsFile)
    except Exception as E:
        log.error("Error opening the credentials file: {0}".format(credentialsFile))
        log.error(E)
        sys.exit(1)

    # TMP fix for 'ValueError: I/O operation on closed epoll fd'
    # Fixed in Tornado 4.2
    tornado.ioloop.IOLoop.instance()

    # Sync time to CertiVox time server
    if options.syncTime:
        Time.getTime(wait=True)

    Keys.getAPISettings(wait=True)

    log.info("Server starting on {0}:{1}...".format(options.address, options.port))

    http_server = Application()
    http_server.listen(options.port, options.address, xheaders=True)
    main_loop = tornado.ioloop.IOLoop.instance()
    http_server.io_loop = main_loop

    if options.autoReload:
        log.debug("Starting autoreloader")

        tornado.autoreload.watch(CONFIG_FILE)
        tornado.autoreload.start(main_loop)

    process_dynamic_options(
        DYNAMIC_OPTION_MAPPING,
        DYNAMIC_OPTION_HANDLERS,
        application=http_server,
        initial=True)

    log.info("Server started. Listening on {0}:{1}".format(options.address, options.port))
    main_loop.start()
项目:incubator-milagro-mfa-server    作者:apache    | 项目源码 | 文件源码
def main():
    options.parse_command_line()

    if os.path.exists(options.configFile):
        try:
            options.parse_config_file(options.configFile)
            options.parse_command_line()
        except Exception, E:
            print("Invalid config file {0}".format(options.configFile))
            print(E)
            sys.exit(1)

    # Set Log level
    log.setLevel(getLogLevel(options.logLevel))

    detectProxy()

    # Load the credentials from file
    log.info("Loading credentials")
    try:
        credentialsFile = options.credentialsFile
        Keys.loadFromFile(credentialsFile)
    except Exception as E:
        log.error("Error opening the credentials file: {0}".format(credentialsFile))
        log.error(E)
        sys.exit(1)

    # TMP fix for 'ValueError: I/O operation on closed epoll fd'
    # Fixed in Tornado 4.2
    tornado.ioloop.IOLoop.instance()

    # Sync time to CertiVox time server
    if options.syncTime:
        Time.getTime(wait=True)

    if options.backup and options.encrypt_master_secret and not options.passphrase:
        options.passphrase = getpass.getpass("Please enter passphrase:")

    http_server = Application()
    http_server.listen(options.port, options.address, xheaders=True)
    io_loop = tornado.ioloop.IOLoop.instance()

    if options.autoReload:
        log.debug("Starting autoreloader")
        tornado.autoreload.watch(CONFIG_FILE)
        tornado.autoreload.start(io_loop)

    if options.syncTime and (options.timePeriod > 0):
        scheduler = tornado.ioloop.PeriodicCallback(Time.getTime, options.timePeriod, io_loop=io_loop)
        scheduler.start()

    log.info("Server started. Listening on {0}:{1}".format(options.address, options.port))
    io_loop.start()