Display better error message when database is not initialized
When trying to start cubicweb on an empty database I get the following tracebacks :
Traceback (most recent call last):
File "/usr/local/lib/python3.7/dist-packages/logilab/common/decorators.py", line 104, in __call__
return _cache[args]
KeyError: (False,)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/bin/cubicweb-ctl", line 8, in <module>
sys.exit(run())
File "/usr/local/lib/python3.7/dist-packages/cubicweb/cwctl.py", line 965, in run
CWCTL.run(args)
File "/usr/local/lib/python3.7/dist-packages/logilab/common/clcommands.py", line 149, in run
sys.exit(command.main_run(args, rcfile))
File "/usr/local/lib/python3.7/dist-packages/logilab/common/clcommands.py", line 290, in main_run
self.run(args)
File "/usr/local/lib/python3.7/dist-packages/cubicweb/web/webctl.py", line 153, in run
self.generate_static_dir(config, dest)
File "/usr/local/lib/python3.7/dist-packages/cubicweb/web/webctl.py", line 92, in generate_static_dir
for datadir in self._datadirs(config, repo=repo):
File "/usr/local/lib/python3.7/dist-packages/cubicweb/web/webctl.py", line 116, in _datadirs
repo = config.repository()
File "/usr/local/lib/python3.7/dist-packages/cubicweb/cwconfig.py", line 1149, in repository
repo.bootstrap()
File "/usr/local/lib/python3.7/dist-packages/cubicweb/server/repository.py", line 430, in bootstrap
config.init_cubes(self.get_cubes())
File "/usr/local/lib/python3.7/dist-packages/cubicweb/server/repository.py", line 743, in get_cubes
or self.config.mode == "test"
File "/usr/local/lib/python3.7/dist-packages/logilab/common/decorators.py", line 76, in wrapped
return self.__call__(*args, **kwargs)
File "/usr/local/lib/python3.7/dist-packages/logilab/common/decorators.py", line 106, in __call__
_cache[args] = __me.callable(self, *args)
File "/usr/local/lib/python3.7/dist-packages/cubicweb/server/repository.py", line 772, in get_versions
build_descr=False,
File "/usr/local/lib/python3.7/dist-packages/cubicweb/server/session.py", line 157, in check_open
return func(cnx, *args, **kwargs)
File "/usr/local/lib/python3.7/dist-packages/cubicweb/server/session.py", line 673, in execute
rset = self._execute(self, rql, kwargs, build_descr)
File "/usr/local/lib/python3.7/dist-packages/cubicweb/server/querier.py", line 601, in execute
results = plan.execute()
File "/usr/local/lib/python3.7/dist-packages/cubicweb/server/querier.py", line 217, in execute
result = step.execute()
File "/usr/local/lib/python3.7/dist-packages/cubicweb/server/ssplanner.py", line 380, in execute
rql_query_tracing_token=self.rql_query_tracing_token,
File "/usr/local/lib/python3.7/dist-packages/cubicweb/server/sources/native.py", line 591, in syntax_tree_search
sql, args, rql_query_tracing_token=rql_query_tracing_token
File "/usr/local/lib/python3.7/dist-packages/cubicweb/server/session.py", line 157, in check_open
return func(cnx, *args, **kwargs)
File "/usr/local/lib/python3.7/dist-packages/cubicweb/server/session.py", line 812, in system_sql
rql_query_tracing_token=rql_query_tracing_token,
File "/usr/local/lib/python3.7/dist-packages/cubicweb/server/sources/native.py", line 812, in doexec
cursor.execute(str(query), args)
psycopg2.errors.UndefinedTable: when doing the query 'SELECT _P.cw_pkey, _P.cw_value
FROM cw_CWProperty AS _P
WHERE _P.cw_pkey ILIKE %(140673472244712)s' with the args '{'140673472244712': 'system.version.%'}' got the error 'relation "cw_cwproperty" does not exist
LINE 2: FROM cw_CWProperty AS _P
Maybe we could catch this and suggest to the user that the database is empty, or broken or missing this information or another.