Commit 63be874a authored by Fabien Amarger's avatar Fabien Amarger
Browse files

fix(db-init) run db-init after sed the sources file

By the way use proper way to define env var
parent 2001187eb813
......@@ -184,8 +184,8 @@
return schema, entitytype_fragment_to_uri, relationtype_fragment_to_uri
def run_and_print_if_error(command):
res = subprocess.run(command, shell=True, capture_output=True)
def run_and_print_if_error(command, custom_env=None):
res = subprocess.run(command, shell=True, capture_output=True, env=custom_env)
if res.returncode != 0:
print(res.stdout.decode())
print(res.stderr.decode())
......@@ -286,4 +286,6 @@
f"creating the instance {args.instance_name}. "
f"The parameters are in ~/etc/cubicweb.d/{args.instance_name}/"
)
if "CW_DB_DRIVER" not in os.environ:
os.environ["CW_DB_DRIVER"] = "sqlite"
create_instance = (
......@@ -289,4 +291,4 @@
create_instance = (
"CW_DB_DRIVER=sqlite cubicweb-ctl create "
"cubicweb-ctl create "
f"{args.instance_name} {args.instance_name} -a --no-db-create"
)
......@@ -291,12 +293,6 @@
f"{args.instance_name} {args.instance_name} -a --no-db-create"
)
run_and_print_if_error(create_instance)
db_init = (
"CW_DB_DRIVER=sqlite cubicweb-ctl db-create "
f"{args.instance_name} -a --drop=y"
)
run_and_print_if_error(db_init)
run_and_print_if_error(create_instance, custom_env=os.environ)
source_path = os.path.expanduser(f"~/etc/cubicweb.d/{args.instance_name}/sources")
# The source file has to be modified to include sqlite
......@@ -310,6 +306,9 @@
with open(source_path, "w") as f:
f.write(replaced_content)
db_init = "cubicweb-ctl db-create " f"{args.instance_name} -a --drop=y"
run_and_print_if_error(db_init, custom_env=os.environ)
print(
"Congratulation ! You can run your instance with : "
f"`cubicweb-ctl pyramid -D -l info {args.instance_name}`"
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment