示例#1
0
def test_load_ini_file_defaults():
    settings = config.load_ini_file("tests/sample.ini", defaults={'threadserver.run_dir':
                                                                  '/var/other',
                                                                  'threadserver.port':
                                                                  4227})
    assert_equal(settings['threadserver.run_dir'], '/var/run/threadserver')  # defaults is overwritten
    assert_equal(settings['threadserver.port'], 4227)  # defaults
示例#2
0
    def __init__(self, name, run_base="/var/run", log_dir="/var/log",
                 uid="nobody", gid="nogroup", config_base="/etc"):
        self.name = name
        self.config_file = os.path.join(config_base, self.name + ".conf")

        if os.path.exists(self.config_file):
            self.config = config.load_ini_file(self.config_file)
        else:
            self.config = {}

        self.run_dir = self.config.get(name + '.run_dir',
                                       os.path.join(run_base, self.name))
        self.log_file = self.config.get(name + '.log_file',
                                        os.path.join(log_dir, self.name + ".log"))
        self.uid = self.config.get(name + '.uid', uid)
        self.gid = self.config.get(name + '.gid', gid)
示例#3
0
def test_load_ini_file_defaults():
    settings = config.load_ini_file(
        "tests/sample.ini", defaults={'threadserver.run_dir': '/var/other'})
    assert_equal(settings['threadserver.run_dir'], '/var/other')
示例#4
0
def test_load_ini_file():
    settings = config.load_ini_file("tests/sample.ini")
    assert_equal(settings['threadserver.run_dir'], '/var/run/threadserver')
示例#5
0
def test_load_ini_file():
    settings = config.load_ini_file("tests/sample.ini")
    assert_equal(settings['threadserver.run_dir'], '/var/run/threadserver')
示例#6
0
def test_load_ini_file_defaults():
    settings = config.load_ini_file("tests/sample.ini", defaults={'threadserver.run_dir':
                                                                  '/var/other'})
    assert_equal(settings['threadserver.run_dir'], '/var/other')