How to use the tornado.options.define function in tornado

To help you get started, we’ve selected a few tornado examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jupyterhub / jupyterhub / multiuser / multiuser.py View on Github external
def main():
    define("port", default=8000, help="The public facing port of the proxy", type=int)
    define("proxy_api_port", help="The port for the proxy API handlers", type=int)
    define("multiuser_port", default=8081, help="The port for this process", type=int)
    tornado.options.parse_command_line()
    options.proxy_api_port = options.proxy_api_port or options.port + 1
    handlers = [
        (r"/", MainHandler),
        (r"/login", LoginHandler),
        (r"/logout", LogoutHandler),
        (r"/headers", HeadersHandler),
        (r"/api/authorizations/([^/]+)", AuthorizationsHandler),
    ]
    
    # add base_url to handlers
    base_url = "/multiuser/"
    for i, tup in enumerate(handlers):
        lis = list(tup)
        lis[0] = utils.url_path_join(base_url, tup[0])
        handlers[i] = tuple(lis)
github mikedewar / d3py / server.py View on Github external
def main():
    define("port", default=7666, help="port num for d3pyplot server", type=int)
    tornado.options.parse_command_line()
    http_server = tornado.httpserver.HTTPServer(application)
    http_server.listen(int(options.port))
    tornado.ioloop.IOLoop.instance().start()
github SEL-Columbia / dokomoforms / dokomoforms / options.py View on Github external
_arg = None

# Application options
define('demo', default=False, help='whether to run in demo mode', type=bool)
define('port', help='run on the given port', type=int)

log_help = 'whether to write logs to files in logs/'
define('log_to_file', default=True, help=log_help, type=bool)

define('debug', default=False, help='whether to enable debug mode', type=bool)

https_help = 'whether the application accepts https traffic'
define('https', default=True, help=https_help, type=bool)

define('organization', help='the name of your organization')
define('admin_email', help='the e-mail address of the main administrator')
define('admin_name', help='the user name of the main administrator')

persona_help = (
    'the URL for login verification. Do not change this without a good reason.'
)
persona_url = 'https://verifier.login.persona.org/verify'
define('persona_verification_url', default=persona_url, help=persona_help)

revisit_url = 'https://revisit.global/api/v0/facilities.json'
revisit_help = (
    'the URL for facility data. Do not change this without a good reason.'
)
define('revisit_url', default=revisit_url, help=revisit_help)

# Database options
define('schema', help='database schema name')
github charlesthomas / magpie / utils / email_notes.py View on Github external
from os.path import exists, join
import re
from sys import exit

import sh
from tornado.options import define, options, parse_config_file

from magpie.config import config_path

class EmailNotesError(Exception):
    pass

define('imap_server', default=None, type=str)
define('username', default=None, type=str)
define('password', default=None, type=str)
define('folder', default=None, type=str)
define('repo', default=None, type=str)
define('use_ssl', default=True, type=bool)
define('default_notebook', default='', type=str)
parse_config_file(config_path.email_notes)

if options.use_ssl:
    imap = IMAP4_SSL(options.imap_server)
else:
    imap = IMAP4(options.imap_server)
imap.login(options.username, options.password)

result, data = imap.select(options.folder)
if result != 'OK':
    raise EmailNotesError(result)
result, messages = imap.search(None, '(UNSEEN)')
if result != 'OK':
github jupyter / nbviewer / nbviewer / app.py View on Github external
define("port", default=default_port, help="run on the given port", type=int)
    define("cache_expiry_min", default=10*60, help="minimum cache expiry (seconds)", type=int)
    define("cache_expiry_max", default=2*60*60, help="maximum cache expiry (seconds)", type=int)
    define("render_timeout", default=15, help="Time to wait for a render to complete before showing the 'Working...' page.", type=int)
    define("rate_limit", default=60, help="Number of requests to allow in rate_limt_interval before limiting. Only requests that trigger a new render are counted.", type=int)
    define("rate_limit_interval", default=600, help="Interval (in seconds) for rate limiting.", type=int)
    define("mc_threads", default=1, help="number of threads to use for Async Memcache", type=int)
    define("threads", default=1, help="number of threads to use for rendering", type=int)
    define("processes", default=0, help="use processes instead of threads for rendering", type=int)
    define("frontpage", default=FRONTPAGE_JSON, help="path to json file containing frontpage content", type=str)
    define("sslcert", help="path to ssl .crt file", type=str)
    define("sslkey", help="path to ssl .key file", type=str)
    define("no_check_certificate", default=False, help="Do not validate SSL certificates", type=bool)
    define("default_format", default="html", help="format to use for legacy / URLs", type=str)
    define("proxy_host", default="", help="The proxy URL.", type=str)
    define("proxy_port", default="", help="The proxy port.", type=int)
    define("providers", default=default_providers, help="Full dotted package(s) that provide `default_handlers`", type=str, multiple=True, group="provider")
    define("provider_rewrites", default=default_rewrites, help="Full dotted package(s) that provide `uri_rewrites`", type=str, multiple=True, group="provider")
    define("mathjax_url", default="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/", help="URL base for mathjax package", type=str)
    define("template_path", default=os.environ.get("NBVIEWER_TEMPLATE_PATH", None), help="Custom template path for the nbviewer app (not rendered notebooks)", type=str)
    define("statsd_host", default="", help="Host running statsd to send metrics to", type=str)
    define("statsd_port", default=8125, help="Port on which statsd is listening for metrics on statsd_host", type=int)
    define("statsd_prefix", default='nbviewer', help="Prefix to use for naming metrics sent to statsd", type=str)
    define("base_url", default='/', help='URL base for the server')
    define("ipywidgets_base_url", default="https://unpkg.com/", help="URL base for ipywidgets JS package", type=str)
    define("jupyter_js_widgets_version", default="*", help="Version specifier for jupyter-js-widgets JS package", type=str)
    define("jupyter_widgets_html_manager_version", default="*", help="Version specifier for @jupyter-widgets/html-manager JS package", type=str)
    define("content_security_policy", default="connect-src 'none';", help="Content-Security-Policy header setting", type=str)
    define("binder_base_url", default="https://mybinder.org/v2", help="URL base for binder notebook execution service", type=str)
github apache / incubator-milagro-mfa-server / servers / demo / mpinDemo.py View on Github external
CONFIG_FILE = os.path.join(BASE_DIR, "config.py")


# OPTIONS

# general options
define("configFile", default=os.path.join(BASE_DIR, "config.py"), type=unicode)
define("address", default="127.0.0.1", type=unicode)
define("port", default=8005, type=int)
define("cookieSecret", type=unicode)
define("resourcesBasePath", default=BASE_DIR, type=unicode)
define("mpinJSURL", default="", type=unicode)

# debugging options
define("autoReload", default=False, type=bool)
define("logLevel", default="ERROR", type=unicode)
define("forceActivate", default=False, type=bool)

# RPS service discovery options
define("RPSURL", default="", type=unicode)
define("rpsPrefix", default="rps", type=unicode)
define("clientSettingsURL", default="", type=unicode)
define("verifyIdentityURL", default="", type=unicode)

# authentication options
define("requestOTP", default=False, type=bool)

# email options
define("emailSubject", type=unicode)
define("emailSender", type=unicode)
define("smtpServer", type=unicode)
define("smtpPort", default=25, type=int)
github ayeowch / bitnodes-hardware / poll.py View on Github external
import json
import logging
import threading
import time
import tornado.httpserver
import tornado.ioloop
import tornado.options
import tornado.web
import tornado.websocket
from collections import deque
from psutil import net_io_counters
from tornado.options import define, options

from django.conf import settings

define('address', type=str, default=settings.WEBSOCKET_HOST)
define('port', type=int, default=settings.WEBSOCKET_PORT)


class Application(tornado.web.Application):
    def __init__(self):
        handlers = [
            (r'/poll', PollHandler),
        ]
        tornado.web.Application.__init__(self, handlers)


class PollHandler(tornado.websocket.WebSocketHandler):
    clients = []
    ticks = deque([], maxlen=180)

    def open(self):
github jupyter / tmpnb / orchestrate.py View on Github external
)
    tornado.options.define('cull_max', default=14400,
        help=dedent("""
        Maximum age of a container (s), regardless of activity.

        Default: 14400 (4 hours)

        A container that has been running for this long will be culled,
        even if it is not idle.
        """)
    )
    tornado.options.define('container_ip', default='127.0.0.1',
        help="""Host IP address for containers to bind to. If host_network=True,
the host IP address for notebook servers to bind to."""
    )
    tornado.options.define('container_port', default='8888',
        help="""Within container port for notebook servers to bind to.
If host_network=True, the starting port assigned to notebook servers on the host."""
    )
    tornado.options.define('use_tokens', default=False,
        help="""Enable token-authentication of notebook servers.
If host_network=True, the starting port assigned to notebook servers on the host."""
    )

    command_default = (
        'jupyter notebook --no-browser'
        ' --port {port} --ip=0.0.0.0'
        ' --NotebookApp.base_url={base_path}'
        ' --NotebookApp.port_retries=0'
        ' --NotebookApp.token="{token}"'
    )
github moloch-- / RootTheBox / rootthebox.py View on Github external
default="rtb",
    group="database",
    help="database password, if applicable",
)

define("log_sql", default=False, group="database", help="Log SQL queries for debugging")

# Memcached settings
define(
    "memcached",
    default="127.0.0.1:11211",
    group="cache",
    help="memcached servers comma separated - hostname:port",
)

define(
    "memcached_user", default="", group="cache", help="memcached SASL server username"
)

define(
    "memcached_password",
    default="",
    group="cache",
    help="memcached SASL server password",
)


# Game Settings
try:
    # python2
    game_type = basestring
except NameError:
github jupyter / nbviewer / nbviewer / app.py View on Github external
define("frontpage", default=FRONTPAGE_JSON, help="path to json file containing frontpage content", type=str)
    define("sslcert", help="path to ssl .crt file", type=str)
    define("sslkey", help="path to ssl .key file", type=str)
    define("no_check_certificate", default=False, help="Do not validate SSL certificates", type=bool)
    define("default_format", default="html", help="format to use for legacy / URLs", type=str)
    define("proxy_host", default="", help="The proxy URL.", type=str)
    define("proxy_port", default="", help="The proxy port.", type=int)
    define("providers", default=default_providers, help="Full dotted package(s) that provide `default_handlers`", type=str, multiple=True, group="provider")
    define("provider_rewrites", default=default_rewrites, help="Full dotted package(s) that provide `uri_rewrites`", type=str, multiple=True, group="provider")
    define("mathjax_url", default="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/", help="URL base for mathjax package", type=str)
    define("template_path", default=os.environ.get("NBVIEWER_TEMPLATE_PATH", None), help="Custom template path for the nbviewer app (not rendered notebooks)", type=str)
    define("statsd_host", default="", help="Host running statsd to send metrics to", type=str)
    define("statsd_port", default=8125, help="Port on which statsd is listening for metrics on statsd_host", type=int)
    define("statsd_prefix", default='nbviewer', help="Prefix to use for naming metrics sent to statsd", type=str)
    define("base_url", default='/', help='URL base for the server')
    define("ipywidgets_base_url", default="https://unpkg.com/", help="URL base for ipywidgets JS package", type=str)
    define("jupyter_js_widgets_version", default="*", help="Version specifier for jupyter-js-widgets JS package", type=str)
    define("jupyter_widgets_html_manager_version", default="*", help="Version specifier for @jupyter-widgets/html-manager JS package", type=str)
    define("content_security_policy", default="connect-src 'none';", help="Content-Security-Policy header setting", type=str)
    define("binder_base_url", default="https://mybinder.org/v2", help="URL base for binder notebook execution service", type=str)