Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
cubicweb
OWL2YAMS
Commits
77d2a5fb710f
Commit
77d2a5fb
authored
Nov 16, 2021
by
Fabien Amarger
Browse files
fix(db-create): Create database into the ~/etc/cubicweb.d folder
parent
f64cf7cc8af1
Pipeline
#94953
passed with stages
in 4 minutes and 2 seconds
Changes
1
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
owl2yams/__init__.py
View file @
77d2a5fb
...
...
@@ -296,6 +296,16 @@
f
"The parameters are in ~/etc/cubicweb.d/
{
args
.
instance_name
}
/"
)
os
.
environ
.
setdefault
(
"CW_DB_DRIVER"
,
"sqlite"
)
os
.
environ
.
setdefault
(
"CW_DB_NAME"
,
str
(
Path
.
home
()
/
"etc"
/
"cubicweb.d"
/
args
.
instance_name
/
f
"
{
args
.
instance_name
}
.sqlite"
),
)
os
.
environ
.
setdefault
(
"CW_ANONYMOUS_USER"
,
"anon"
)
os
.
environ
.
setdefault
(
"CW_ANONYMOUS_PASSWORD"
,
"anon"
)
create_instance
=
(
...
...
@@ -308,6 +318,7 @@
# The source file has to be modified to include sqlite
driver_regexp
=
re
.
compile
(
"db-driver.*"
)
admin_pass
=
re
.
compile
(
"password=(.*)"
)
dbname_regexp
=
re
.
compile
(
"db-name=.*"
)
with
open
(
source_path
,
"r"
)
as
f
:
content
=
f
.
read
()
replaced_content
=
driver_regexp
.
sub
(
"db-driver=sqlite"
,
content
)
...
...
@@ -311,6 +322,9 @@
with
open
(
source_path
,
"r"
)
as
f
:
content
=
f
.
read
()
replaced_content
=
driver_regexp
.
sub
(
"db-driver=sqlite"
,
content
)
replaced_content
=
dbname_regexp
.
sub
(
f
"db-name=
{
os
.
getenv
(
'CW_DB_NAME'
)
}
"
,
replaced_content
)
admin_pwd
=
next
(
admin_pass
.
finditer
(
content
)).
group
(
1
)
with
open
(
source_path
,
"w"
)
as
f
:
...
...
@@ -330,6 +344,11 @@
)
)
create_db_instance
=
(
f
"cubicweb-ctl db-create
{
args
.
instance_name
}
-a --create-db=y --drop=y"
)
run_and_print_if_error
(
create_db_instance
,
custom_env
=
os
.
environ
)
run_and_print_if_error
(
f
"black
{
cube_master_folder
}
"
)
print
(
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment