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

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

项目:geekcloud    作者:Mr-Linus    | 项目源码 | 文件源码
def run_cmd(self, command, pattern):
        self.runner.run('shell', command, pattern=pattern)
        ExecLog(host=self.asset_name_str, cmd=self.command, user=self.user.username,
                remote_ip=self.remote_ip, result=self.runner.results).save()
        newline_pattern = re.compile(r'\n')
        for k, v in self.runner.results.items():
            for host, output in v.items():
                output = newline_pattern.sub('<br />', output)
                if k == 'ok':
                    header = "<span style='color: green'>[ %s => %s]</span>\n" % (host, 'Ok')
                else:
                    header = "<span style='color: red'>[ %s => %s]</span>\n" % (host, 'failed')
                self.write_message(header)
                self.write_message(output)

        self.write_message('\n~o~ Task finished ~o~\n')
项目:geekcloud    作者:GeekCloud-Team    | 项目源码 | 文件源码
def run_cmd(self, command, pattern):
        self.runner.run('shell', command, pattern=pattern)
        ExecLog(host=self.asset_name_str, cmd=self.command, user=self.user.username,
                remote_ip=self.remote_ip, result=self.runner.results).save()
        newline_pattern = re.compile(r'\n')
        for k, v in self.runner.results.items():
            for host, output in v.items():
                output = newline_pattern.sub('<br />', output)
                if k == 'ok':
                    header = "<span style='color: green'>[ %s => %s]</span>\n" % (host, 'Ok')
                else:
                    header = "<span style='color: red'>[ %s => %s]</span>\n" % (host, 'failed')
                self.write_message(header)
                self.write_message(output)

        self.write_message('\n~o~ Task finished ~o~\n')
项目:server    作者:sgr-smile2015    | 项目源码 | 文件源码
def run_cmd(self, command, pattern):
        self.runner.run('shell', command, pattern=pattern)
        ExecLog(host=self.asset_name_str, cmd=self.command, user=self.user.username,
                remote_ip=self.remote_ip, result=self.runner.results).save()
        newline_pattern = re.compile(r'\n')
        for k, v in self.runner.results.items():
            for host, output in v.items():
                output = newline_pattern.sub('<br />', output)
                if k == 'ok':
                    header = "<span style='color: green'>[ %s => %s]</span>\n" % (host, 'Ok')
                else:
                    header = "<span style='color: red'>[ %s => %s]</span>\n" % (host, 'failed')
                self.write_message(header)
                self.write_message(output)

        self.write_message('\n~o~ Task finished ~o~\n')
项目:jumpsever    作者:jacksonyoudi    | 项目源码 | 文件源码
def run_cmd(self, command, pattern):
        self.runner.run('shell', command, pattern=pattern)
        ExecLog(host=self.asset_name_str, cmd=self.command, user=self.user.username,
                remote_ip=self.remote_ip, result=self.runner.results).save()
        newline_pattern = re.compile(r'\n')
        for k, v in self.runner.results.items():
            for host, output in v.items():
                output = newline_pattern.sub('<br />', output)
                if k == 'ok':
                    header = "<span style='color: green'>[ %s => %s]</span>\n" % (host, 'Ok')
                else:
                    header = "<span style='color: red'>[ %s => %s]</span>\n" % (host, 'failed')
                self.write_message(header)
                self.write_message(output)

        self.write_message('\n~o~ Task finished ~o~\n')
项目:redis-pubsub    作者:xitongjiagoushi    | 项目源码 | 文件源码
def __init__(self):
        # register tornado's RequestHandler to designated context path
        handlers = [
            (r'/publish', PublishHandler),
            (r'/subscribe', SubscribeHandler), 
            (r'/', IndexHandler),
            ]
        settings = dict(
            template_path=path.join(path.dirname(__file__), 'templates'),
            static_path=path.join(path.dirname(__file__), 'static'),
        )
        super(Application, self).__init__(handlers, **settings)
        # redis singeleton to share among handlers
        self.redis = redis.StrictRedis(host=options.redis_host, port=options.redis_port, db=options.redis_db, password=options.redis_password)
        # redis pubsub singeleton to share among handler(pubsub is used to subscribe channels)
        self.pubsub = self.redis.pubsub(ignore_subscribe_messages=True)
        self.pubsub.subscribe(options.redis_channel)
        # logger to record log
        self.logger = logger


# base handler
项目:Mohou_Box-master    作者:mohou    | 项目源码 | 文件源码
def __init__(self):
        signal.signal(signal.SIGINT, self.intercept_signal)
        signal.signal(signal.SIGTERM, self.intercept_signal)

        self.logger = logging.getLogger(__name__)
        define("port", default=5000, help="run on the given port", type=int)
        define("host", default="0.0.0.0", help="run on the given host", type=str)
        self.config_file = os.path.join(os.path.dirname(os.path.abspath(__file__)), "boxPrint.conf")
        tornado.options.parse_config_file(self.config_file)

        self.host = options.host
        self.port = options.port
        self.app =  App()
项目:Mohou_Box-master    作者:mohou    | 项目源码 | 文件源码
def run(self):
        http_server = tornado.httpserver.HTTPServer(self.app)
        http_server.listen(self.port, self.host)
        self.logger.info("Mohou 3d print provider start.")
        tornado.ioloop.IOLoop.current().start()
项目:aweasome_learning    作者:Knight-ZXW    | 项目源码 | 文件源码
def send_message():
    stream = yield TCPClient().connect(options.host, options.port)
    yield stream.write((options.message + "\n").encode())
    print("Sent to server:", options.message)
    reply = yield stream.read_until(b"\n")
    print("Response from server:", reply.decode().strip())
项目:exotic-rpi    作者:All-less    | 项目源码 | 文件源码
def main():
    util.setup_trap()
    rpi.init()
    fpga.init()
    network.init(options.host, options.port)
    IOLoop.current().start()
项目:redis-pubsub    作者:xitongjiagoushi    | 项目源码 | 文件源码
def main():
    tornado.options.parse_command_line()
    # create http server
    http_server = tornado.httpserver.HTTPServer(Application())
    # serve the host and port pass by command line(or default 0.0.0.0:8000)
    http_server.listen(options.port, options.host)
    # start http server
    tornado.ioloop.IOLoop.current().start()
项目:browser_vuln_check    作者:lcatro    | 项目源码 | 文件源码
def send_message():
    stream = yield TCPClient().connect(options.host, options.port)
    yield stream.write((options.message + "\n").encode())
    print("Sent to server:", options.message)
    reply = yield stream.read_until(b"\n")
    print("Response from server:", reply.decode().strip())
项目:ProgrameFacil    作者:Gpzim98    | 项目源码 | 文件源码
def send_message():
    stream = yield TCPClient().connect(options.host, options.port)
    yield stream.write((options.message + "\n").encode())
    print("Sent to server:", options.message)
    reply = yield stream.read_until(b"\n")
    print("Response from server:", reply.decode().strip())