2024-08-26 14:55:36 -04:00
|
|
|
#!/usr/bin/env python
|
|
|
|
|
# © 2021-2024 TechnoLibre (http://www.technolibre.ca)
|
|
|
|
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl)
|
2020-05-31 09:29:29 -04:00
|
|
|
|
|
|
|
|
import argparse
|
|
|
|
|
|
|
|
|
|
from os import listdir
|
|
|
|
|
from os.path import isdir, join, abspath
|
|
|
|
|
|
|
|
|
|
import configparser
|
|
|
|
|
|
|
|
|
|
parser = argparse.ArgumentParser(prog='Configure base dir for all addons')
|
|
|
|
|
|
2020-08-01 14:17:39 -04:00
|
|
|
parser.add_argument("addonsBaseDir", help="Path where addons are cloned.")
|
|
|
|
|
parser.add_argument("srcConfigPath",
|
|
|
|
|
help="Path where we retrieve source config file to adapt with new "
|
|
|
|
|
"addons path.")
|
|
|
|
|
parser.add_argument("dstConfigPath", help="Path to save adapted configuration.")
|
2020-05-31 09:29:29 -04:00
|
|
|
|
|
|
|
|
args = parser.parse_args()
|
|
|
|
|
addonsBaseDir = args.addonsBaseDir
|
|
|
|
|
srcConfigPath = args.srcConfigPath
|
|
|
|
|
dstConfigPath = args.dstConfigPath
|
|
|
|
|
|
2020-08-01 14:17:39 -04:00
|
|
|
addonsDirs = [abspath(join(addonsBaseDir, f)) for f in listdir(addonsBaseDir) if
|
|
|
|
|
isdir(join(addonsBaseDir, f))]
|
2020-05-31 09:29:29 -04:00
|
|
|
|
|
|
|
|
# addonsDirs.insert(0, "/usr/lib/python3/dist-packages/odoo/addons/")
|
2023-07-07 01:31:03 -04:00
|
|
|
addonsDirs.insert(0, "/ERPLibre/addons/addons")
|
2020-05-31 09:29:29 -04:00
|
|
|
addonsDirs.insert(0, "/ERPLibre/odoo/addons/")
|
|
|
|
|
|
|
|
|
|
config = configparser.ConfigParser()
|
|
|
|
|
|
|
|
|
|
config.read(srcConfigPath)
|
|
|
|
|
|
|
|
|
|
separator = ","
|
|
|
|
|
|
|
|
|
|
config.set('options', 'addons_path', separator.join(addonsDirs))
|
|
|
|
|
|
2020-08-01 14:17:39 -04:00
|
|
|
print(config.get('options', 'addons_path'))
|
2020-05-31 09:29:29 -04:00
|
|
|
|
|
|
|
|
with open(dstConfigPath, 'w') as configfile:
|
|
|
|
|
config.write(configfile)
|