From 472291b35cd94d0847d2ce4cb880be0fa979e927 Mon Sep 17 00:00:00 2001 From: Christophe Simonis Date: Mon, 6 May 2013 12:30:54 +0200 Subject: [PATCH 1/2] [FIX] When using "--stop-after-init", set the return code correctly. A non zero return code reflect the number of databases that fail to load/update Backport of 2c4e370b766db6280d38a4d3535e07de604b1922 and 33ce0e73dba7c23d004a278f61943be8052e7f37 --- openerp/cli/server.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/openerp/cli/server.py b/openerp/cli/server.py index ec5516a4786..d7e7ca73469 100644 --- a/openerp/cli/server.py +++ b/openerp/cli/server.py @@ -97,6 +97,8 @@ def preload_registry(dbname): db, registry = openerp.pooler.get_db_and_pool(dbname,update_module=update_module) except Exception: _logger.exception('Failed to initialize database `%s`.', dbname) + return False + return registry._assertion_report.failures == 0 def run_test_file(dbname, test_file): """ Preload a registry, possibly run a test file, and start the cron.""" @@ -257,12 +259,14 @@ def main(args): else: openerp.service.start_services() + rc = 0 if config['db_name']: for dbname in config['db_name'].split(','): - preload_registry(dbname) + if not preload_registry(dbname): + rc += 1 if config["stop_after_init"]: - sys.exit(0) + sys.exit(rc) _logger.info('OpenERP server is running, waiting for connections...') quit_on_signals() From d2fd05ef21173060a74958514860a9981428ec3d Mon Sep 17 00:00:00 2001 From: Samus CTO Date: Wed, 22 Oct 2014 11:40:09 +0200 Subject: [PATCH 2/2] [IMP] config: Test that the config file is readable Fixes #3237 cherry-pick of 8e72049 --- openerp/tools/config.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openerp/tools/config.py b/openerp/tools/config.py index 3e7fc331e2c..4b3ba6909f6 100644 --- a/openerp/tools/config.py +++ b/openerp/tools/config.py @@ -350,8 +350,8 @@ class configmanager(object): "the i18n-export option cannot be used without the database (-d) option") # Check if the config file exists (-c used, but not -s) - die(not opt.save and opt.config and not os.path.exists(opt.config), - "The config file '%s' selected with -c/--config doesn't exist, "\ + die(not opt.save and opt.config and not os.access(opt.config, os.R_OK), + "The config file '%s' selected with -c/--config doesn't exist or is not readable, "\ "use -s/--save if you want to generate it"% opt.config) # place/search the config file on Win32 near the server installation