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


Python Conf.reload方法代码示例

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


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

示例1: test_invalid_ini

# 需要导入模块: from galicaster.core.conf import Conf [as 别名]
# 或者: from galicaster.core.conf.Conf import reload [as 别名]
    def test_invalid_ini(self):
        conf_file = get_resource('conf/conf.ini')
        conf_dist_file = get_resource('conf/conf_dist.ini')
        profiles_dir = get_resource('conf/profiles')
        conf = Conf(conf_file, conf_dist_file, profiles_dir)
        conf.reload()
        old_conf = self.conf.get_all()

        content = ''
        with open(get_resource('conf/conf.ini'), 'r') as content_file:
                content = content_file.read()

        # Override conf file
        f = open(get_resource('conf/conf.ini'),'w')
        f.write('testing wrong config file')
        f.close()

        conf_dist_file = get_resource('conf/conf_dist.ini')
        profiles_dir = get_resource('conf/profiles')
        conf = Conf(conf_file, conf_dist_file, profiles_dir)
        conf.reload()
        new_conf = self.conf.get_all()

        self.assertEqual(old_conf, new_conf)

        # Override conf file
        f = open(get_resource('conf/conf.ini'),'w')
        f.write(content)
        f.close()
开发者ID:SussexLearningSystems,项目名称:Galicaster,代码行数:31,代码来源:conf.py

示例2: test_profile_with_no_profiles_in_files

# 需要导入模块: from galicaster.core.conf import Conf [as 别名]
# 或者: from galicaster.core.conf.Conf import reload [as 别名]
 def test_profile_with_no_profiles_in_files(self):
     conf_file = get_resource('conf/conf.ini')
     conf_dist_file = get_resource('conf/conf_dist.ini')
     profiles_dir = get_resource('conf/profiles')
     conf = Conf(conf_file, conf_dist_file, profiles_dir)
     conf.reload()
     self.assertEqual(len(conf.get_profiles()), 1)
开发者ID:SussexLearningSystems,项目名称:Galicaster,代码行数:9,代码来源:conf.py

示例3: TestFunctions

# 需要导入模块: from galicaster.core.conf import Conf [as 别名]
# 或者: from galicaster.core.conf.Conf import reload [as 别名]
class TestFunctions(TestCase):

    def setUp(self):
        self.tmppath = mkdtemp()

        repo = repository.Repository(self.tmppath)
        context.set('repository', repo)

        # conf = Conf()
        # context.set('conf', conf)

        self.conf_file = get_resource('conf/conf.ini')
        self.backup_conf_file =get_resource('conf/conf.backup.ini')
        dist_file = get_resource('conf/conf-dist.ini')

        shutil.copyfile(self.conf_file,self.backup_conf_file)
        self.conf = Conf(self.conf_file,dist_file)
        self.conf.reload()



    def tearDown(self):
        rmtree(self.tmppath)
        shutil.copyfile(self.backup_conf_file,self.conf_file)
        os.remove(self.backup_conf_file)
        del self.conf


    def test_cleanstale_plugin(self):
        dispatcher = context.get_dispatcher()
        repo = context.get_repository()
        conf = context.get_conf()
        now = datetime.datetime.utcnow()

        mp = mediapackage.Mediapackage(identifier="1", title='MP#1', date=(now - datetime.timedelta(days=1)))
        repo.add(mp)
        mp = mediapackage.Mediapackage(identifier="2", title='MP#2', date=(now - datetime.timedelta(days=30)))
        repo.add(mp)
        mp = mediapackage.Mediapackage(identifier="3", title='MP#3', date=(now - datetime.timedelta(days=60)))
        repo.add(mp)
        mp = mediapackage.Mediapackage(identifier="4", title='MP#4', date=(now + datetime.timedelta(days=1)))
        repo.add(mp)
        mp = mediapackage.Mediapackage(identifier="5", title='MP#5', date=(now + datetime.timedelta(days=30)))
        repo.add(mp)


        conf.set('cleanstale','maxarchivaldays', '70')
        cleanstale.init()
        self.assertEqual(len(repo), 5)

        conf.set('cleanstale','maxarchivaldays', '50')
        cleanstale.init()
        dispatcher.emit('timer-nightly')
        self.assertEqual(len(repo), 4)
        conf.set('cleanstale','maxarchivaldays', '20')
        cleanstale.init()
        dispatcher.emit('timer-nightly')
        self.assertEqual(len(repo), 3)
开发者ID:SussexLearningSystems,项目名称:Galicaster,代码行数:60,代码来源:cleanstale.py

示例4: __get_dependencies

# 需要导入模块: from galicaster.core.conf import Conf [as 别名]
# 或者: from galicaster.core.conf.Conf import reload [as 别名]
    def __get_dependencies(self):
        dispatcher = context.get_dispatcher()
        repo = Repository(self.tmppath)
        worker = self.WorkerMock()
        conf = Conf()
        conf.reload()
        conf.set("allows", "overlap", "False")
        logger = Logger(None)

        return dispatcher, repo, worker, conf, logger
开发者ID:SussexLearningSystems,项目名称:Galicaster,代码行数:12,代码来源:service.py

示例5: test_active_tag_default_profile

# 需要导入模块: from galicaster.core.conf import Conf [as 别名]
# 或者: from galicaster.core.conf.Conf import reload [as 别名]
    def test_active_tag_default_profile(self):
        conf_file = get_resource('conf/conf_active.ini')
        backup_conf_active = get_resource('conf/conf_active.backup.ini')
        dist_file = get_resource('conf/conf-dist.ini')

        shutil.copyfile(conf_file, backup_conf_active)
        conf = Conf(conf_file, dist_file)
        conf.reload()
        profile = conf.get_current_profile()
        self.assertEqual(1, len(profile.tracks))
        shutil.copyfile(backup_conf_active, conf_file)
        os.remove(backup_conf_active)
开发者ID:SussexLearningSystems,项目名称:Galicaster,代码行数:14,代码来源:conf.py

示例6: TestFunctions

# 需要导入模块: from galicaster.core.conf import Conf [as 别名]
# 或者: from galicaster.core.conf.Conf import reload [as 别名]
class TestFunctions(TestCase):
        
    def setUp(self):
        conf_file = path.join(path.dirname(path.abspath(__file__)), 'resources', 'conf', 'conf.ini')
        dist_file = path.join(path.dirname(path.abspath(__file__)), 'resources', 'conf', 'conf-dist.ini')
        self.conf = Conf(conf_file,dist_file)


    def tearDown(self):
        del self.conf

    
    def test_init_no_file(self):
        primary_conf = path.join('/etc/galicaster','conf.ini')
        secondary_conf = path.abspath(path.join(path.dirname(__file__), '..', 'conf.ini'))
        primary_dist = path.join('/usr/share/galicaster/',  'conf-dist.ini')
        secondary_dist = path.abspath(path.join(path.dirname(__file__), '..', 'conf-dist.ini'))
        # Conf loads default conf and conf-dist
        conf = Conf()
        self.assertEqual( primary_conf if path.isfile(primary_conf) else secondary_conf,
                          conf.conf_file) 
        self.assertEqual( primary_dist if path.isfile(primary_dist) else secondary_dist,
                          conf.conf_dist_file) 

    def test_init_no_dist_file(self):
        conf_file = path.join(path.dirname(path.abspath(__file__)), 'resources', 'conf', 'conf.ini')
        primary_dist = path.join('/usr/share/galicaster/',  'conf-dist.ini')
        secondary_dist = path.abspath(path.join(path.dirname(__file__), '..', 'conf-dist.ini'))
        #conf load custom conf and default dist
        conf = Conf(conf_file)
        self.assertEqual(conf_file, conf.conf_file)
        self.assertEqual( primary_dist if path.isfile(primary_dist) else secondary_dist,
                          conf.conf_dist_file) 

    def test_init_all_files(self):
        conf_file = path.join(path.dirname(path.abspath(__file__)), 'resources', 'conf', 'conf.ini')
        conf_dist_file = path.join(path.dirname(path.abspath(__file__)), 'resources', 'conf', 'conf-dist.ini')
        conf = Conf(conf_file, conf_dist_file)
        self.assertEqual(conf_file, conf.conf_file)
        self.assertEqual(conf_dist_file, conf.conf_dist_file)


    def test_get_and_set(self):
        # GET data in conf-dist
        self.assertEqual('full', self.conf.get('ingest', 'workflow'))
        # GET data in conf
        self.assertEqual('track1', self.conf.get('track1', 'name'))
        # GET data in conf (and conf-dist)
        self.assertEqual('presentation', self.conf.get('screen', 'left'))
        # SET
        self.conf.set('section', 'key', 'value')
        self.assertEqual('value', self.conf.get('section', 'key'))
        

    def test_reload(self):
        self.conf.set('basic', 'temp', 'temporal')
        self.assertEqual('temporal', self.conf.get('basic', 'temp'))
        self.conf.reload()
        self.assertEqual('/tmp/repo', self.conf.get('basic', 'temp'))
        

    def test_get_tracks_in_mh_dict(self):
        conf = self.conf.get_tracks_in_mh_dict()
        self.assertEqual(len(conf), 3*3 +1)
        self.assertEqual(conf['capture.device.names'], 'track1,track3,track2')
        self.assertEqual(conf['capture.device.track2.outputfile'], 'SCREEN.mpeg')
        self.assertEqual(conf['capture.device.track2.src'], '/dev/null')

    def test_profile_with_no_profiles_in_files(self):
        conf_file = path.join(path.dirname(path.abspath(__file__)), 'resources', 'conf', 'conf.ini')
        conf_dist_file = path.join(path.dirname(path.abspath(__file__)), 'resources', 'conf', 'conf_dist.ini')
        profiles_dir = path.join(path.dirname(path.abspath(__file__)), 'resources', 'conf', 'profiles')
        conf = Conf(conf_file, conf_dist_file, profiles_dir)

        self.assertEqual(len(conf.get_profiles()), 1)

    def test_init_track(self):
        track = Track()
        self.assertEqual(track.name, None)
        self.assertEqual(track.device, None)
        self.assertEqual(track.flavor, None)
        self.assertEqual(track.location, None)
        self.assertEqual(track.file, None)
        self.assertEqual(len(track), 5)

        track.name = 'v_name'
        track.device = 'v_device'
        track.flavor = 'v_flavor'
        track.location = 'v_location'
        track.file = 'v_file'

        self.assertEqual(track.name, 'v_name')
        self.assertEqual(track.device, 'v_device')
        self.assertEqual(track.flavor, 'v_flavor')
        self.assertEqual(track.location, 'v_location')
        self.assertEqual(track.file, 'v_file')
        self.assertEqual(track['name'], 'v_name')
        self.assertEqual(track['device'], 'v_device')
        self.assertEqual(track['flavor'], 'v_flavor')
        self.assertEqual(track['location'], 'v_location')
#.........这里部分代码省略.........
开发者ID:qingke678,项目名称:galicaster-uib,代码行数:103,代码来源:conf.py

示例7: TestFunctions

# 需要导入模块: from galicaster.core.conf import Conf [as 别名]
# 或者: from galicaster.core.conf.Conf import reload [as 别名]
class TestFunctions(TestCase):
    def setUp(self):
        conf_file = get_resource("conf/conf.ini")
        dist_file = get_resource("conf/conf-dist.ini")
        self.conf = Conf(conf_file, dist_file)

    def tearDown(self):
        del self.conf

    def test_init_no_file(self):
        primary_conf = path.join("/etc/galicaster", "conf.ini")
        secondary_conf = path.abspath(path.join(path.dirname(__file__), "..", "..", "conf.ini"))
        secondary_dist = path.abspath(path.join(path.dirname(__file__), "..", "..", "conf-dist.ini"))
        # Conf loads default conf and conf-dist
        conf = Conf(conf_dist_file=secondary_dist)
        self.assertEqual(primary_conf if path.isfile(primary_conf) else secondary_conf, conf.conf_file)
        self.assertEqual(secondary_dist, conf.conf_dist_file)

    def test_init_all_files(self):
        conf_file = get_resource("conf/conf.ini")
        conf_dist_file = get_resource("conf/conf-dist.ini")
        conf = Conf(conf_file, conf_dist_file)
        self.assertEqual(conf_file, conf.conf_file)
        self.assertEqual(conf_dist_file, conf.conf_dist_file)

    def test_get_and_set(self):
        # GET data in conf-dist
        self.assertEqual("full", self.conf.get("ingest", "workflow"))
        # GET data in conf
        self.assertEqual("track1", self.conf.get("track1", "name"))
        # SET
        self.conf.set("section", "key", "value")
        self.assertEqual("value", self.conf.get("section", "key"))

    def test_reload(self):
        self.conf.set("basic", "temp", "temporal")
        self.assertEqual("temporal", self.conf.get("basic", "temp"))
        self.conf.reload()
        self.assertEqual("/tmp/repo", self.conf.get("basic", "temp"))

    def test_get_tracks_in_oc_dict(self):
        conf = self.conf.get_tracks_in_oc_dict()
        self.assertEqual(len(conf), 3 * 3 + 1)
        self.assertEqual(conf["capture.device.names"], "track1,track3,track2")
        self.assertEqual(conf["capture.device.track2.outputfile"], "SCREEN.mpeg")
        self.assertEqual(conf["capture.device.track2.src"], "/dev/null")

    def test_profile_with_no_profiles_in_files(self):
        conf_file = get_resource("conf/conf.ini")
        conf_dist_file = get_resource("conf/conf_dist.ini")
        profiles_dir = get_resource("conf/profiles")
        conf = Conf(conf_file, conf_dist_file, profiles_dir)

        self.assertEqual(len(conf.get_profiles()), 1)

    def test_init_track(self):
        track = Track()
        self.assertEqual(track.name, None)
        self.assertEqual(track.device, None)
        self.assertEqual(track.flavor, None)
        self.assertEqual(track.location, None)
        self.assertEqual(track.file, None)
        self.assertEqual(len(track), 5)

        track.name = "v_name"
        track.device = "v_device"
        track.flavor = "v_flavor"
        track.location = "v_location"
        track.file = "v_file"

        self.assertEqual(track.name, "v_name")
        self.assertEqual(track.device, "v_device")
        self.assertEqual(track.flavor, "v_flavor")
        self.assertEqual(track.location, "v_location")
        self.assertEqual(track.file, "v_file")
        self.assertEqual(track["name"], "v_name")
        self.assertEqual(track["device"], "v_device")
        self.assertEqual(track["flavor"], "v_flavor")
        self.assertEqual(track["location"], "v_location")
        self.assertEqual(track["file"], "v_file")

        self.assertEqual(track.keys(), ["name", "device", "flavor", "location", "file"])
        self.assertEqual(track.values(), ["v_name", "v_device", "v_flavor", "v_location", "v_file"])
        self.assertEqual(
            track.basic(),
            {"name": "v_name", "device": "v_device", "flavor": "v_flavor", "location": "v_location", "file": "v_file"},
        )
        self.assertEqual(track.options(), {})

    def test_add_and_del_value_in_track(self):
        track = Track()
        track["new_key"] = "new_value"
        self.assertEqual(len(track), 6)
        self.assertEqual(track["new_key"], "new_value")
        self.assertEqual(track.keys(), ["name", "device", "flavor", "location", "file", "new_key"])
        self.assertEqual(track.values(), [None, None, None, None, None, "new_value"])
        self.assertEqual(track.basic(), {"name": None, "device": None, "flavor": None, "location": None, "file": None})
        self.assertEqual(track.options(), {"new_key": "new_value"})

        del track["new_key"]
#.........这里部分代码省略.........
开发者ID:rubenrua,项目名称:Galicaster,代码行数:103,代码来源:conf.py

示例8: TestFunctions

# 需要导入模块: from galicaster.core.conf import Conf [as 别名]
# 或者: from galicaster.core.conf.Conf import reload [as 别名]
class TestFunctions(TestCase):

    def setUp(self):
        self.conf_file = get_resource('conf/conf.ini')
        self.backup_conf_file =get_resource('conf/conf.backup.ini')
        dist_file = get_resource('conf/conf-dist.ini')

        shutil.copyfile(self.conf_file,self.backup_conf_file)
        self.conf = Conf(self.conf_file,dist_file)
        self.conf.reload()

    def tearDown(self):
        shutil.copyfile(self.backup_conf_file,self.conf_file)
        os.remove(self.backup_conf_file)
        del self.conf


    def touch(self, fname, times=None):
        with open(fname, 'a'):
            os.utime(fname, times)

    def test_init_no_file(self):
        primary_conf = os.path.join('/etc/galicaster','conf.ini')
        secondary_conf = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..', 'conf.ini'))
        secondary_dist = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..', 'conf-dist.ini'))
        # Conf loads default conf and conf-dist
        conf = Conf(conf_dist_file=secondary_dist)
        self.assertEqual( primary_conf if os.path.isfile(primary_conf) else secondary_conf,
                          conf.conf_file)
        self.assertEqual( secondary_dist,
                          conf.conf_dist_file)

    def test_init_all_files(self):
        conf_file = get_resource('conf/conf.ini')
        conf_dist_file = get_resource('conf/conf-dist.ini')
        conf = Conf(conf_file, conf_dist_file)
        self.assertEqual(conf_file, conf.conf_file)
        self.assertEqual(conf_dist_file, conf.conf_dist_file)


    def test_invalid_ini(self):
        conf_file = get_resource('conf/conf.ini')
        conf_dist_file = get_resource('conf/conf_dist.ini')
        profiles_dir = get_resource('conf/profiles')
        conf = Conf(conf_file, conf_dist_file, profiles_dir)
        conf.reload()
        old_conf = self.conf.get_all()

        content = ''
        with open(get_resource('conf/conf.ini'), 'r') as content_file:
                content = content_file.read()

        # Override conf file
        f = open(get_resource('conf/conf.ini'),'w')
        f.write('testing wrong config file')
        f.close()

        conf_dist_file = get_resource('conf/conf_dist.ini')
        profiles_dir = get_resource('conf/profiles')
        conf = Conf(conf_file, conf_dist_file, profiles_dir)
        conf.reload()
        new_conf = self.conf.get_all()

        self.assertEqual(old_conf, new_conf)

        # Override conf file
        f = open(get_resource('conf/conf.ini'),'w')
        f.write(content)
        f.close()


    def test_active_tag_default_profile(self):
        conf_file = get_resource('conf/conf_active.ini')
        backup_conf_active = get_resource('conf/conf_active.backup.ini')
        dist_file = get_resource('conf/conf-dist.ini')

        shutil.copyfile(conf_file, backup_conf_active)
        conf = Conf(conf_file, dist_file)
        conf.reload()
        profile = conf.get_current_profile()
        self.assertEqual(1, len(profile.tracks))
        shutil.copyfile(backup_conf_active, conf_file)
        os.remove(backup_conf_active)

    def test_profile_with_no_profiles_in_files(self):
        conf_file = get_resource('conf/conf.ini')
        conf_dist_file = get_resource('conf/conf_dist.ini')
        profiles_dir = get_resource('conf/profiles')
        conf = Conf(conf_file, conf_dist_file, profiles_dir)
        conf.reload()
        self.assertEqual(len(conf.get_profiles()), 1)


    def test_get_and_set(self):
        # GET data in conf-dist
        self.assertEqual('full', self.conf.get('ingest', 'workflow'))
        # GET data in conf
        self.assertEqual('track1', self.conf.get('track1', 'name'))
        # SET
        self.conf.set('section', 'key', 'value')
#.........这里部分代码省略.........
开发者ID:SussexLearningSystems,项目名称:Galicaster,代码行数:103,代码来源:conf.py

示例9: TestFunctions

# 需要导入模块: from galicaster.core.conf import Conf [as 别名]
# 或者: from galicaster.core.conf.Conf import reload [as 别名]
class TestFunctions(TestCase):

    def setUp(self):
        for service_name in ['conf', 'dispatcher', 'mainwindow', 'heartbeat',
                             'repository', 'occlient', 'scheduler']:
            if context.has(service_name):
                context.delete(service_name)

        self.conf_file = get_resource('conf/conf.ini')
        self.backup_conf_file =get_resource('conf/conf.backup.ini')
        dist_file = get_resource('conf/conf-dist.ini')

        shutil.copyfile(self.conf_file,self.backup_conf_file)
        self.conf = Conf(self.conf_file,dist_file)
        context.set('conf',self.conf)
        self.conf.reload()

    def tearDown(self):
        shutil.copyfile(self.backup_conf_file,self.conf_file)
        os.remove(self.backup_conf_file)
        del self.conf

    def test_twice(self):
        conf1 = context.get_conf()
        conf2 = context.get_conf()
        self.assertEqual(id(conf1), id(conf2))

    def test_getter_setter(self):
        service_name = 'pr'
        service = 'Service'
        other_service = 'Other service'
        self.assertRaises(KeyError, context.get, service_name)
        context.set(service_name, service)
        self.assertEqual(service, context.get(service_name))
        context.set(service_name, other_service)
        self.assertNotEqual(service, context.get(service_name))
        self.assertEqual(other_service, context.get(service_name))
        context.delete(service_name)
        self.assertRaises(KeyError, context.get, service_name)

    def test_context(self):
        self.assertNotEqual(type(context.get_conf()), galicaster.core.conf)
        self.assertEqual(type(context.get_conf()), galicaster.core.conf.Conf)
        self.assertEqual(type(context.get_dispatcher()), galicaster.core.dispatcher.Dispatcher)
        self.assertEqual(type(context.get_repository()), galicaster.mediapackage.repository.Repository)


    def test_get_scheduler_and_occlient_none(self):
        conf = context.get_conf()
        conf.set('ingest', 'active', 'False')

        self.assertEqual(context.get_occlient(), None)
        self.assertTrue(context.get_scheduler() != None)

        context.delete('occlient')
        context.delete('scheduler')
        conf.set('ingest', 'active', 'True')
        self.assertEqual(type(context.get_occlient()), galicaster.opencast.client.OCHTTPClient)
        self.assertEqual(type(context.get_scheduler()), galicaster.scheduler.scheduler.Scheduler)


    def test_get_occlient_with_config(self):
        # Context init in other test
        if context.has('occlient'):
            context.delete('occlient')

        host = "http://servertest.www.es"
        conf = context.get_conf()
        conf.set('ingest', 'active', 'True')
        original_host = conf.get('ingest', 'host')
        conf.set('ingest', 'host', host)
        client = context.get_occlient()
        self.assertNotEqual(original_host, client.server)
        self.assertEqual(host, client.server)

        context.delete('occlient') # Context init in other test
        conf.remove_option('ingest', 'hostname')
        conf.set('ingest' , 'hostname', 'foobar')
        client = context.get_occlient()
        self.assertEqual('foobar', client.hostname)

        context.delete('occlient') # Context init in other test
        conf.set('basic', 'admin', 'False')
        conf.remove_option('ingest', 'hostname')
        conf.hostname = conf.get_hostname()
        client = context.get_occlient()
        self.assertEqual('GC-' + socket.gethostname(), client.hostname)

        context.delete('occlient') # Context init in other test
        conf.set('basic', 'admin', 'True')
        conf.remove_option('ingest', 'hostname')
        conf.hostname = conf.get_hostname()
        client = context.get_occlient()
        self.assertEqual('GCMobile-' + socket.gethostname(), client.hostname)

        context.delete('conf') # To other test
        context.delete('occlient') # To other test

    @attr('notravis')
    def test_get_mainwindow(self):
#.........这里部分代码省略.........
开发者ID:SussexLearningSystems,项目名称:Galicaster,代码行数:103,代码来源:context.py


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