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


Python Conf.get_free_profile方法代码示例

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


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

示例1: TestFunctions

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

    def setUp(self):
        conf_file = get_resource('profile/conf_good.ini')
        conf_dist_file = get_resource('profile/conf-dist.ini')
        folder_path = get_resource('profile/folder')

        self.conf = Conf(conf_file,conf_dist_file, folder_path)

    def no_test_create_profile(self):
        profile=Profile("New profile")
        self.assertEqual(profile.name, "New profile")    

    def no_test_create_and_add_profile(self):
        self.setUp()
        profile=Profile("New")
        self.conf.add_profile(profile)
        self.assertEqual(self.conf.get_profiles().has_key("New"),True)    
    
    def no_test_write_profile(self):
        self.setUp()
        folder_path = path.join(path.dirname(path.abspath(__file__)), 
                                'resources', 'profile', 'folder')

        profile=Profile("New profile", path.join(folder_path,"profile11.ini"))
    
        self.conf.add_profile(profile)
        self.conf.update_profiles()
        path.isfile(path.join(folder_path,"profile11.ini"))
        os.remove(path.join(folder_path,"profile11.ini"))

    def no_test_write_profile_default_naming(self):
        self.setUp()
        folder_path = path.join(path.dirname(path.abspath(__file__)),
                                'resources', 'profile', 'folder')

        profile=Profile("New profile")
        profile.path=self.conf.get_free_profile()
        self.conf.add_profile(profile)
        self.conf.update_profiles()
        path.isfile(path.join(folder_path,"profile1.ini"))
        os.remove(path.join(folder_path,"profile1.ini"))

    def no_test_delete_profile(self):
        self.setUp()
        folder_path = path.join(path.dirname(path.abspath(__file__)),
                                'resources', 'profile', 'folder')

        profile=Profile("New")
        profile.path=self.conf.get_free_profile()
        self.conf.add_profile(profile)
        self.conf.update_profiles()
        profile.to_delete = True
        self.conf.update_profiles()
        self.assertEqual(path.isfile(path.join(folder_path,"profile1.ini")),False)
        #os.remove(path.join(folder_path,"profile1.ini"))
        return True
    
    def change_parameters():
        return True

    def change_properties():
        return True

    def load_default_profile(self):
        return True

    def load_default_profile_on_dist(self):
        return True

    def see_all_tracks_in_conf(self):
        return True

    def look_for_an_unexisting_profile(self):
        return True
    
    def loof_for_an_existing_profile(self):
        return True

    def change_current_profile(self):
        return True

    def delete_current_profile(self):
        return True
    
    def set_default_to_current(self):
        return True

    def add_track():
        return True

    def delete_track():
        return True

    def get_video_areas_on_profile():
        return True

    def get_videos_areas_in_order():
        return True

#.........这里部分代码省略.........
开发者ID:CGreweling,项目名称:Galicaster,代码行数:103,代码来源:profile.py

示例2: TestFunctions

# 需要导入模块: from galicaster.core.conf import Conf [as 别名]
# 或者: from galicaster.core.conf.Conf import get_free_profile [as 别名]

#.........这里部分代码省略.........

    def test_track_property(self):
        track = Track()
        track.name = 'name'
        self.assertEqual(track.name, 'name')
        self.assertEqual(track['name'], 'name')


    def test_get_hostname(self):
        conf = Conf(self.conf_file)
        conf.set('config', 'ingest', None)
        conf.set('basic', 'admin', 'True')
        conf.set('ingest', 'hostname', None)
        self.assertEqual('GCMobile-' + socket.gethostname(), conf.get_hostname())
        self.assertEqual(1, len(conf.get_tracks_in_oc_dict()))
        self.assertEqual({'capture.device.names': 'defaults'}, conf.get_tracks_in_oc_dict())
        conf.set('basic', 'admin', 'False')
        conf.set('ingest', 'hostname', None)
        self.assertEqual('GC-' + socket.gethostname(), conf.get_hostname())
        name = "123456_654321"
        conf.set('ingest', 'hostname', name)
        self.assertEqual(name, conf.get_hostname())
        a = conf.remove_option('ingest', 'hostname')


    def test_get_ip_address(self):
        valid = True
        try:
            addr = self.conf.get_ip_address()
            socket.inet_aton(addr)
        except socket.error:
            valid = False
        self.assertTrue(valid)


    def test_set_section(self):
        self.assertEqual(self.conf.set_section(None, {}), False)
        self.assertEqual(self.conf.set_section('k', {"a": "1", "b" :"2"}), True)

    def test_get_section(self):
        self.assertEqual(self.conf.set_section('k', {"a": "1", "b" :"2"}), True)
        self.assertEqual(self.conf.get_section('k'), {"a": "1", "b" :"2"})
        self.assertEqual(self.conf.get_section('kkkkkk'), {})


    def test_get_user_section(self):
        self.assertEqual(self.conf.set_section('k', {"a": "1", "b" :"2"}), True)
        self.assertEqual(self.conf.get_user_section('k'), {"a": "1", "b" :"2"})
        self.assertEqual(self.conf.get_user_section('kkkkkk'), {})

    def test_get_sections(self):
        self.conf.remove_sections()
        self.assertEqual(self.conf.get_sections(), ['basic'])
        self.assertEqual(self.conf.get_user_sections(), [])

    def test_get_modules(self):
        self.assertEqual(self.conf.get_modules(), ['recorder', 'scheduler'])
        self.conf.set('basic', 'admin', 'True')
        self.assertEqual(self.conf.get_modules(), ['recorder', 'scheduler', 'media_manager', 'player'])
        self.conf.set('ingest', 'active', 'True')
        self.assertEqual(self.conf.get_modules(), ['recorder', 'scheduler', 'media_manager', 'player', 'ocservice'])

    def test_get_color_style(self):
        self.assertEqual(self.conf.get_color_style(), False)
        self.conf.set('color', 'classic', 'True')
        self.assertTrue(self.conf.get_color_style())

    def test_get_free_profile(self):
        profile_name = self.conf.get_free_profile()
        self.assertEqual(profile_name, self.conf.get_free_profile())
        self.touch(profile_name)
        self.assertNotEqual(profile_name, self.conf.get_free_profile())
        os.remove(profile_name)


    def test_get_palette(self):
        self.conf.set('color', 'none', None)
        self.conf.set('color','nightly', None)
        self.conf.set('color','pending', None)
        self.conf.set('color','processing', None)
        self.conf.set('color','done', None)
        self.conf.set('color','failed', None)
        self.assertEqual(self.conf.get_palette(), [None, None, None, None, None, None])

        self.conf.set('color', 'none', "#FFFFF0")
        self.conf.set('color','nightly', "#FFFFF1")
        self.conf.set('color','pending', "#FFFFF2")
        self.conf.set('color','processing', "#FFFFF3")
        self.conf.set('color','done', "#FFFFF4")
        self.conf.set('color','failed', "#FFFFF5")
        self.assertEqual(self.conf.get_palette(), ["#FFFFF0", "#FFFFF1", "#FFFFF2", "#FFFFF3", "#FFFFF4", "#FFFFF5"])

    def test_export_to_file(self):
        p_name = self.conf.get_profiles().keys()[0]
        p = self.conf.get_profiles()[p_name]

        p.path = "/tmp/test_profile1.ini"
        p.export_to_file()
        self.assertTrue(os.path.exists(p.path))
        os.remove(p.path)
开发者ID:SussexLearningSystems,项目名称:Galicaster,代码行数:104,代码来源:conf.py


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