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


Python config.load函数代码示例

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


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

示例1: test_logging

    def test_logging(self):
        """
        Logging module configures properly.
        """
        self.assertNotEqual(
            defaultLogLevel, LogLevel.error,
            "This test assumes the default log level is not error."
        )

        config.setDefaults(DEFAULT_CONFIG)
        config.reload()

        self.assertEquals(logLevelForNamespace(None), defaultLogLevel)
        self.assertEquals(logLevelForNamespace("some.namespace"), defaultLogLevel)

        config.load(self.testConfig)

        self.assertEquals(logLevelForNamespace(None), LogLevel.error)
        self.assertEquals(logLevelForNamespace("some.namespace"), LogLevel.debug)

        writePlist({}, self.testConfig)
        config.reload()

        self.assertEquals(logLevelForNamespace(None), defaultLogLevel)
        self.assertEquals(logLevelForNamespace("some.namespace"), defaultLogLevel)
开发者ID:svn2github,项目名称:calendarserver-raw,代码行数:25,代码来源:test_config.py

示例2: testSyncToken

    def testSyncToken(self):
        config.load(self.testConfig)

        # no sync token keys specified; need to empty this array here because
        # stdconfig is registering keys automatically
        config._syncTokenKeys = []
        self.assertEquals("d41d8cd98f00b204e9800998ecf8427e", config.syncToken())

        # add sync token keys (some with multiple levels)
        config.addSyncTokenKey("DefaultLogLevel")
        config.addSyncTokenKey("Notifications.Services.APNS.Enabled")
        config.addSyncTokenKey("Notifications.Services.APNS.CalDAV.Topic")
        config.addSyncTokenKey("Notifications.Services.APNS.CardDAV.Topic")
        self.assertEquals("7473205187d7a6ff0c61a2b6b04053c5", config.syncToken())

        # modify a sync token key value
        config.Notifications.Services.APNS.CalDAV.Topic = "changed"
        # direct manipulation of config requires explicit invalidation
        self.assertEquals("7473205187d7a6ff0c61a2b6b04053c5", config.syncToken())
        config.invalidateSyncToken()
        self.assertEquals("4cdbb3841625d001dc768439f5a88cba", config.syncToken())

        # add a non existent key (not an error because it could exist later)
        config.addSyncTokenKey("Notifications.Services.APNS.CalDAV.NonExistent")
        config.invalidateSyncToken()
        self.assertEquals("2ffb128cee5a4b217cef82fd31ae7767", config.syncToken())

        # reload automatically invalidates
        config.reload()
        self.assertEquals("a1c46c5aff1899658dac033ee8520b07", config.syncToken())
开发者ID:eventable,项目名称:CalendarServer,代码行数:30,代码来源:test_config.py

示例3: testScoping

    def testScoping(self):
        self.assertEquals(config.ResponseCompression, False)

        config.load(self.testConfig)

        self.assertEquals(config.ResponseCompression, True)

        _testResponseCompression(self)
开发者ID:svn2github,项目名称:calendarserver-raw,代码行数:8,代码来源:test_config.py

示例4: loadConfig

def loadConfig(configFileName):
    if configFileName is None:
        configFileName = DEFAULT_CONFIG_FILE

    if not os.path.isfile(configFileName):
        raise ConfigurationError("No config file: %s" % (configFileName,))

    config.load(configFileName)

    return config
开发者ID:svn2github,项目名称:calendarserver-raw,代码行数:10,代码来源:util.py

示例5: testReloading

    def testReloading(self):
        self.assertEquals(config.HTTPPort, 0)

        config.load(self.testConfig)

        self.assertEquals(config.HTTPPort, 8008)

        writePlist({}, self.testConfig)

        config.reload()

        self.assertEquals(config.HTTPPort, 0)
开发者ID:svn2github,项目名称:calendarserver-raw,代码行数:12,代码来源:test_config.py

示例6: loadConfiguration

    def loadConfiguration(self):
        if not os.path.exists(self["config"]):
            print "Config file %s not found. Exiting." % (self["config"],)
            sys.exit(1)

        print "Reading configuration from file: %s" % (self["config"],)

        try:
            config.load(self["config"])
        except ConfigurationError, e:
            print "Invalid configuration: %s" % (e,)
            sys.exit(1)
开发者ID:svn2github,项目名称:calendarserver-raw,代码行数:12,代码来源:caldav.py

示例7: loadConfiguration

    def loadConfiguration(self):
        if not os.path.exists(self["config"]):
            self.log_info("Config file %s not found, using defaults"
                          % (self["config"],))

        self.log_info("Reading configuration from file: %s"
                      % (self["config"],))

        try:
            config.load(self["config"])
        except ConfigurationError, e:
            log.err("Invalid configuration: %s" % (e,))
            sys.exit(1)
开发者ID:svn2github,项目名称:calendarserver-raw,代码行数:13,代码来源:caldav.py

示例8: testUpdateAndReload

    def testUpdateAndReload(self):
        self.assertEquals(config.HTTPPort, 0)

        config.load(self.testConfig)

        self.assertEquals(config.HTTPPort, 8008)

        config.update({"HTTPPort": 80})

        self.assertEquals(config.HTTPPort, 80)

        config.reload()

        self.assertEquals(config.HTTPPort, 8008)
开发者ID:svn2github,项目名称:calendarserver-raw,代码行数:14,代码来源:test_config.py

示例9: testUpdateDefaults

    def testUpdateDefaults(self):
        self.assertEquals(config.SSLPort, 0)

        config.load(self.testConfig)

        config.updateDefaults({"SSLPort": 8009})

        self.assertEquals(config.SSLPort, 8009)

        config.reload()

        self.assertEquals(config.SSLPort, 8009)

        config.updateDefaults({"SSLPort": 0})
开发者ID:svn2github,项目名称:calendarserver-raw,代码行数:14,代码来源:test_config.py

示例10: testPreserveAcrossReload

    def testPreserveAcrossReload(self):
        self.assertEquals(config.Scheduling.iMIP.Sending.Password, "")
        self.assertEquals(config.Scheduling.iMIP.Receiving.Password, "")

        config.load(self.testConfig)

        self.assertEquals(config.Scheduling.iMIP.Sending.Password, "sending")
        self.assertEquals(config.Scheduling.iMIP.Receiving.Password, "receiving")

        writePlist({}, self.testConfig)

        config.reload()

        self.assertEquals(config.Scheduling.iMIP.Sending.Password, "sending")
        self.assertEquals(config.Scheduling.iMIP.Receiving.Password, "receiving")
开发者ID:svn2github,项目名称:calendarserver-raw,代码行数:15,代码来源:test_config.py

示例11: setUp

    def setUp(self):
        super(ManagePrincipalsTestCase, self).setUp()

        # Since this test operates on proxy db, we need to assign the service:
        calendaruserproxy.ProxyDBService = calendaruserproxy.ProxySqliteDB(os.path.abspath(self.mktemp()))

        config.GlobalAddressBook.Enabled = False

        testRoot = os.path.join(os.path.dirname(__file__), "principals")
        templateName = os.path.join(testRoot, "caldavd.plist")
        templateFile = open(templateName)
        template = templateFile.read()
        templateFile.close()

        databaseRoot = os.path.abspath("_spawned_scripts_db" + str(os.getpid()))
        newConfig = template % {
            "ServerRoot" : os.path.abspath(config.ServerRoot),
            "DataRoot" : os.path.abspath(config.DataRoot),
            "DatabaseRoot" : databaseRoot,
            "DocumentRoot" : os.path.abspath(config.DocumentRoot),
            "LogRoot" : os.path.abspath(config.LogRoot),
        }
        configFilePath = FilePath(os.path.join(config.ConfigRoot, "caldavd.plist"))
        configFilePath.setContent(newConfig)

        self.configFileName = configFilePath.path
        config.load(self.configFileName)

        origUsersFile = FilePath(os.path.join(os.path.dirname(__file__),
            "principals", "users-groups.xml"))
        copyUsersFile = FilePath(os.path.join(config.DataRoot, "accounts.xml"))
        origUsersFile.copyTo(copyUsersFile)

        origResourcesFile = FilePath(os.path.join(os.path.dirname(__file__),
            "principals", "resources-locations.xml"))
        copyResourcesFile = FilePath(os.path.join(config.DataRoot, "resources.xml"))
        origResourcesFile.copyTo(copyResourcesFile)

        origAugmentFile = FilePath(os.path.join(os.path.dirname(__file__),
            "principals", "augments.xml"))
        copyAugmentFile = FilePath(os.path.join(config.DataRoot, "augments.xml"))
        origAugmentFile.copyTo(copyAugmentFile)

        # Make sure trial puts the reactor in the right state, by letting it
        # run one reactor iteration.  (Ignore me, please.)
        d = Deferred()
        reactor.callLater(0, d.callback, True)
        return d
开发者ID:svn2github,项目名称:calendarserver-raw,代码行数:48,代码来源:test_principals.py

示例12: testReloading

    def testReloading(self):
        self.assertEquals(config.HTTPPort, 0)

        config.load(self.testConfig)

        self.assertEquals(config.HTTPPort, 8008)

        writePlist({}, self.testConfig)

        self._reloadingValue = None
        config.addPostUpdateHooks([self._myUpdateHook])
        config.reload()

        # Make sure reloading=True was passed to the update hooks
        self.assertTrue(self._reloadingValue)

        self.assertEquals(config.HTTPPort, 0)
开发者ID:svn2github,项目名称:calendarserver-raw,代码行数:17,代码来源:test_config.py

示例13: loadConfig

def loadConfig(configFileName):
    """
    Helper method for command-line utilities to load configuration plist
    and override certain values.
    """
    if configFileName is None:
        configFileName = DEFAULT_CONFIG_FILE

    if not os.path.isfile(configFileName):
        raise ConfigurationError("No config file: %s" % (configFileName,))

    config.load(configFileName)

    # Command-line utilities always want these enabled:
    config.EnableCalDAV = True
    config.EnableCardDAV = True

    return config
开发者ID:eventable,项目名称:CalendarServer,代码行数:18,代码来源:util.py

示例14: test_logging

    def test_logging(self):
        """
        Logging module configures properly.
        """
        config.setDefaults(DEFAULT_CONFIG)
        config.reload()

        self.assertEquals(logLevelForNamespace(None), "warn")
        self.assertEquals(logLevelForNamespace("some.namespace"), "warn")

        config.load(self.testConfig)

        self.assertEquals(logLevelForNamespace(None), "info")
        self.assertEquals(logLevelForNamespace("some.namespace"), "debug")

        writePlist({}, self.testConfig)
        config.reload()

        self.assertEquals(logLevelForNamespace(None), "warn")
        self.assertEquals(logLevelForNamespace("some.namespace"), "warn")
开发者ID:svn2github,项目名称:calendarserver-raw,代码行数:20,代码来源:test_config.py

示例15: setUp

    def setUp(self):
        super(RunCommandTestCase, self).setUp()

        testRoot = os.path.join(os.path.dirname(__file__), "gateway")
        templateName = os.path.join(testRoot, "caldavd.plist")
        templateFile = open(templateName)
        template = templateFile.read()
        templateFile.close()

        databaseRoot = os.path.abspath("_spawned_scripts_db" + str(os.getpid()))
        newConfig = template % {
            "ServerRoot" : os.path.abspath(config.ServerRoot),
            "DatabaseRoot" : databaseRoot,
            "WritablePlist" : os.path.join(os.path.abspath(config.ConfigRoot), "caldavd-writable.plist"),
        }
        configFilePath = FilePath(os.path.join(config.ConfigRoot, "caldavd.plist"))
        configFilePath.setContent(newConfig)

        self.configFileName = configFilePath.path
        config.load(self.configFileName)

        origUsersFile = FilePath(os.path.join(os.path.dirname(__file__),
            "gateway", "users-groups.xml"))
        copyUsersFile = FilePath(os.path.join(config.DataRoot, "accounts.xml"))
        origUsersFile.copyTo(copyUsersFile)

        origResourcesFile = FilePath(os.path.join(os.path.dirname(__file__),
            "gateway", "resources-locations.xml"))
        copyResourcesFile = FilePath(os.path.join(config.DataRoot, "resources.xml"))
        origResourcesFile.copyTo(copyResourcesFile)

        origAugmentFile = FilePath(os.path.join(os.path.dirname(__file__),
            "gateway", "augments.xml"))
        copyAugmentFile = FilePath(os.path.join(config.DataRoot, "augments.xml"))
        origAugmentFile.copyTo(copyAugmentFile)

        # Make sure trial puts the reactor in the right state, by letting it
        # run one reactor iteration.  (Ignore me, please.)
        d = Deferred()
        reactor.callLater(0, d.callback, True)
        return d
开发者ID:svn2github,项目名称:calendarserver-raw,代码行数:41,代码来源:test_gateway.py


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