本文整理汇总了Python中iniparse.ConfigParser.read方法的典型用法代码示例。如果您正苦于以下问题:Python ConfigParser.read方法的具体用法?Python ConfigParser.read怎么用?Python ConfigParser.read使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类iniparse.ConfigParser
的用法示例。
在下文中一共展示了ConfigParser.read方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: post
# 需要导入模块: from iniparse import ConfigParser [as 别名]
# 或者: from iniparse.ConfigParser import read [as 别名]
def post(self, command, output_dir, vars):
common.Template.post(self, command, output_dir, vars)
#etc = os.path.join(vars['path'], 'etc', 'plone')
#if not os.path.isdir(etc):
# os.makedirs(etc)
cfg = os.path.join(vars['path'], 'etc', 'base.cfg')
dst = os.path.join(vars['path'],
'etc', 'plone', 'plone%s.buildout.cfg' % vars['major'])
vdst = os.path.join(vars['path'],
'etc', 'plone', 'plone%s.versions.cfg' % vars['major'])
sdst = os.path.join(vars['path'],
'etc', 'plone', 'plone%s.sources.cfg' % vars['major'])
ztkdst = os.path.join(vars['path'], 'etc', 'plone', 'ztk.versions.cfg')
zaztkdst = os.path.join(vars['path'], 'etc', 'plone', 'zopeapp.versions.cfg')
zdst = os.path.join(vars['path'],
'etc', 'plone', 'zope2.versions.cfg')
os.rename(os.path.join(vars['path'], 'gitignore'),
os.path.join(vars['path'], '.gitignore'))
bc = ConfigParser()
bc.read(cfg)
for f in (glob(os.path.join(output_dir, 'scripts/*'))
+ glob(os.path.join(output_dir, 'etc/hudson/%s/build/*' % vars['project']))
):
os.chmod(f, 0700)
# release KGS
#try:
# open(vdst, 'w').write(
# urllib2.urlopen(vars['versions_url']).read()
# )
#except Exception, e:
suffix = vars['major']
if vars['major'] > 3:
suffix = self.name.replace('minitage.plone', '')
示例2: read_ini_file
# 需要导入模块: from iniparse import ConfigParser [as 别名]
# 或者: from iniparse.ConfigParser import read [as 别名]
def read_ini_file(self,filename):
cp = ConfigParser()
cp.read(filename)
if not self.backup_base_dir:
self.backup_base_dir = cp.get('global','backup_base_dir')
if not os.path.isdir(self.backup_base_dir):
self.logger.info('Creating backup directory %s' % self.backup_base_dir)
os.makedirs(self.backup_base_dir)
self.logger.debug("backup directory : " + self.backup_base_dir)
self.dbstat = BackupStat(os.path.join(self.backup_base_dir,'log','tisbackup.sqlite'))
for section in cp.sections():
if (section != 'global'):
self.logger.debug("reading backup config " + section)
backup_item = None
type = cp.get(section,'type')
backup_item = backup_drivers[type](backup_name=section,
backup_dir=os.path.join(self.backup_base_dir,section),dbstat=self.dbstat,dry_run=self.dry_run)
backup_item.read_config(cp)
backup_item.verbose = self.verbose
self.backup_list.append(backup_item)
示例3: checkSSLvdsm
# 需要导入模块: from iniparse import ConfigParser [as 别名]
# 或者: from iniparse.ConfigParser import read [as 别名]
def checkSSLvdsm(self):
"""check if vdsm is running as SSL or without it"""
cfg = ConfigParser()
cfg.read('/etc/vdsm/vdsm.conf')
cfg.get('vars', 'ssl')
return cfg.data.vars.ssl
示例4: write
# 需要导入模块: from iniparse import ConfigParser [as 别名]
# 或者: from iniparse.ConfigParser import read [as 别名]
def write(self,
path=None,
dependencies = None,
src_uri = None,
description = None,
install_method = None,
src_type = None,
url = None,
revision = None,
category = None,
src_opts = None,
src_md5 = None,
python = None,
scm_branch = None,
):
"""Store/Update the minibuild config
"""
to_write = OrderedDict(
[('dependencies', dependencies),
('src_uri', src_uri),
('install_method', install_method),
('src_type', src_type),
('revision', revision),
('category', category),
('description', description),
('src_md5', src_md5),
('url', url),
('src_opts', src_opts),
('python', python),
('scm_branch', scm_branch),]
)
# open config
if not path:
path = self.path
shutil.copy2(path, path+'.sav')
wconfig = WritableConfigParser()
wconfig.read(path)
for metadata in to_write:
value = to_write[metadata]
if isinstance(value, list):
if len(value) < 1:
value = None
else:
value = ' '.join(value)
if value is not None:
wconfig.set('minibuild' , metadata, value)
# write back cofig
fic = open(path, 'w')
wconfig.write(fic)
fic.flush()
fic.close()
newline(path)
# reload minibuild
self.load()
示例5: parseDesktopFile
# 需要导入模块: from iniparse import ConfigParser [as 别名]
# 或者: from iniparse.ConfigParser import read [as 别名]
def parseDesktopFile(self):
"""
Getting all necessary data from *.dektop file of the app
"""
cmd = 'ls -d /usr/share/applications/* | grep ".*%s.desktop"' % self.desktopFileName
proc = Popen(cmd, shell=True, stdout=PIPE)
# !HAVE TO check if the command and its desktop file exist
if proc.wait() != 0:
raise Exception("*.desktop file of the app not found")
output = proc.communicate()[0].rstrip()
desktopConfig = ConfigParser()
desktopConfig.read(output)
return desktopConfig
示例6: config
# 需要导入模块: from iniparse import ConfigParser [as 别名]
# 或者: from iniparse.ConfigParser import read [as 别名]
def config(cfgname, inisect):
cfg = { }
cfgpr = ConfigParser()
try:
cfgpr.read(cfgname)
cfg["sleep"] = cfgpr.get(inisect, "sleep")
cfg["s3host"] = cfgpr.get(inisect, "s3host")
cfg["s3user"] = cfgpr.get(inisect, "s3user")
cfg["s3pass"] = cfgpr.get(inisect, "s3pass")
cfg["bucket"] = cfgpr.get(inisect, "s3bucket")
cfg["prefix"] = cfgpr.get(inisect, "prefix")
maxsize = cfgpr.get(inisect, "maxsize")
#expire = cfgpr.get(inisect, "expire")
except NoSectionError:
# Unfortunately if the file does not exist, we end here.
raise ConfigError("Unable to open or find section " + inisect)
except NoOptionError, e:
raise ConfigError(str(e))
示例7: _apply
# 需要导入模块: from iniparse import ConfigParser [as 别名]
# 或者: from iniparse.ConfigParser import read [as 别名]
def _apply():
debug('Write ini settings to %s' % filename)
debug(config)
cfg = ConfigParser()
cfg.read(filename)
for section, values in config.items():
if not cfg.has_section(section):
if strict_sections:
raise Exception('No section %s in ini file %s' % (section, filename))
else:
cfg.add_section(section)
for key, val in values.items():
cfg.set(section, key, val)
with open(filename, 'w') as configfile:
cfg.write(configfile)
event(on_apply)
示例8: startService
# 需要导入模块: from iniparse import ConfigParser [as 别名]
# 或者: from iniparse.ConfigParser import read [as 别名]
def startService(self):
cfgpr = ConfigParser()
# TODO: config location from argparse or something
cfgpr.read('config/config.ini')
ip = cfgpr.get('main', 'ip')
port = cfgpr.getint('main', 'port')
tag = cfgpr.get('main', 'tag')
password = cfgpr.get('main', 'password')
server_data = {
'ip': ip,
'port': port,
'tag': tag, # TODO: what is this:
'secret': password, # TODO: refactor how this kind of data is passed and stored in factory
}
factory = getClientRconFactory(server_data)
client = TCPClient(server_data["ip"], server_data["port"], factory)
client.setServiceParent(self)
self.server["factory"] = factory
MultiService.startService(self)
示例9: archive_inv
# 需要导入模块: from iniparse import ConfigParser [as 别名]
# 或者: from iniparse.ConfigParser import read [as 别名]
def archive_inv(gameDir, dummyPath, game='FO3', mode=True):
'''Apply ArchiveInvalidationInvalidated.'''
if mode:
if game == 'NV':
try:
ini = ConfigParser()
ini.read(os.environ['USERPROFILE'] + '\\My Games\\FalloutNV\\Fallout.ini')
ini.set('Archive', 'bInvalidateOlderFiles', '1')
ini.set('Archive', 'SArchiveList', 'Dummy.bsa,' + ini.get('Archive', 'SArchiveList'))
iniFile = open(os.environ['USERPROFILE'] + '\\My Games\\FalloutNV\\Fallout.ini', 'w')
ini.write(iniFile)
bsa = open(dummyPath, 'rb').read()
dummy = open(gameDir + '\\Data\\Dummy.bsa', 'wb')
dummy.write(bsa)
dummy.close()
return True
except IOError:
return False
示例10: _LoadLevelDef
# 需要导入模块: from iniparse import ConfigParser [as 别名]
# 或者: from iniparse.ConfigParser import read [as 别名]
def _LoadLevelDef(filename):
"""Load level definitions from Config/Level/<filename>.ini.
Call LoadLevel(<name>) to actually load all the Actors described in
the file.
If called a second time, it will reload the file, so the definitions
will be updated, but the existing world won't be affected.
"""
path_try = os.path.join("Config", "Level", filename + ".ini")
if not (os.path.exists(path_try)):
raise IOError, "Couldn't find " + path_try
if not hasattr(angel, "_levels"):
angel._levels = {}
angel._levels[filename] = {}
config = ConfigParser()
config.read(path_try)
for section in config.sections():
actor = {}
for item in config.items(section):
actor[item[0]] = item[1]
angel._levels[filename][section] = actor
示例11: test_enabling_yum_plugin_with_wrong_conf
# 需要导入模块: from iniparse import ConfigParser [as 别名]
# 或者: from iniparse.ConfigParser import read [as 别名]
def test_enabling_yum_plugin_with_wrong_conf(self):
"""
Test automatic enabling of configuration files of already plugins with wrong values in conf file.
"""
self.init_yum_plugin_conf_files(conf_string=PKG_PLUGIN_CONF_FILE_WRONG_VALUE)
plugin_list = YumPluginManager.enable_pkg_plugins()
self.assertEqual(len(plugin_list), 2)
for plugin_conf_file_name in YumPluginManager.PLUGINS:
yum_plugin_config = ConfigParser()
result = yum_plugin_config.read(YumPluginManager.YUM_PLUGIN_DIR + '/' + plugin_conf_file_name + '.conf')
self.assertGreater(len(result), 0)
is_plugin_enabled = yum_plugin_config.getint('main', 'enabled')
self.assertEqual(is_plugin_enabled, 1)
self.restore_yum_plugin_conf_files()
示例12: _LoadActorDefs
# 需要导入模块: from iniparse import ConfigParser [as 别名]
# 或者: from iniparse.ConfigParser import read [as 别名]
def _LoadActorDefs(filename):
"""Load actor definitions from Config/ActorDef/<filename>.ini.
Instantiate an Actor from a definition with Actor.Create(<name>)
If called a second time, it will reload the file, so the definitions
will be updated, but any existing Actors that were created from them
remain the same.
"""
path_try = os.path.join("Config", "ActorDef", filename + ".ini")
if not (os.path.exists(path_try)):
raise IOError, "Couldn't find " + path_try
if not hasattr(Actor, "_defs"):
Actor._defs = {}
config = ConfigParser()
config.read(path_try)
for section in config.sections():
definition = {}
for item in config.items(section):
definition[item[0]] = item[1]
if 'class' not in definition:
definition["class"] = "Actor"
Actor._defs[section] = definition
示例13: test_enabling_enabled_yum_plugin_int
# 需要导入模块: from iniparse import ConfigParser [as 别名]
# 或者: from iniparse.ConfigParser import read [as 别名]
def test_enabling_enabled_yum_plugin_int(self):
"""
Test automatic enabling of configuration files of already enabled plugins
"""
self.init_yum_plugin_conf_files(conf_string=PKG_PLUGIN_CONF_FILE_ENABLED_INT)
plugin_list = YumPluginManager.enable_pkg_plugins()
self.assertEqual(len(plugin_list), 0)
for plugin_conf_file_name in YumPluginManager.PLUGINS:
yum_plugin_config = ConfigParser()
result = yum_plugin_config.read(YumPluginManager.YUM_PLUGIN_DIR + '/' + plugin_conf_file_name + '.conf')
self.assertGreater(len(result), 0)
is_plugin_enabled = yum_plugin_config.getint('main', 'enabled')
self.assertEqual(is_plugin_enabled, 1)
self.restore_yum_plugin_conf_files()
示例14: test_not_enabling_disabled_yum_plugin
# 需要导入模块: from iniparse import ConfigParser [as 别名]
# 或者: from iniparse.ConfigParser import read [as 别名]
def test_not_enabling_disabled_yum_plugin(self):
"""
Test not enabling (disabled in rhsm.conf) of configuration files of disabled plugins
"""
self.init_yum_plugin_conf_files(conf_string=PKG_PLUGIN_CONF_FILE_DISABLED_BOOL)
plugin_list = YumPluginManager.enable_pkg_plugins()
self.assertEqual(len(plugin_list), 0)
for plugin_conf_file_name in YumPluginManager.PLUGINS:
yum_plugin_config = ConfigParser()
result = yum_plugin_config.read(YumPluginManager.YUM_PLUGIN_DIR + '/' + plugin_conf_file_name + '.conf')
self.assertGreater(len(result), 0)
is_plugin_enabled = yum_plugin_config.getboolean('main', 'enabled')
self.assertEqual(is_plugin_enabled, False)
self.restore_yum_plugin_conf_files()
示例15: test_enabling_enabled_yum_plugin_bool
# 需要导入模块: from iniparse import ConfigParser [as 别名]
# 或者: from iniparse.ConfigParser import read [as 别名]
def test_enabling_enabled_yum_plugin_bool(self):
"""
Test automatic enabling of configuration files of already enabled plugins
"""
self.init_yum_plugin_conf_files(conf_string=PKG_PLUGIN_CONF_FILE_ENABLED_BOOL)
plugin_list = YumPluginManager.enable_pkg_plugins()
self.assertEqual(len(plugin_list), 0)
for plugin_conf_file_name in YumPluginManager.PLUGINS:
yum_plugin_config = ConfigParser()
result = yum_plugin_config.read(YumPluginManager.YUM_PLUGIN_DIR + '/' + plugin_conf_file_name + '.conf')
self.assertGreater(len(result), 0)
# The file was not modified. We have to read value with with getboolean()
is_plugin_enabled = yum_plugin_config.getboolean('main', 'enabled')
self.assertEqual(is_plugin_enabled, True)
self.restore_yum_plugin_conf_files()