ConfigParser.NoSectionError:没有部分:'选项'

时间:2016-09-23 09:00:23

标签: python-2.7 config odoo-8 configparser

我尝试读取odoo 8的配置文件,但收到此错误:

我的配置文件如下:

[options]
#This is the password that allows database operations:
admin_passwd = admin
db_host = False
db_port = False
db_user = kabeer
db_password = password
addons_path = /OdooSass/odoo-8.0-20151229/openerp/addons

我的代码如下:

def get_odoo_config():
res = {}
if not args.get('odoo_config'):
    return res
p = ConfigParser.ConfigParser()

log('Read odoo config', args.get('odoo_config'))
p.read(args.get('odoo_config'))

for (name, value) in p.items('options'):
    if value == 'True' or value == 'true':
        value = True
    if value == 'False' or value == 'false':
        value = False
    res[name] = value
return res

错误是:

Traceback (most recent call last):
File "saas.py", line 118, in <module>
odoo_config = get_odoo_config()
File "saas.py", line 110, in get_odoo_config
for (name, value) in p.items('options'):
File "/usr/lib/python2.7/ConfigParser.py", line 642, in items
raise NoSectionError(section)
ConfigParser.NoSectionError: No section: 'options'

如何解决此错误?

0 个答案:

没有答案