示例#1
0
文件: info.py 项目: bgyarfas/bokeh
    def invoke(self, args):
        if args.static:
            print(settings.bokehjsdir())
        else:
            if_installed = lambda version_or_none: version_or_none or "(not installed)"

            print("Python version      :  %s" % sys.version.split('\n')[0])
            print("IPython version     :  %s" % if_installed(ipython_version()))
            print("Bokeh version       :  %s" % __version__)
            print("BokehJS static path :  %s" % settings.bokehjsdir())
            print("node.js version     :  %s" % if_installed(nodejs_version()))
            print("npm version         :  %s" % if_installed(npmjs_version()))
示例#2
0
 def invoke(self, args):
     if args.static:
         print(settings.bokehjsdir())
     else:
         try:
             import IPython
             ipy_version = IPython.__version__
         except ImportError:
             ipy_version = "Not installed"
         print("Python version      :  %s" % sys.version.split('\n')[0])
         print("IPython version     :  %s" % ipy_version)
         print("Bokeh version       :  %s" % __version__)
         print("BokehJS static path :  %s" % settings.bokehjsdir())
示例#3
0
    def invoke(self, args):
        if args.static:
            print(settings.bokehjsdir())
        else:
            if_installed = lambda version_or_none: version_or_none or "(not installed)"

            print("Python version      :  %s" % sys.version.split('\n')[0])
            print("IPython version     :  %s" %
                  if_installed(ipython_version()))
            print("Bokeh version       :  %s" % __version__)
            print("BokehJS static path :  %s" % settings.bokehjsdir())
            print("node.js version     :  %s" % if_installed(nodejs_version()))
            print("npm version         :  %s" % if_installed(npmjs_version()))
    def invoke(self, args: Namespace) -> None:
        '''

        '''
        if args.static:
            print(settings.bokehjsdir())
        else:

            print("Python version      :  %s" % sys.version.split('\n')[0])
            print("IPython version     :  %s" % if_installed(_version('IPython', '__version__')))
            print("Tornado version     :  %s" % if_installed(_version('tornado', 'version')))
            print("Bokeh version       :  %s" % __version__)
            print("BokehJS static path :  %s" % settings.bokehjsdir())
            print("node.js version     :  %s" % if_installed(nodejs_version()))
            print("npm version         :  %s" % if_installed(npmjs_version()))
示例#5
0
 def append_version(cls, path):
     # this version is cached on the StaticFileHandler class,
     # keyed by absolute filesystem path, and only invalidated
     # on an explicit StaticFileHandler.reset(). The reset is
     # automatic on every request if you set
     # static_hash_cache=False in TornadoApplication kwargs.
     version = StaticFileHandler.get_version(dict(static_path=settings.bokehjsdir()), path)
     return ("%s?v=%s" % (path, version))
示例#6
0
 def setup(self, backend, backbone_storage, servermodel_storage,
           authentication):
     self.backend = backend
     self.backbone_storage = backbone_storage
     self.servermodel_storage = servermodel_storage
     self.authentication = authentication
     self.bokehjsdir = settings.bokehjsdir()
     self.bokehjssrcdir = settings.bokehjssrcdir()
示例#7
0
文件: app.py 项目: CatherineH/bokeh
 def setup(self, backend, backbone_storage, servermodel_storage,
           authentication):
     self.backend = backend
     self.backbone_storage = backbone_storage
     self.servermodel_storage = servermodel_storage
     self.authentication = authentication
     self.bokehjsdir = settings.bokehjsdir()
     self.bokehjssrcdir = settings.bokehjssrcdir()
示例#8
0
 def invoke(self, args):
     bokehjs_dir = settings.bokehjsdir()
     print(bokehjs_dir)
     compiler_script = join(bokehjs_dir, "js", "compiler.js")
     output = _run_nodejs([
         compiler_script, "build", "--base-dir", args.base_dir,
         "--bokehjs-dir", bokehjs_dir
     ])
     print(output)
示例#9
0
 def append_version(cls, path):
     # This version is cached on the StaticFileHandler class,
     # keyed by absolute filesystem path, and only invalidated
     # on an explicit StaticFileHandler.reset(). The reset is
     # automatic on every request if you set static_hash_cache=False
     # in TornadoApplication kwargs. In dev mode rely on dev tools
     # to manage caching. This improves the ability to debug code.
     if settings.dev:
         return path
     else:
         version = StaticFileHandler.get_version(dict(static_path=settings.bokehjsdir()), path)
         return ("%s?v=%s" % (path, version))
示例#10
0
 def append_version(cls, path):
     # This version is cached on the StaticFileHandler class,
     # keyed by absolute filesystem path, and only invalidated
     # on an explicit StaticFileHandler.reset(). The reset is
     # automatic on every request if you set static_hash_cache=False
     # in TornadoApplication kwargs. In dev mode rely on dev tools
     # to manage caching. This improves the ability to debug code.
     if settings.dev:
         return path
     else:
         version = StaticFileHandler.get_version(dict(static_path=settings.bokehjsdir()), path)
         return ("%s?v=%s" % (path, version))
示例#11
0
文件: app.py 项目: xuexianwu/bokeh
    def setup(self, backend, backbone_storage, servermodel_storage,
              authentication, datamanager):
        self.datamanager = datamanager
        self.backend = backend
        self.backbone_storage = backbone_storage
        self.servermodel_storage = servermodel_storage
        self.authentication = authentication

        def auth(auth, docid):
            doc = docs.Doc.load(self.servermodel_storage, docid)
            status = mconv.can_write_doc_api(doc, auth, self)
            return status
        self.bokehjsdir = settings.bokehjsdir()
        self.bokehjssrcdir = settings.bokehjssrcdir()
示例#12
0
    def invoke(self, args: Namespace) -> None:
        '''

        '''
        if args.static:
            print(settings.bokehjsdir())
        else:
            newline = '\n'
            print(f"Python version      :  {sys.version.split(newline)[0]}")
            print(
                f"IPython version     :  {if_installed(_version('IPython', '__version__'))}"
            )
            print(
                f"Tornado version     :  {if_installed(_version('tornado', 'version'))}"
            )
            print(f"Bokeh version       :  {__version__}")
            print(f"BokehJS static path :  {settings.bokehjsdir()}")
            print(f"node.js version     :  {if_installed(nodejs_version())}")
            print(f"npm version         :  {if_installed(npmjs_version())}")
示例#13
0
    def __init__(self, tornado_app, *args, **kw):
        kw['path'] = settings.bokehjsdir()

        # Note: tornado_app is stored as self.application
        super(StaticHandler, self).__init__(tornado_app, *args, **kw)
示例#14
0
def includeme(config):
    # app routes
    documentcontext = config.registry.documentcontext
    config.add_route(
        'bokeh.gc',
        '/bokeh/bb/{docid}/gc',
        factory=documentcontext
        )
    config.add_route(
        'bokeh.bulk_upsert',
        '/bokeh/bb/{docid}/bulkupsert',
        factory=documentcontext,
        )
    config.add_route(
        'bokeh.create',
        '/bokeh/bb/{docid}/{typename}/',
        )
    config.add_route(
        'bokeh.bulkget_wo_typename',
        '/bokeh/bb/{docid}/',
        factory=documentcontext,
        )
    config.add_route(
        'bokeh.bulkget_w_typename',
        '/bokeh/bb/{docid}/{typename}/',
        factory=documentcontext,
        )
    config.add_route(
        'bokeh.handle_model',
        '/bokeh/bb/{docid}/{typename}/{id}/',
        factory=documentcontext,
        )
    config.add_route(
        'bokeh.login', '/bokeh/login')
    config.add_route(
        'bokeh.loginfromapikey', '/bokeh/loginfromapikey')
    config.add_route(
        'bokeh.register', '/bokeh/register')
    config.add_route(
        'bokeh.logout', '/bokeh/logout')
    config.add_route(
        'bokeh.publish',
        '/bokeh/{docid}/publish',
        factory=documentcontext,
        )
    config.add_route(
        'bokeh.root', '/')
    config.add_route(
        'bokeh.index', '/bokeh/')
    config.add_route(
        'bokeh.favicon', '/bokeh/favicon.ico')
    config.add_route(
        'bokeh.docs', '/bokeh/doc/')
    config.add_route(
        'bokeh.doc',
        '/bokeh/doc/{docid}/',
        factory=documentcontext,
        )
    config.add_route(
        'bokeh.getdocapikey',
        '/bokeh/getdocapikey/{docid}',
        factory=documentcontext,
        )
    config.add_route(
        'bokeh.userinfo', '/bokeh/userinfo/')
    config.add_route(
        'bokeh.info',
        '/bokeh/bokehinfo/{docid}/',
        factory=documentcontext,
        )
    config.add_route(
        'bokeh.showdoc', '/bokeh/doc/{title}/show')
    config.add_route(
        'bokeh.sampleerror', '/bokeh/sampleerror')
    config.add_route(
        'bokeh.autoloadjs', '/bokeh/autoload.js/{elementid}'
        )
    config.add_route(
        'bokeh.objinfo',
        '/bokeh/objinfo/{docid}/{objid}',
        factory=documentcontext,
        )
    config.add_route(
        'bokeh.showobj',
        '/bokeh/doc/{docid}/{objid}',
        factory=documentcontext,
        )
    config.add_route(
        'bokeh.wsurl', '/bokeh/wsurl/')
    config.add_route(
        'bokeh.ping', '/bokeh/ping')

    config.add_route(
        'bokeh.generatejs',
        '/bokeh/jsgenerate/{parentname}/{modulename}/{classname}')

    jsdir = bokeh_settings.bokehjsdir()
    jssrcdir = bokeh_settings.bokehjssrcdir()

    # static views
    config.add_static_view('bokehjs/static', jsdir, cache_max_age=3600)
    if jssrcdir is not None:
        config.add_static_view('bokehjs/src', jssrcdir, cache_max_age=3600)

    config.add_static_view(
        'static', 'pyramid_bokehserver:static', cache_max_age=3600)

    # notfound view (append_slash needed for /doc vs. doc/ etc)
    config.add_notfound_view(notfound, append_slash=True)

    # scan
    config.scan('.')
示例#15
0
    def __init__(self, tornado_app, *args, **kw) -> None:
        kw['path'] = settings.bokehjsdir()

        # Note: tornado_app is stored as self.application
        super().__init__(tornado_app, *args, **kw)
示例#16
0
def getapp(settings): # settings should be a bokehserver.settings.Settings
    """ This function returns a Pyramid WSGI application representing the Bokeh
    server.
    """
    config = Configurator(settings={})
    config.registry.bokehserver_settings = settings

    backend = settings.model_backend
    if backend['type'] == 'redis':
        import redis
        rhost = backend.get('redis_host', '127.0.0.1')
        rport = backend.get('redis_port', REDIS_PORT)
        bbstorage = RedisBackboneStorage(
            redis.Redis(host=rhost, port=rport, db=2)
            )
        servermodel_storage = RedisServerModelStorage(
            redis.Redis(host=rhost, port=rport, db=3)
            )
    elif backend['type'] == 'memory':
        bbstorage = InMemoryBackboneStorage()
        servermodel_storage = InMemoryServerModelStorage()

    elif backend['type'] == 'shelve':
        bbstorage = ShelveBackboneStorage()
        servermodel_storage = ShelveServerModelStorage()

    if settings.multi_user:
        default_username = None
    else:
        default_username = '******'

    authentication = BokehAuthenticationPolicy(
        default_username=default_username,
        )

    authorization = BokehAuthorizationPolicy()
    url_prefix = settings.url_prefix
    publisher = Publisher(settings.ctx, settings.pub_zmqaddr, Queue())

    for script in settings.scripts:
        script_dir = os.path.dirname(script)
        if script_dir not in sys.path:
            print ("adding %s to python path" % script_dir)
            sys.path.append(script_dir)
        print ("importing and scanning %s" % script)
        mod = imp.load_source("_bokeh_app", script)
        if hasattr(mod, 'includeme'):
            config.include(mod)
        else:
            config.scan(mod)

    config.registry.url_prefix = url_prefix
    config.registry.publisher = publisher
    config.registry.wsmanager = websocket.WebSocketManager()
    config.registry.backend = backend
    config.registry.servermodel_storage = servermodel_storage
    config.registry.backbone_storage = bbstorage
    config.registry.authentication = authentication
    config.registry.authorization = authorization
    config.registry.bokehjsdir = bokeh_settings.bokehjsdir()
    config.registry.bokehjssrcdir = bokeh_settings.bokehjssrcdir()
    config.registry.documentcontext = DocumentContext
    config.registry.default_username = default_username

    # add a ``request.current_user()`` API
    config.add_request_method(current_user)
    # add a ``request.current_document()`` API
    config.add_request_method(current_document)

    # configure a session factory for request.session access and
    # SessionAuthenticationPolicy usage
    session_factory = SignedCookieSessionFactory(settings.secret_key)
    config.set_session_factory(session_factory)

    # do jinja2 setup; files ending in .html and .js will be considered
    # jinja2 templates
    config.include('pyramid_jinja2')
    config.add_jinja2_renderer('.html')
    config.add_jinja2_renderer('.js')

    # register routes and default views
    config.include('.views')

    # set up default declarative security context
    config.set_root_factory(RootContext)

    # set up view-time security policies
    config.set_authentication_policy(authentication)
    config.set_authorization_policy(authorization)

    # return a WSGI application
    return config.make_wsgi_app()