• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python views.load_views函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中views.load_views函数的典型用法代码示例。如果您正苦于以下问题:Python load_views函数的具体用法?Python load_views怎么用?Python load_views使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: page_index

def page_index():
    title = _("Check_MK Mobile")
    mobile_html_head(title)
    jqm_page_header(title, right_button=("javascript:document.location.reload();", _("Reload"), "refresh"),id="data")
    views.load_views()
    items = []
    for view_name, view in html.available_views.items():
        if view.get("mobile") and not view.get("hidden"):
            url = "mobile_view.py?view_name=%s" % view_name
            count = "" 
            if not view.get("mustsearch"):
	        count = views.show_view(view, only_count = True)
                count = '<span class="ui-li-count">%d</span>' % count
            items.append((view.get("topic"), url, '%s %s' % (view.get("linktitle", view["title"]), count)))
    jqm_page_index(_("Check_MK Mobile"), items)
    # Link to non-mobile GUI

    html.write('<hr>')
    html.write('<ul data-role="listview" data-theme="b" data-inset="true">\n')
    html.write('<li><a data-ajax="false" data-transition="fade" href="%s">%s</a></li>\n' %                 ("index.py?mobile=", _("Classical web GUI")))
    html.write('</ul>\n')

    html.write('<ul data-role="listview" data-theme="f" data-inset="true">\n')
    html.write('<li><a data-ajax="false" data-transition="fade" href="%s">%s</a></li>\n' %                 ("logout.py", _("Logout")))
    html.write('</ul>\n')
    mobile_html_foot()
开发者ID:itouch2web,项目名称:check_mk,代码行数:26,代码来源:mobile.py


示例2: choose_view

def choose_view(name):
    import views

    views.load_views()
    vs_view = DropdownChoice(title=_("View Name"), choices=views.view_choices, sorted=True)

    html.header(_("Create Dashlet from existing View"), stylesheets=["pages"])
    html.begin_context_buttons()
    back_url = html.var("back", "dashboard.py?edit=1&name=%s" % html.urlencode(html.var("name")))
    html.context_button(_("Back"), back_url, "back")
    html.end_context_buttons()

    if html.var("save") and html.check_transaction():
        try:
            view_name = vs_view.from_html_vars("view")
            vs_view.validate_value(view_name, "view")

            load_dashboards(lock=True)
            dashboard = available_dashboards[name]

            # Add the dashlet!
            dashlet = default_dashlet_definition("view")

            # save the original context and override the context provided by the view
            dashlet_id = len(dashboard["dashlets"])
            load_view_into_dashlet(dashlet, dashlet_id, view_name)
            add_dashlet(dashlet, dashboard)

            html.http_redirect("edit_dashlet.py?name=%s&id=%d" % (name, dashlet_id))
            return

        except MKUserError, e:
            html.write("<div class=error>%s</div>\n" % e)
            html.add_user_error(e.varname, e)
开发者ID:hamcos,项目名称:check_mk,代码行数:34,代码来源:dashboard.py


示例3: dashlet_view_handle_input

def dashlet_view_handle_input(ident, dashlet):
    dashlet["name"] = "dashlet_%d" % ident
    dashlet.setdefault("title", _("View"))
    import views  # FIXME: HACK, clean this up somehow

    views.load_views()
    return views.create_view_from_valuespec(dashlet, dashlet)
开发者ID:hamcos,项目名称:check_mk,代码行数:7,代码来源:dashlets.py


示例4: page_side

def page_side():
    if not config.user.may("general.see_sidebar"):
        return
    if config.sidebar_notify_interval is not None:
        interval = config.sidebar_notify_interval
    else:
        interval = "null"
    html.html_head(_("Check_MK Sidebar"), javascripts=["sidebar"], stylesheets=["sidebar", "status"])
    html.write('<body class="side')
    if config.screenshotmode:
        html.write(" screenshotmode")
    html.write(
        '" onload="initScrollPos(); set_sidebar_size(); init_messages(%s);" '
        'onunload="storeScrollPos()">\n' % interval
    )
    html.write('<div id="check_mk_sidebar">\n')

    # FIXME: Move this to the code where views are needed (snapins?)
    views.load_views()
    sidebar_head()
    user_config = load_user_config()
    refresh_snapins = []
    restart_snapins = []

    scrolling = ""
    if config.sidebar_show_scrollbar:
        scrolling = " class=scroll"

    html.write('<div id="side_content"%s>' % scrolling)
    for name, state in user_config["snapins"]:
        if not name in sidebar_snapins or not config.user.may("sidesnap." + name):
            continue
        # Performs the initial rendering and might return an optional refresh url,
        # when the snapin contents are refreshed from an external source
        refresh_url = render_snapin(name, state)
        if sidebar_snapins.get(name).get("refresh", False):
            refresh_snapins.append([name, refresh_url])
        elif sidebar_snapins.get(name).get("restart", False):
            refresh_snapins.append([name, refresh_url])
            restart_snapins.append(name)
    html.write("</div>")
    sidebar_foot()
    html.write("</div>")

    html.write('<script language="javascript">\n')
    if restart_snapins:
        html.write("sidebar_restart_time = %s\n" % time.time())
    html.write("sidebar_update_interval = %0.2f;\n" % config.sidebar_update_interval)
    html.write("registerEdgeListeners();\n")
    html.write("set_sidebar_size();\n")
    html.write("refresh_snapins = %s;\n" % json.dumps(refresh_snapins))
    html.write("restart_snapins = %s;\n" % json.dumps(restart_snapins))
    html.write("sidebar_scheduler();\n")
    html.write("window.onresize = function() { set_sidebar_size(); };\n")
    html.write("if (contentFrameAccessible()) { update_content_location(); };\n")
    html.write("</script>\n")

    html.body_end()
开发者ID:ypid-bot,项目名称:check_mk,代码行数:58,代码来源:sidebar.py


示例5: render_hosts

def render_hosts(mode):
    html.live.set_prepend_site(True)
    query = "GET hosts\nColumns: name state worst_service_state\nLimit: 100"
    view = "host"

    if mode == "summary":
        query += "Filter: custom_variable_names >= _REALNAME\n"
    else:
        query += "Filter: custom_variable_names < _REALNAME\n"

    if mode == "problems":
        query += "Filter: state > 0\nFilter: worst_service_state > 0\nOr: 2\n"
        view = "problemsofhost"

    hosts = html.live.query(query)
    html.live.set_prepend_site(False)
    hosts.sort()

    longestname = 0
    for site, host, state, worstsvc in hosts:
        longestname = max(longestname, len(host))
    if longestname > 15:
        num_columns = 1
    else:
        num_columns = 2

    views.load_views()
    target = views.get_context_link(config.user_id, view)
    html.write("<table class=allhosts>\n")
    col = 1
    for site, host, state, worstsvc in hosts:
        if col == 1:
            html.write("<tr>")
        html.write("<td>")

        if state > 0 or worstsvc == 2:
            statecolor = 2
        elif worstsvc == 1:
            statecolor = 1
        elif worstsvc == 3:
            statecolor = 3
        else:
            statecolor = 0
        html.write('<div class="statebullet state%d">&nbsp;</div> ' % statecolor)
        html.write(link(host, target + ("&host=%s&site=%s" % (htmllib.urlencode(host), htmllib.urlencode(site)))))
        html.write("</td>")
        if col == num_columns:
            html.write("</tr>\n")
            col = 1
        else:
            col += 1

    if col < num_columns:
        html.write("</tr>\n")
    html.write("</table>\n")
开发者ID:fmarino,项目名称:check_mk-1,代码行数:55,代码来源:shipped.py


示例6: dashlet_view

def dashlet_view(nr, dashlet):
    import bi # FIXME: Cleanup?
    bi.reset_cache_status() # needed for status icon

    html.set_var('display_options', 'HRSIXL')
    html.set_var('_display_options', 'HRSIXL')
    html.set_var('_body_class', 'dashlet')

    import views # FIXME: HACK, clean this up somehow
    views.load_views()
    views.show_view(dashlet, True, True, True)
开发者ID:iceman1989,项目名称:Check_mk,代码行数:11,代码来源:dashlets.py


示例7: render_wato_foldertree

def render_wato_foldertree():
    is_slave_site = not wato.is_distributed() and os.path.exists(defaults.check_mk_configdir + "/distributed_wato.mk")
    if not is_slave_site:
        if not config.wato_enabled:
            html.write(_("WATO is disabled."))
            return False
        elif not config.may("wato.use"):
            html.write(_("You are not allowed to use Check_MK's web configuration GUI."))
            return False

    user_folders = compute_foldertree()

    #
    # Render link target selection
    #
    selected_topic, selected_target = config.load_user_file("foldertree", (_('Hosts'), 'allhosts'))

    views.load_views()
    dashboard.load_dashboards()
    topic_views  = visuals_by_topic(views.permitted_views().items() + dashboard.permitted_dashboards().items())
    topics = [ (t, t) for t, s in topic_views ]
    html.select("topic", topics, selected_topic, onchange = 'wato_tree_topic_changed(this)')
    html.write('<span class=left>%s</span>' % _('Topic:'))

    for topic, view_list in topic_views:
        targets = []
        for t, title, name, is_view in view_list:
            if config.visible_views and name not in config.visible_views:
                continue
            if config.hidden_views and name in config.hidden_views:
                continue
            if t == topic:
                if not is_view:
                    name = 'dashboard|' + name
                targets.append((name, title))

        attrs = {}
        if topic != selected_topic:
            attrs['style'] = 'display:none'
            default = ''
        else:
            default = selected_target

        html.select("target_%s" % topic, targets, default, attrs = attrs, onchange = 'wato_tree_target_changed(this)')

    html.write('<span class=left>%s</span>' % _('View:'))

    # Now render the whole tree
    if user_folders:
        render_tree_folder(user_folders.values()[0], 'wato_tree_click')
开发者ID:ShMaunder,项目名称:check_mk,代码行数:50,代码来源:wato.py


示例8: load_view_into_dashlet

def load_view_into_dashlet(dashlet, nr, view_name, add_context=None, load_from_all_views=False):
    import views

    views.load_views()

    permitted_views = views.permitted_views()

    # it is random which user is first accessing
    # an apache python process, initializing the dashboard loading and conversion of
    # old dashboards. In case of the conversion we really try hard to make the conversion
    # work in all cases. So we need all views instead of the views of the user.
    if load_from_all_views and view_name not in permitted_views:
        # This is not really 100% correct according to the logic of visuals.available(),
        # but we do this for the rare edge case during legacy dashboard conversion, so
        # this should be sufficient
        view = None
        for (u, n), this_view in views.all_views().items():
            # take the first view with a matching name
            if view_name == n:
                view = this_view
                break

        if not view:
            raise MKGeneralException(
                _(
                    "Failed to convert a builtin dashboard which is referencing "
                    'the view "%s". You will have to migrate it to the new '
                    "dashboard format on your own to work properly." % view_name
                )
            )
    else:
        view = permitted_views[view_name]

    view = copy.deepcopy(view)  # Clone the view
    dashlet.update(view)
    if add_context:
        dashlet["context"].update(add_context)

    # Overwrite the views default title with the context specific title
    dashlet["title"] = visuals.visual_title("view", view)
    dashlet["title_url"] = html.makeuri_contextless(
        [("view_name", view_name)] + visuals.get_singlecontext_vars(view).items(), filename="view.py"
    )

    dashlet["type"] = "view"
    dashlet["name"] = "dashlet_%d" % nr
    dashlet["show_title"] = True
开发者ID:hamcos,项目名称:check_mk,代码行数:47,代码来源:dashboard.py


示例9: dashlet_view

def dashlet_view(nr, dashlet):
    import bi # FIXME: Cleanup?
    bi.reset_cache_status() # needed for status icon

    is_reload = html.has_var("_reload")

    display_options = "SIXL"
    if not is_reload:
        display_options += "HR"

    html.set_var('display_options',  display_options)
    html.set_var('_display_options', display_options)
    html.add_body_css_class('dashlet')

    import views # FIXME: HACK, clean this up somehow
    views.load_views()
    views.show_view(dashlet, True, True, True)
开发者ID:ffeldhaus,项目名称:check_mk,代码行数:17,代码来源:dashlets.py


示例10: load_view_into_dashlet

def load_view_into_dashlet(dashlet, nr, view_name, add_context=None):
    import views
    views.load_views()
    views = views.permitted_views()
    if view_name in views:
        view = copy.deepcopy(views[view_name])
        dashlet.update(view)
        if add_context:
            dashlet['context'].update(add_context)

        # Overwrite the views default title with the context specific title
        dashlet['title'] = visuals.visual_title('view', view)
        dashlet['title_url'] = html.makeuri_contextless(
                [('view_name', view_name)] + visuals.get_singlecontext_vars(view).items(),
                filename='view.py')

    dashlet['type']       = 'view'
    dashlet['name']       = 'dashlet_%d' % nr
    dashlet['show_title'] = True
开发者ID:iceman1989,项目名称:Check_mk,代码行数:19,代码来源:dashboard.py


示例11: page_side

def page_side():
    if not config.may("general.see_sidebar"):
        return
    html.html_head(_("Check_MK Sidebar"), javascripts=["sidebar"], stylesheets=["sidebar", "status"])
    html.write('<body class="side" onload="initScrollPos(); setSidebarHeight();" onunload="storeScrollPos()">\n')
    html.write('<div id="check_mk_sidebar">\n')

    views.load_views()
    sidebar_head()
    user_config = load_user_config()
    refresh_snapins = []
    restart_snapins = []

    html.write('<div id="side_content">')
    for name, state in user_config:
        if not name in sidebar_snapins or not config.may("sidesnap." + name):
            continue
        refresh_url  = render_snapin(name, state)
        refresh_time = sidebar_snapins.get(name).get("refresh", 0)
        if refresh_time > 0:
            refresh_snapins.append([name, refresh_time, refresh_url])

        restart = sidebar_snapins.get(name, {}).get('restart', False)
        if restart:
            restart_snapins.append(name)
    html.write('</div>')
    sidebar_foot()
    html.write('</div>')

    html.write("<script language=\"javascript\">\n")
    if restart_snapins:
        html.write("sidebar_restart_time = %s\n" % time.time())
    html.write("registerEdgeListeners();\n")
    html.write("setSidebarHeight();\n")
    html.write("refresh_snapins = %r;\n" % refresh_snapins)
    html.write("restart_snapins = %r;\n" % restart_snapins)
    html.write("sidebar_scheduler();\n")
    html.write("window.onresize = function() { setSidebarHeight(); }\n")
    # html.write("window.onload = function() { setSidebarHeight(); }\n")
    html.write("</script>\n")

    # html.write("</div>\n")
    html.write("</body>\n</html>")
开发者ID:itouch2web,项目名称:check_mk,代码行数:43,代码来源:sidebar.py


示例12: page_side

def page_side():
    if not config.may("general.see_sidebar"):
        return
    html.html_head(_("Check_MK Sidebar"), javascripts=["sidebar"], stylesheets=["sidebar", "status"])
    html.write('<body class="side" onload="initScrollPos(); setSidebarHeight();" onunload="storeScrollPos()">\n')
    html.write('<div id="check_mk_sidebar">\n')

    views.load_views()
    sidebar_head()
    user_config = load_user_config()
    refresh_snapins = []
    restart_snapins = []

    html.write('<div id="side_content">')
    for name, state in user_config:
        if not name in sidebar_snapins or not config.may("sidesnap." + name):
            continue
        # Performs the initial rendering and might return an optional refresh url,
        # when the snapin contents are refreshed from an external source
        refresh_url = render_snapin(name, state)
        if sidebar_snapins.get(name).get("refresh", False):
            refresh_snapins.append([name, refresh_url])
        elif sidebar_snapins.get(name).get("restart", False):
            refresh_snapins.append([name, refresh_url])
            restart_snapins.append(name)
    html.write('</div>')
    sidebar_foot()
    html.write('</div>')

    html.write("<script language=\"javascript\">\n")
    if restart_snapins:
        html.write("sidebar_restart_time = %s\n" % time.time())
    html.write("sidebar_update_interval = %0.2f;\n" % config.sidebar_update_interval)
    html.write("registerEdgeListeners();\n")
    html.write("setSidebarHeight();\n")
    html.write("refresh_snapins = %r;\n" % refresh_snapins)
    html.write("restart_snapins = %r;\n" % restart_snapins)
    html.write("sidebar_scheduler();\n")
    html.write("window.onresize = function() { setSidebarHeight(); }\n")
    html.write("</script>\n")

    html.write("</body>\n</html>")
开发者ID:FireFoxIXI,项目名称:check_mk,代码行数:42,代码来源:sidebar.py


示例13: page_view

def page_view():
    views.load_views()
    view_name = html.var("view_name")
    if not view_name:
        return page_index()

    view = views.permitted_views().get(view_name)
    if not view:
        raise MKGeneralException("No view defined with the name '%s'." % view_name)

    title = views.view_title(view)
    mobile_html_head(title)

    try:
	views.show_view(view, show_heading = False, show_buttons = False,
			show_footer = False, render_function = render_view)
    except Exception, e:
	if config.debug:
	    raise
	html.write("ERROR showing view: %s" % html.attrencode(e))
开发者ID:NeilBryant,项目名称:check_mk,代码行数:20,代码来源:mobile.py


示例14: render_wato_foldertree

def render_wato_foldertree():
    user_folders = compute_foldertree()

    #
    # Render link target selection
    #
    selected_topic, selected_target = config.load_user_file("foldertree", (_('Hosts'), 'allhosts'))

    views.load_views()
    dashboard.load_dashboards()
    topic_views  = visuals_by_topic(views.permitted_views().items() + dashboard.permitted_dashboards().items())
    topics = [ (t, t) for t, s in topic_views ]
    html.select("topic", topics, selected_topic, onchange = 'wato_tree_topic_changed(this)')
    html.write('<span class=left>%s</span>' % _('Topic:'))

    for topic, view_list in topic_views:
        targets = []
        for t, title, name, is_view in view_list:
            if config.visible_views and name not in config.visible_views:
                continue
            if config.hidden_views and name in config.hidden_views:
                continue
            if t == topic:
                if not is_view:
                    name = 'dashboard|' + name
                targets.append((name, title))

        attrs = {}
        if topic != selected_topic:
            attrs['style'] = 'display:none'
            default = ''
        else:
            default = selected_target

        html.select("target_%s" % topic, targets, default, attrs = attrs, onchange = 'wato_tree_target_changed(this)')

    html.write('<span class=left>%s</span>' % _('View:'))

    # Now render the whole tree
    if user_folders:
        render_tree_folder(user_folders.values()[0], 'wato_tree_click')
开发者ID:iceman1989,项目名称:Check_mk,代码行数:41,代码来源:wato.py


示例15: dashlet_view_render_input

def dashlet_view_render_input(dashlet):
    import views  # FIXME: HACK, clean this up somehow

    views.load_views()
    views.transform_view_to_valuespec_value(dashlet)
    return views.render_view_config(dashlet)
开发者ID:hamcos,项目名称:check_mk,代码行数:6,代码来源:dashlets.py


示例16: dashlet_view_handle_input

def dashlet_view_handle_input(ident, dashlet):
    dashlet['name'] = 'dashlet_%d' % ident
    dashlet.setdefault('title', _('View'))
    import views # FIXME: HACK, clean this up somehow
    views.load_views()
    return views.create_view_from_valuespec(dashlet, dashlet)
开发者ID:ffeldhaus,项目名称:check_mk,代码行数:6,代码来源:dashlets.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python views.HomeView类代码示例发布时间:2022-05-26
下一篇:
Python views.import_ldap_users函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap