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


Python options.debug方法代码示例

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


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

示例1: main

# 需要导入模块: from tornado.options import options [as 别名]
# 或者: from tornado.options.options import debug [as 别名]
def main():
    parse_command_line()
    app = tornado.web.Application(
        [
            (r"/", MainHandler),
            (r"/a/message/new", MessageNewHandler),
            (r"/a/message/updates", MessageUpdatesHandler),
            ],
        cookie_secret="__TODO:_GENERATE_YOUR_OWN_RANDOM_VALUE_HERE__",
        template_path=os.path.join(os.path.dirname(__file__), "templates"),
        static_path=os.path.join(os.path.dirname(__file__), "static"),
        xsrf_cookies=True,
        debug=options.debug,
        )
    app.listen(options.port)
    tornado.ioloop.IOLoop.current().start() 
开发者ID:tao12345666333,项目名称:tornado-zh,代码行数:18,代码来源:chatdemo.py

示例2: run

# 需要导入模块: from tornado.options import options [as 别名]
# 或者: from tornado.options.options import debug [as 别名]
def run(self):
        """
        Function to Run the server. Server runs on host: 127.0.0.1 and port: 2000 by default. Debug is also set to false
        by default

        Can be overriden by using the config.ini file
        """
        define("port", default=self.port, help="Run on given port", type=int)
        define("host", default=self.host, help="Run on given host", type=str)
        define("debug", default=self.debug, help="True for development", type=bool)

        parse_command_line()

        print(Fore.GREEN + "Starting Bast Server....")
        print(Fore.GREEN + "Bast Server Running on %s:%s" % (options.host, options.port))

        application = Application(self.handler, debug=options.debug)
        server = HTTPServer(application)
        server.listen(options.port, options.host)
        IOLoop.current().start() 
开发者ID:moluwole,项目名称:Bast,代码行数:22,代码来源:bast.py

示例3: on_read

# 需要导入模块: from tornado.options import options [as 别名]
# 或者: from tornado.options.options import debug [as 别名]
def on_read(self):
        logging.debug('worker {} on read'.format(self.id))
        try:
            data = self.chan.recv(BUF_SIZE)
        except (OSError, IOError) as e:
            logging.error(e)
            if errno_from_exception(e) in _ERRNO_CONNRESET:
                self.close()
        else:
            logging.debug('"{}" from {}:{}'.format(data, *self.dst_addr))
            if not data:
                self.close()
                return

            logging.debug('"{}" to {}:{}'.format(data, *self.handler.src_addr))
            try:
                self.handler.write_message(data)
            except tornado.websocket.WebSocketClosedError:
                self.close() 
开发者ID:hequan2017,项目名称:chain,代码行数:21,代码来源:main.py

示例4: on_write

# 需要导入模块: from tornado.options import options [as 别名]
# 或者: from tornado.options.options import debug [as 别名]
def on_write(self):
        logging.debug('worker {} on write'.format(self.id))
        if not self.data_to_dst:
            return

        data = ''.join(self.data_to_dst)
        logging.debug('"{}" to {}:{}'.format(data, *self.dst_addr))

        try:
            sent = self.chan.send(data)
        except (OSError, IOError) as e:
            logging.error(e)
            if errno_from_exception(e) in _ERRNO_CONNRESET:
                self.close()
            else:
                self.update_handler(IOLoop.WRITE)
        else:
            self.data_to_dst = []
            data = data[sent:]
            if data:
                self.data_to_dst.append(data)
                self.update_handler(IOLoop.WRITE)
            else:
                self.update_handler(IOLoop.READ) 
开发者ID:hequan2017,项目名称:chain,代码行数:26,代码来源:main.py

示例5: get_app

# 需要导入模块: from tornado.options import options [as 别名]
# 或者: from tornado.options.options import debug [as 别名]
def get_app(self):
        self.body_dict = {
            'hostname': '127.0.0.1',
            'port': str(self.sshserver_port),
            'username': 'robey',
            'password': '',
            '_xsrf': 'yummy'
        }
        loop = self.io_loop
        options.debug = False
        options.policy = random.choice(['warning', 'autoadd'])
        options.hostfile = ''
        options.syshostfile = ''
        options.tdstream = ''
        app = make_app(make_handlers(loop, options), get_app_settings(options))
        return app 
开发者ID:huashengdun,项目名称:webssh,代码行数:18,代码来源:test_app.py

示例6: main

# 需要导入模块: from tornado.options import options [as 别名]
# 或者: from tornado.options.options import debug [as 别名]
def main():
    app = Application()
    app.listen(options.port)
    loop = asyncio.get_event_loop()
    app.init_with_loop(loop)

    enable_pretty_logging()

    if options.debug:
        env = 'development'
    else:
        env = 'production'

    print(f'Starting {env} server at http://localhost:{options.port}/')
    print('Quit the server with CONTROL-C.')

    loop.run_forever() 
开发者ID:olhoneles,项目名称:politicos,代码行数:19,代码来源:server.py

示例7: __init__

# 需要导入模块: from tornado.options import options [as 别名]
# 或者: from tornado.options.options import debug [as 别名]
def __init__(self):
        self._nodes = {}
        if options.debug:
            logger.setLevel(logging.DEBUG)

        handlers = [
            (r'/', DashboardHandler),
        ]
        settings = {'debug': True,
                    "cookie_secret": "MY_COOKIE_ID",
                    "xsrf_cookies": False,
                    'static_path': options.static_path,
                    'template_path': options.static_path
                    }
        super().__init__(handlers, **settings)
        logger.info('Application started, listening on port {0}'
                    .format(options.web_port)) 
开发者ID:pyaiot,项目名称:pyaiot,代码行数:19,代码来源:dashboard.py

示例8: invalidate_email

# 需要导入模块: from tornado.options import options [as 别名]
# 或者: from tornado.options.options import debug [as 别名]
def invalidate_email(self):
        self.email_confirmed = 0
        h = hashlib.sha1()
        h.update("%s" % (time.time()))
        h.update("%s" % (random.random()))
        self.verify_email_token = h.hexdigest()
        self.save()
        if not options.debug:
            pm = postmark.PMMail(api_key=options.postmark_api_key,
                sender="hello@mltshp.com", to=self.email,
                subject="[mltshp] Please verify your email address",
                text_body="Hi there, could you visit this URL to verify your email address for us? Thanks. \n\nhttps://%s/verify-email/%s" % (
                    options.app_host, self.verify_email_token))
            pm.send()
            return True
        return False 
开发者ID:MLTSHP,项目名称:mltshp,代码行数:18,代码来源:user.py

示例9: test_tweet_best_posts

# 需要导入模块: from tornado.options import options [as 别名]
# 或者: from tornado.options.options import debug [as 别名]
def test_tweet_best_posts(self):
        old_likes = options.likes_to_tweet
        old_magic = options.likes_to_magic
        old_debug = options.debug
        try:
            options.likes_to_tweet = 1
            options.likes_to_magic = 1
            options.debug = False
            add_posts(shake_id=self.shake_a.id, sharedfile_id=self.shared_1.id, sourcefile_id=self.source.id)
            self.user_b.add_favorite(self.shared_1)
            # this like should trigger a tweet
            self.assertEqual(MockTweepy.count, 1)
            mf = Magicfile.get("sharedfile_id = %s", self.shared_1.id)
            self.assertIsNotNone(mf)
        finally:
            options.likes_to_tweet = old_likes
            options.likes_to_magic = old_magic
            options.debug = old_debug 
开发者ID:MLTSHP,项目名称:mltshp,代码行数:20,代码来源:task_tests.py

示例10: main

# 需要导入模块: from tornado.options import options [as 别名]
# 或者: from tornado.options.options import debug [as 别名]
def main():
	parse_command_line()
	get_file_stats('../files/upgrade.bin')
	app = tornado.web.Application(
		[
			(r"/", MainHandler),
			(r"/gw.json", JSONHandler),
			(r"/d.json", JSONHandler),
			('/files/(.*)', FilesHandler, {'path': str('../files/')}),
			(r".*", tornado.web.RedirectHandler, {"url": "http://" + options.addr + "/", "permanent": False}),
		],
		#template_path=os.path.join(os.path.dirname(__file__), "templates"),
		#static_path=os.path.join(os.path.dirname(__file__), "static"),
		debug=options.debug,
	)
	try:
		app.listen(options.port, options.addr)
		print("Listening on " + options.addr + ":" + str(options.port))
		tornado.ioloop.IOLoop.current().start()
	except OSError as err:
		print("Could not start server on port " + str(options.port))
		if err.errno == 98: # EADDRINUSE
			print("Close the process on this port and try again")
		else:
			print(err) 
开发者ID:ct-Open-Source,项目名称:tuya-convert,代码行数:27,代码来源:fake-registration-server.py

示例11: __init__

# 需要导入模块: from tornado.options import options [as 别名]
# 或者: from tornado.options.options import debug [as 别名]
def __init__(self, route):
        """
         Bast Server Class. Runs on Tornado HTTP Server (http://www.tornadoweb.org/en/stable/)

        Constructor for the Bast Server. Takes an instance of the route as parameter.
        The Web handler with routes are handled here.

        Config files are also loaded from the config/config.ini folder.
        Appropriate configurations are loaded from the config file into the os environment for use
        :param route:
        """

        super(Bast, self).__init__()
        init()

        load_env()
        self.config()

        self.host = os.getenv("HOST", "127.0.0.1")
        self.port = os.getenv("PORT", 2000)
        self.debug = os.getenv("DEBUG", True)

        self.handler = route.all().url
        self.handler.append((r'/css/(.*)', StaticFileHandler, {"path": self.css_folder}))
        self.handler.append((r'/script/(.*)', StaticFileHandler, {"path": self.script_folder}))
        self.handler.append((r'/images/(.*)', StaticFileHandler, {"path": self.image_folder}))

        # append the URL for static files to exception
        self.handler.append((r'/exp/(.*)', StaticFileHandler,
                             {'path': os.path.join(os.path.dirname(os.path.realpath(__file__)), "exception")})) 
开发者ID:moluwole,项目名称:Bast,代码行数:32,代码来源:bast.py

示例12: default_settings

# 需要导入模块: from tornado.options import options [as 别名]
# 或者: from tornado.options.options import debug [as 别名]
def default_settings(self):
        """
        """
        import gprime.const
        return {
            "cookie_secret": base64.b64encode(uuid.uuid4().bytes + uuid.uuid4().bytes),
            "login_url":     self.make_url("/login"),
            'template_path': os.path.join(gprime.const.DATA_DIR, "templates"),
            'debug':         self.options.debug,
            "xsrf_cookies":  self.options.xsrf,
        } 
开发者ID:GenealogyCollective,项目名称:gprime,代码行数:13,代码来源:app.py

示例13: main

# 需要导入模块: from tornado.options import options [as 别名]
# 或者: from tornado.options.options import debug [as 别名]
def main():
    from tornado.options import options
    import traceback
    try:
        run_app()
    except Exception as exc:
        if options.debug:
            traceback.print_exc()
        else:
            print(exc) 
开发者ID:GenealogyCollective,项目名称:gprime,代码行数:12,代码来源:app.py

示例14: close

# 需要导入模块: from tornado.options import options [as 别名]
# 或者: from tornado.options.options import debug [as 别名]
def close(self):
        logging.debug('Closing worker {}'.format(self.id))
        if self.handler:
            self.loop.remove_handler(self.fd)
            self.handler.close()
        self.chan.close()
        self.ssh.close()
        logging.info('Connection to {}:{} lost'.format(*self.dst_addr)) 
开发者ID:hequan2017,项目名称:chain,代码行数:10,代码来源:main.py

示例15: get_args

# 需要导入模块: from tornado.options import options [as 别名]
# 或者: from tornado.options.options import debug [as 别名]
def get_args(self):
        hostname = self.get_value('hostname')
        port = self.get_port()
        username = self.get_value('username')
        password = self.get_argument('password')
        privatekey = self.get_privatekey()
        pkey = self.get_pkey(privatekey, password) if privatekey else None
        args = (hostname, port, username, decrypt_p(password), pkey)
        logging.debug(args)
        return args 
开发者ID:hequan2017,项目名称:chain,代码行数:12,代码来源:main.py


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