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


Python Session.login方法代码示例

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


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

示例1: test_login

# 需要导入模块: from bokeh.session import Session [as 别名]
# 或者: from bokeh.session.Session import login [as 别名]
    def test_login(self):
        #create a server config, register a user
        config1 = tempfile.mkdtemp()
        server = Session(name="foo", root_url="http://localhost:5006/",
                        configdir=config1
                        )
        assert server.userapikey == "nokey"
        server.register("testuser", "fluffy")
        assert server.userapikey and server.userapikey != "nokey"

        #create a separate server config, login a user
        config2 = tempfile.mkdtemp()
        server2 = Session(name="foo", root_url="http://localhost:5006/",
                         configdir=config2
                         )
        assert server2.userapikey == "nokey"
        server2.login("testuser", "fluffy")
        #make sure the userapikeys match
        assert server2.userapikey == server.userapikey
开发者ID:Afey,项目名称:bokeh,代码行数:21,代码来源:multiuser_auth_test.py

示例2: login

# 需要导入模块: from bokeh.session import Session [as 别名]
# 或者: from bokeh.session.Session import login [as 别名]
def login(password, username='nirum'):
    session = Session()
    session.login(username, password)
开发者ID:nirum,项目名称:bokeh-hud-server,代码行数:5,代码来源:hud.py

示例3: prepare_widgets

# 需要导入模块: from bokeh.session import Session [as 别名]
# 或者: from bokeh.session.Session import login [as 别名]
def prepare_widgets():
    print "initializing..."
    # start bokeh-server session
    global client
    client = Session(root_url='http://0.0.0.0:7010/', load_from_config=False)
    try:
        client.register(bs_login,bs_password)
    except:pass

    client.login(bs_login,bs_password)

    ###CREATE WIDGETS
    print "preaparing widgets..."
    #hist1: hist with overlay
    import analysis.distfit as distfit
    import pandas as pd
    xname,xmin,xmax,xbins = "invariantMass",0,10,50


    bin_separators = np.histogram([],bins=xbins, range=[xmin,xmax])[1]
    bin_centers = np.array([0.5*(bin_separators[i]+bin_separators[i+1]) for i in range(len(bin_separators)-1)])
    bins = pd.DataFrame({"x":bin_centers})

    expo_gap = lambda x,slope: (x>=xmin)*(x<=xmax)*distfit.exponential(x-xmin,slope)/(1.-np.e**(-(xmax-xmin)*slope))
    mix_model = distfit.DistributionsMixture(
        distributions={'sig': distfit.gauss, 'bck': expo_gap},
        weights_ranges={'sig': [1.,10.], 'bck': [1.,10.]},
        parameter_ranges={'mean': [xmin ,xmax], 'sigma': [0., xmax-xmin], 'slope': [0, 15.]},
        column_ranges={'x': [xmin, xmax]},
        sampling_strategy='grid',
    )


    mix_model.compile(bins,1000) #takes several seconds



    hist1_base = WhiskeredHistWidget(xname,xmin,xmax,xbins,es,
                       fig = figure(plot_width=600, plot_height=600,tools=['wheel_zoom','ywheel_zoom','pan','resize','reset']))
    hist1 = MLFitOverlayWidget(hist1_base,mix_model,n_pts=100)
    widgets.append(hist1)

    #hist2: just hist
    hist2 = ClassicHistWidget("muonHits",0,100,30,es,
                       fig = figure(plot_width=600, plot_height=600,tools=['wheel_zoom','ywheel_zoom','pan','reset']))
    widgets.append(hist2)


    #hist3: heatmap
    hist3 = HeatmapWidget("avgMass",0,35,50,
                          "muonHits",0,70,50,
                          es,fig = figure(plot_width=600, plot_height=600),)
    widgets.append(hist3)

    #hist4: hist with reference
    hist4_base = ClassicHistWidget("dskkpi",1920,2020,30,es,
                       fig = figure(plot_width=600, plot_height=600,tools=['wheel_zoom','ywheel_zoom','pan','reset']))
    
    from scipy.stats import laplace
    pdf = laplace(1970,7).pdf
    hist4 = ReferenceOverlay(hist4_base,pdf)
    widgets.append(hist4)    
    
    ###end CREATE PLOTS

    print "publishing plots..."
    #create a dashboard on bokeh_server
    output_server(dashboard_name,client)

    plots = [ hplot(widget.fig) for widget in widgets ]

    global whole_dashboard
    whole_dashboard = vplot(hplot(*plots[:2]),hplot(*plots[2:]))
    plots.append(whole_dashboard)    

    for plot in plots:
        client.show(plot)


    client.publish()
 
    print "creating static links..."
    #publish the thing
    from bokeh.embed import autoload_server
    scripts = [autoload_server(plot,client,public=True) for plot in plots]


    
    print "saving widget scripts..."
    
    #remove previous widgets
    for path_to_static in path_to_django_static,path_to_flask_static:
        path_to_widgets = os.path.join(path_to_static,dashboard_name)

        os.system("rm -rf " + path_to_widgets)
        os.mkdir(path_to_widgets)

        for i, source_script in enumerate(scripts):
            
            #convert script...
#.........这里部分代码省略.........
开发者ID:justheuristic,项目名称:throw_events_upon_storage,代码行数:103,代码来源:demo1_dashboard.py


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