[IMP] core: rename upgrades-paths to upgrade-path
Since this option is soon to be used, this rename is a last tweek to make it more logical to use since it will point to a single upgrade dir most of the time. closes odoo/odoo#44593 X-original-commit: 1c8e2809fb296abce6114b7da906d48a240df418 Signed-off-by: Xavier Dollé (xdo) <xdo@odoo.com>
This commit is contained in:
committed by
Christophe Simonis
parent
39018e7515
commit
9c26d4d870
+1
-1
@@ -106,7 +106,7 @@ def registry(database_name=None):
|
||||
#----------------------------------------------------------
|
||||
# Imports
|
||||
#----------------------------------------------------------
|
||||
from . import upgrades # this namespace must be imported first
|
||||
from . import upgrade # this namespace must be imported first
|
||||
from . import addons
|
||||
from . import conf
|
||||
from . import loglevels
|
||||
|
||||
+2
-2
@@ -60,8 +60,8 @@ def report_configuration():
|
||||
if os.path.isfile(config.rcfile):
|
||||
_logger.info("Using configuration file at " + config.rcfile)
|
||||
_logger.info('addons paths: %s', odoo.addons.__path__)
|
||||
if config.get('upgrades_paths'):
|
||||
_logger.info('upgrades path: %s', config['upgrades_paths'])
|
||||
if config.get('upgrade_path'):
|
||||
_logger.info('upgrade path: %s', config['upgrade_path'])
|
||||
host = config['db_host'] or os.environ.get('PGHOST', 'default')
|
||||
port = config['db_port'] or os.environ.get('PGPORT', 'default')
|
||||
user = config['db_user'] or os.environ.get('PGUSER', 'default')
|
||||
|
||||
@@ -12,7 +12,7 @@ from os.path import join as opj
|
||||
|
||||
from odoo.modules.module import get_resource_path
|
||||
import odoo.release as release
|
||||
import odoo.upgrades
|
||||
import odoo.upgrade
|
||||
from odoo.tools.parse_version import parse_version
|
||||
|
||||
_logger = logging.getLogger(__name__)
|
||||
@@ -62,8 +62,8 @@ class MigrationManager(object):
|
||||
self._get_files()
|
||||
|
||||
def _get_files(self):
|
||||
def _get_upgrades_paths(pkg):
|
||||
for path in odoo.upgrades.__path__:
|
||||
def _get_upgrade_path(pkg):
|
||||
for path in odoo.upgrade.__path__:
|
||||
upgrade_path = opj(path, pkg)
|
||||
if os.path.exists(upgrade_path):
|
||||
return upgrade_path
|
||||
@@ -86,7 +86,7 @@ class MigrationManager(object):
|
||||
self.migrations[pkg.name] = {
|
||||
'module': get_scripts(get_resource_path(pkg.name, 'migrations')),
|
||||
'module_upgrades': get_scripts(get_resource_path(pkg.name, 'upgrades')),
|
||||
'upgrades': get_scripts(_get_upgrades_paths(pkg.name)),
|
||||
'upgrade': get_scripts(_get_upgrade_path(pkg.name)),
|
||||
}
|
||||
|
||||
def migrate_module(self, pkg, stage):
|
||||
@@ -133,9 +133,9 @@ class MigrationManager(object):
|
||||
'module_upgrades': opj(pkg.name, 'upgrades'),
|
||||
}
|
||||
|
||||
for path in odoo.upgrades.__path__:
|
||||
for path in odoo.upgrade.__path__:
|
||||
if os.path.exists(opj(path, pkg.name)):
|
||||
mapping['upgrades'] = opj(path, pkg.name)
|
||||
mapping['upgrade'] = opj(path, pkg.name)
|
||||
break
|
||||
|
||||
for x in mapping:
|
||||
|
||||
+11
-11
@@ -55,24 +55,24 @@ def initialize_sys_path():
|
||||
if base_path not in odoo.addons.__path__ and os.path.isdir(base_path):
|
||||
odoo.addons.__path__.append(base_path)
|
||||
|
||||
# hook odoo.upgrades on upgrades paths
|
||||
from odoo import upgrades
|
||||
for up in tools.config['upgrades_paths'].split(','):
|
||||
# hook odoo.upgrade on upgrade-path
|
||||
from odoo import upgrade
|
||||
for up in tools.config['upgrade_path'].split(','):
|
||||
up = os.path.normcase(os.path.abspath(tools.ustr(up.strip())))
|
||||
if up not in upgrades.__path__:
|
||||
upgrades.__path__.append(up)
|
||||
if up not in upgrade.__path__:
|
||||
upgrade.__path__.append(up)
|
||||
|
||||
# hook odoo.upgrades on legacy odoo/addons/base/maintenance/migrations symlink
|
||||
if not tools.config['upgrades_paths']:
|
||||
upgrades.__path__.append(os.path.join(
|
||||
# hook odoo.upgrade on legacy odoo/addons/base/maintenance/migrations symlink
|
||||
if not tools.config['upgrade_path']:
|
||||
upgrade.__path__.append(os.path.join(
|
||||
base_path, 'base', 'maintenance', 'migrations'))
|
||||
|
||||
# create decrecated module alias from odoo.addons.base.maintenance.migrations to odoo.upgrades
|
||||
# create decrecated module alias from odoo.addons.base.maintenance.migrations to odoo.upgrade
|
||||
spec = importlib.machinery.ModuleSpec("odoo.addons.base.maintenance", None, is_package=True)
|
||||
maintenance_pkg = importlib.util.module_from_spec(spec)
|
||||
maintenance_pkg.migrations = upgrades
|
||||
maintenance_pkg.migrations = upgrade
|
||||
sys.modules["odoo.addons.base.maintenance"] = maintenance_pkg
|
||||
sys.modules["odoo.addons.base.maintenance.migrations"] = upgrades
|
||||
sys.modules["odoo.addons.base.maintenance.migrations"] = upgrade
|
||||
|
||||
def get_module_path(module, downloaded=False, display_warning=True):
|
||||
"""Return the path of the given module.
|
||||
|
||||
+12
-12
@@ -120,9 +120,9 @@ class configmanager(object):
|
||||
group.add_option("--addons-path", dest="addons_path",
|
||||
help="specify additional addons paths (separated by commas).",
|
||||
action="callback", callback=self._check_addons_path, nargs=1, type="string")
|
||||
group.add_option("--upgrades-paths", dest="upgrades_paths",
|
||||
help="specify an additional upgrades path.",
|
||||
action="callback", callback=self._check_upgrades_paths, nargs=1, type="string")
|
||||
group.add_option("--upgrade-path", dest="upgrade_path",
|
||||
help="specify an additional upgrade path.",
|
||||
action="callback", callback=self._check_upgrade_path, nargs=1, type="string")
|
||||
group.add_option("--load", dest="server_wide_modules", help="Comma-separated list of server-wide modules.", my_default='base,web')
|
||||
|
||||
group.add_option("-D", "--data-dir", dest="data_dir", my_default=_get_default_datadir(),
|
||||
@@ -425,7 +425,7 @@ class configmanager(object):
|
||||
'db_name', 'db_user', 'db_password', 'db_host', 'db_sslmode',
|
||||
'db_port', 'db_template', 'logfile', 'pidfile', 'smtp_port',
|
||||
'email_from', 'smtp_server', 'smtp_user', 'smtp_password',
|
||||
'db_maxconn', 'import_partial', 'addons_path', 'upgrades_paths',
|
||||
'db_maxconn', 'import_partial', 'addons_path', 'upgrade_path',
|
||||
'syslog', 'without_demo', 'screencasts', 'screenshots',
|
||||
'dbfilter', 'log_level', 'log_db',
|
||||
'log_db_level', 'geoip_database', 'dev_mode', 'shell_interface'
|
||||
@@ -490,10 +490,10 @@ class configmanager(object):
|
||||
self._normalize(x)
|
||||
for x in self.options['addons_path'].split(','))
|
||||
|
||||
self.options["upgrades_paths"] = (
|
||||
self.options["upgrade_path"] = (
|
||||
",".join(self._normalize(x)
|
||||
for x in self.options['upgrades_paths'].split(','))
|
||||
if self.options['upgrades_paths']
|
||||
for x in self.options['upgrade_path'].split(','))
|
||||
if self.options['upgrade_path']
|
||||
else ""
|
||||
)
|
||||
|
||||
@@ -553,8 +553,8 @@ class configmanager(object):
|
||||
|
||||
setattr(parser.values, option.dest, ",".join(ad_paths))
|
||||
|
||||
def _check_upgrades_paths(self, option, opt, value, parser):
|
||||
upgrades_paths = []
|
||||
def _check_upgrade_path(self, option, opt, value, parser):
|
||||
upgrade_path = []
|
||||
for path in value.split(','):
|
||||
path = path.strip()
|
||||
res = self._normalize(path)
|
||||
@@ -562,9 +562,9 @@ class configmanager(object):
|
||||
raise optparse.OptionValueError("option %s: no such directory: %r" % (opt, path))
|
||||
if not self._is_upgrades_path(res):
|
||||
raise optparse.OptionValueError("option %s: the path %r is not a valid upgrade directory" % (opt, path))
|
||||
if res not in upgrades_paths:
|
||||
upgrades_paths.append(res)
|
||||
setattr(parser.values, option.dest, ",".join(upgrades_paths))
|
||||
if res not in upgrade_path:
|
||||
upgrade_path.append(res)
|
||||
setattr(parser.values, option.dest, ",".join(upgrade_path))
|
||||
|
||||
def _is_upgrades_path(self, res):
|
||||
return any(
|
||||
|
||||
Reference in New Issue
Block a user