本文整理匯總了Python中galicaster.core.conf.Conf.get_user_section方法的典型用法代碼示例。如果您正苦於以下問題:Python Conf.get_user_section方法的具體用法?Python Conf.get_user_section怎麽用?Python Conf.get_user_section使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類galicaster.core.conf.Conf
的用法示例。
在下文中一共展示了Conf.get_user_section方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: TestFunctions
# 需要導入模塊: from galicaster.core.conf import Conf [as 別名]
# 或者: from galicaster.core.conf.Conf import get_user_section [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)