本文整理汇总了Python中galicaster.core.conf.Conf.set方法的典型用法代码示例。如果您正苦于以下问题:Python Conf.set方法的具体用法?Python Conf.set怎么用?Python Conf.set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类galicaster.core.conf.Conf
的用法示例。
在下文中一共展示了Conf.set方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_get_lower
# 需要导入模块: from galicaster.core.conf import Conf [as 别名]
# 或者: from galicaster.core.conf.Conf import set [as 别名]
def test_get_lower(self):
conf = Conf()
for lower in ['RUBENRUA', 'RubenRua', 'RubenruA', 'rubenrua']:
conf.set('s', 'k', lower)
self.assertEqual(conf.get_lower('s', 'k'), 'rubenrua')
self.assertEqual(conf.get_lower('s', 'k_not_exists'), None)
示例2: test_get_hostname
# 需要导入模块: from galicaster.core.conf import Conf [as 别名]
# 或者: from galicaster.core.conf.Conf import set [as 别名]
def test_get_hostname(self):
conf = Conf()
conf.set("config", "ingest", None)
conf.set("basic", "admin", "True")
self.assertEqual("GCMobile-" + socket.gethostname(), conf.get_hostname())
self.assertEqual(1, len(conf.get_tracks_in_mh_dict()))
self.assertEqual({"capture.device.names": "defaults"}, conf.get_tracks_in_mh_dict())
conf.set("basic", "admin", "False")
self.assertEqual("GC-" + socket.gethostname(), conf.get_hostname())
示例3: test_get_list
# 需要导入模块: from galicaster.core.conf import Conf [as 别名]
# 或者: from galicaster.core.conf.Conf import set [as 别名]
def test_get_list(self):
conf = Conf()
self.assertEqual(conf.get_list("s", "k"), [])
conf.set("s", "k", "1 2 3 4 5 6")
self.assertEqual(conf.get_list("s", "k"), ["1", "2", "3", "4", "5", "6"])
conf.set("s", "k", "one two three")
self.assertEqual(conf.get_list("s", "k"), ["one", "two", "three"])
示例4: test_get_boolean
# 需要导入模块: from galicaster.core.conf import Conf [as 别名]
# 或者: from galicaster.core.conf.Conf import set [as 别名]
def test_get_boolean(self):
conf = Conf()
for yes in ["True", "true", "yes", "si", "y", "OK", "Y", "TRUE"]:
conf.set("s", "k", yes)
self.assertTrue(conf.get_boolean("s", "k"), "Check if {0} is True".format(yes))
for no in ["None", "not", "False", "no", "n"]:
conf.set("s", "k", no)
self.assertFalse(conf.get_boolean("s", "k"), "Check if {0} is False".format(no))
示例5: __get_dependencies
# 需要导入模块: from galicaster.core.conf import Conf [as 别名]
# 或者: from galicaster.core.conf.Conf import set [as 别名]
def __get_dependencies(self):
dispatcher = context.get_dispatcher()
repo = Repository(self.tmppath)
worker = self.WorkerMock()
conf = Conf()
conf.set("allows", "overlap", "False")
logger = Logger(None)
return dispatcher, repo, worker, conf, logger
示例6: test_get_hostname
# 需要导入模块: from galicaster.core.conf import Conf [as 别名]
# 或者: from galicaster.core.conf.Conf import set [as 别名]
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')
示例7: test_get_boolean_int_lower
# 需要导入模块: from galicaster.core.conf import Conf [as 别名]
# 或者: from galicaster.core.conf.Conf import set [as 别名]
def test_get_boolean_int_lower(self):
conf = Conf()
for yes in ['True', 'true', 'yes', 'si', 'y', 'OK', 'Y', 'TRUE']:
conf.set('s', 'k', yes)
self.assertTrue(conf.get_boolean('s', 'k'), 'Check if {0} is True'.format(yes))
for no in ['None', 'not', 'False', 'no', 'n']:
conf.set('s', 'k', no)
self.assertFalse(conf.get_boolean('s', 'k'), 'Check if {0} is False'.format(no))
for lower in ['RUBENRUA', 'RubenRua', 'RubenruA', 'rubenrua']:
conf.set('s', 'k', lower)
self.assertEqual(conf.get_lower('s', 'k'), 'rubenrua')
self.assertEqual(conf.get_lower('s', 'k_not_exists'), None)
conf.set('s', 'k', '10')
self.assertEqual(conf.get_int('s', 'k'), 10)
示例8: test_get_boolean_int_lower
# 需要导入模块: from galicaster.core.conf import Conf [as 别名]
# 或者: from galicaster.core.conf.Conf import set [as 别名]
def test_get_boolean_int_lower(self):
conf = Conf()
for yes in ["True", "true", "yes", "si", "y", "OK", "Y", "TRUE"]:
conf.set("s", "k", yes)
self.assertTrue(conf.get_boolean("s", "k"), "Check if {0} is True".format(yes))
for no in ["None", "not", "False", "no", "n"]:
conf.set("s", "k", no)
self.assertFalse(conf.get_boolean("s", "k"), "Check if {0} is False".format(no))
for lower in ["RUBENRUA", "RubenRua", "RubenruA", "rubenrua"]:
conf.set("s", "k", lower)
self.assertEqual(conf.get_lower("s", "k"), "rubenrua")
self.assertEqual(conf.get_lower("s", "k_not_exists"), None)
conf.set("s", "k", "10")
self.assertEqual(conf.get_int("s", "k"), 10)
示例9: test_get_dict
# 需要导入模块: from galicaster.core.conf import Conf [as 别名]
# 或者: from galicaster.core.conf.Conf import set [as 别名]
def test_get_dict(self):
conf = Conf()
self.assertEqual(conf.get_dict("s", "k"), {})
conf.set("s", "k", "k1:v1;k2:v2;k3:v3")
self.assertEqual(conf.get_dict("s", "k"), {"k1": "v1", "k2": "v2", "k3": "v3"})
示例10: TestFunctions
# 需要导入模块: from galicaster.core.conf import Conf [as 别名]
# 或者: from galicaster.core.conf.Conf import set [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')
#.........这里部分代码省略.........
示例11: test_get_int
# 需要导入模块: from galicaster.core.conf import Conf [as 别名]
# 或者: from galicaster.core.conf.Conf import set [as 别名]
def test_get_int(self):
conf = Conf()
conf.set('s', 'k', '10')
self.assertEqual(conf.get_int('s', 'k'), 10)
示例12: TestFunctional
# 需要导入模块: from galicaster.core.conf import Conf [as 别名]
# 或者: from galicaster.core.conf.Conf import set [as 别名]
class TestFunctional(TestCase):
def setUp(self):
""" Set up clear conf with a custom logger and repository folder.
"""
self.conf_path = '/etc/galicaster/conf.ini'
identifier = self.id().split('.')
identifier.reverse()
test_number = re.sub('\D','',identifier[0])
self.test_path = '/tmp/test{}'.format(test_number)
if os.path.exists(self.conf_path) and not os.path.exists('{}.old'.format(self.conf_path)):
os.rename(self.conf_path,'{}.old'.format(self.conf_path))
shutil.copyfile(get_resource('conf/functional_test.ini'),'/etc/galicaster/conf.ini')
if not os.path.exists(self.test_path):
os.makedirs('{}/logs/'.format(self.test_path))
self.conf = Conf()
self.conf.set('basic','repository','{}/Repository'.format(self.test_path))
self.conf.set('logger','path','{}/logs/galicaster.log'.format(self.test_path))
self.conf.update()
config.load({'logDir':'{}/logs/'.format(self.test_path)})
from . import recording
def tearDown(self):
os.rename(self.conf_path,'{}/conf.ini'.format(self.test_path))
if os.path.exists('{}.old'.format(self.conf_path)):
os.rename('{}.old'.format(self.conf_path),self.conf_path)
recording.quit()
del self.conf
def test_136(self):
""" Do 15 recordings of 10 minutes of duration
with automatic ingest to Opencast
"""
self.conf.set('ingest','manual','immediately')
self.conf.set('ingest','active','true')
self.conf.update()
recording.start_galicaster()
recording.rec(10*60, 15)
def test_137(self):
""" Check nightly ingest while recording is paused
"""
self.conf.set('ingest','manual','nightly')
self.conf.set('ingest','active','true')
night = datetime.datetime.now() + datetime.timedelta(minutes=1)
self.conf.set('heartbeat','night',night.strftime('%H:%M'))
self.conf.update()
recording.start_galicaster()
recording.rec(5)
recording.go_to_recorder()
recording.start_recording()
recording.pause_recording()
remaining_sleep = night - datetime.datetime.now()
time.sleep(remaining_sleep.seconds)
recording.rewind_recording()
recording.stop_recording()
recording.go_to_distrib()
示例13: TestFunctions
# 需要导入模块: from galicaster.core.conf import Conf [as 别名]
# 或者: from galicaster.core.conf.Conf import set [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')
#.........这里部分代码省略.........
示例14: TestFunctions
# 需要导入模块: from galicaster.core.conf import Conf [as 别名]
# 或者: from galicaster.core.conf.Conf import set [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"]
#.........这里部分代码省略.........