當前位置: 首頁>>代碼示例>>Python>>正文


Python LdapCherry.reload方法代碼示例

本文整理匯總了Python中ldapcherry.LdapCherry.reload方法的典型用法代碼示例。如果您正苦於以下問題:Python LdapCherry.reload方法的具體用法?Python LdapCherry.reload怎麽用?Python LdapCherry.reload使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在ldapcherry.LdapCherry的用法示例。


在下文中一共展示了LdapCherry.reload方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: testMissingParameters

# 需要導入模塊: from ldapcherry import LdapCherry [as 別名]
# 或者: from ldapcherry.LdapCherry import reload [as 別名]
 def testMissingParameters(self):
     app = LdapCherry()
     try:
         app.reload({})
     except SystemExit:
         return
     else:
         raise AssertionError("expected an exception")
開發者ID:kakwa,項目名稱:ldapcherry,代碼行數:10,代碼來源:test_LdapCherry.py

示例2: start

# 需要導入模塊: from ldapcherry import LdapCherry [as 別名]
# 或者: from ldapcherry.LdapCherry import reload [as 別名]
def start(configfile=None, daemonize=False, environment=None,
          fastcgi=False, scgi=False, pidfile=None,
          cgi=False, debug=False):
    """Subscribe all engine plugins and start the engine."""
    sys.path = [''] + sys.path

    # monkey patching cherrypy to disable config interpolation
    def new_as_dict(self, raw=True, vars=None):
        """Convert an INI file to a dictionary"""
        # Load INI file into a dict
        result = {}
        for section in self.sections():
            if section not in result:
                result[section] = {}
            for option in self.options(section):
                value = self.get(section, option, raw=raw, vars=vars)
                try:
                    value = cherrypy.lib.reprconf.unrepr(value)
                except Exception:
                    x = sys.exc_info()[1]
                    msg = ("Config error in section: %r, option: %r, "
                           "value: %r. Config values must be valid Python." %
                           (section, option, value))
                    raise ValueError(msg, x.__class__.__name__, x.args)
                result[section][option] = value
        return result
    cherrypy.lib.reprconf.Parser.as_dict = new_as_dict

    instance = LdapCherry()
    app = cherrypy.tree.mount(instance, '/', configfile)
    cherrypy.config.update(configfile)
    instance.reload(app.config, debug)

    engine = cherrypy.engine

    # Turn off autoreload
    cherrypy.config.update({'engine.autoreload.on': False})

    if environment is not None:
        cherrypy.config.update({'environment': environment})

    # Only daemonize if asked to.
    if daemonize:
        # Don't print anything to stdout/sterr.
        cherrypy.config.update({'log.screen': False})
        plugins.Daemonizer(engine).subscribe()

    if pidfile:
        plugins.PIDFile(engine, pidfile).subscribe()

    if hasattr(engine, "signal_handler"):
        engine.signal_handler.subscribe()
    if hasattr(engine, "console_control_handler"):
        engine.console_control_handler.subscribe()

    if (fastcgi and (scgi or cgi)) or (scgi and cgi):
        cherrypy.log.error("You may only specify one of the cgi, fastcgi, and "
                           "scgi options.", 'ENGINE')
        sys.exit(1)
    elif fastcgi or scgi or cgi:
        # Turn off the default HTTP server (which is subscribed by default).
        cherrypy.server.unsubscribe()

        addr = cherrypy.server.bind_addr
        if fastcgi:
            f = servers.FlupFCGIServer(application=cherrypy.tree,
                                       bindAddress=addr)
        elif scgi:
            f = servers.FlupSCGIServer(application=cherrypy.tree,
                                       bindAddress=addr)
        else:
            f = servers.FlupCGIServer(application=cherrypy.tree,
                                      bindAddress=addr)
        s = servers.ServerAdapter(engine, httpserver=f, bind_addr=addr)
        s.subscribe()

    # Always start the engine; this will start all other services
    try:
        engine.start()
    except Exception as e:
        # Assume the error has been logged already via bus.log.
        sys.exit(1)
    else:
        engine.block()
開發者ID:kakwa,項目名稱:ldapcherry,代碼行數:86,代碼來源:cli.py


注:本文中的ldapcherry.LdapCherry.reload方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。