Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
Odoo scripts
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Container Registry
Operate
Terraform modules
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
XCG
Odoo scripts
Commits
d4a964711550
Commit
d4a964711550
authored
6 years ago
by
Vincent Hatakeyama
Browse files
Options
Downloads
Patches
Plain Diff
use _logger instead of logging (no point in defining it otherwise)
parent
89126f315e06
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
do_tests.py
+4
-4
4 additions, 4 deletions
do_tests.py
docker_dev_start.py
+30
-30
30 additions, 30 deletions
docker_dev_start.py
with
34 additions
and
34 deletions
do_tests.py
+
4
−
4
View file @
d4a96471
...
@@ -170,7 +170,7 @@
...
@@ -170,7 +170,7 @@
c
=
configparser
.
ConfigParser
()
c
=
configparser
.
ConfigParser
()
if
not
os
.
path
.
exists
(
setup_path
):
if
not
os
.
path
.
exists
(
setup_path
):
logg
ing
.
fatal
(
'
Missing %s
'
,
setup_path
)
_
logg
er
.
fatal
(
'
Missing %s
'
,
setup_path
)
return
12
return
12
c
.
read
(
setup_path
)
c
.
read
(
setup_path
)
...
@@ -192,9 +192,9 @@
...
@@ -192,9 +192,9 @@
c
.
has_option
(
'
odoo_scripts
'
,
'
postgresql_version
'
)
and
c
.
has_option
(
'
odoo_scripts
'
,
'
postgresql_version
'
)
and
c
.
get
(
'
odoo_scripts
'
,
'
postgresql_version
'
))
or
'
9.6
'
c
.
get
(
'
odoo_scripts
'
,
'
postgresql_version
'
))
or
'
9.6
'
image
=
"
%s/%s:latest
"
%
(
registry
,
project
)
image
=
"
%s/%s:latest
"
%
(
registry
,
project
)
logg
ing
.
debug
(
"
Docker image: %s
"
,
image
)
_
logg
er
.
debug
(
"
Docker image: %s
"
,
image
)
# read from odoo.conf if it exists
# read from odoo.conf if it exists
sample_conf
=
'
conf/dev/odoo.conf
'
sample_conf
=
'
conf/dev/odoo.conf
'
if
os
.
path
.
exists
(
sample_conf
):
if
os
.
path
.
exists
(
sample_conf
):
...
@@ -196,9 +196,9 @@
...
@@ -196,9 +196,9 @@
# read from odoo.conf if it exists
# read from odoo.conf if it exists
sample_conf
=
'
conf/dev/odoo.conf
'
sample_conf
=
'
conf/dev/odoo.conf
'
if
os
.
path
.
exists
(
sample_conf
):
if
os
.
path
.
exists
(
sample_conf
):
logg
ing
.
info
(
'
Reading from sample configuration %s
'
,
sample_conf
)
_
logg
er
.
info
(
'
Reading from sample configuration %s
'
,
sample_conf
)
c
.
read
(
sample_conf
)
c
.
read
(
sample_conf
)
if
not
odoo_db_user
:
if
not
odoo_db_user
:
if
c
.
has_option
(
'
options
'
,
'
db_user
'
):
if
c
.
has_option
(
'
options
'
,
'
db_user
'
):
...
@@ -220,7 +220,7 @@
...
@@ -220,7 +220,7 @@
):
):
extensions
.
append
(
'
unaccent
'
)
extensions
.
append
(
'
unaccent
'
)
else
:
else
:
logg
ing
.
debug
(
'
No sample configuration %s
'
,
sample_conf
)
_
logg
er
.
debug
(
'
No sample configuration %s
'
,
sample_conf
)
extensions
.
append
(
'
unaccent
'
)
extensions
.
append
(
'
unaccent
'
)
# Do stuff
# Do stuff
...
...
This diff is collapsed.
Click to expand it.
docker_dev_start.py
+
30
−
30
View file @
d4a96471
...
@@ -60,6 +60,6 @@
...
@@ -60,6 +60,6 @@
"""
Run flake8 if found
"""
Run flake8 if found
"""
"""
if
which
(
'
flake8
'
):
if
which
(
'
flake8
'
):
logg
ing
.
info
(
'
Running flake8
'
)
_
logg
er
.
info
(
'
Running flake8
'
)
call
([
'
flake8
'
])
call
([
'
flake8
'
])
else
:
else
:
...
@@ -64,6 +64,6 @@
...
@@ -64,6 +64,6 @@
call
([
'
flake8
'
])
call
([
'
flake8
'
])
else
:
else
:
logg
ing
.
warning
(
'
No flake8 in PATH
'
)
_
logg
er
.
warning
(
'
No flake8 in PATH
'
)
def
main
(
argv
=
None
):
# IGNORE:C0111
def
main
(
argv
=
None
):
# IGNORE:C0111
...
@@ -280,8 +280,8 @@
...
@@ -280,8 +280,8 @@
if
restore_filename
:
if
restore_filename
:
if
not
database
:
if
not
database
:
logg
ing
.
fatal
(
'
No database name given for restore
'
)
_
logg
er
.
fatal
(
'
No database name given for restore
'
)
return
13
return
13
c
=
ConfigParser
()
c
=
ConfigParser
()
if
not
os
.
path
.
exists
(
setup_path
):
if
not
os
.
path
.
exists
(
setup_path
):
...
@@ -284,8 +284,8 @@
...
@@ -284,8 +284,8 @@
return
13
return
13
c
=
ConfigParser
()
c
=
ConfigParser
()
if
not
os
.
path
.
exists
(
setup_path
):
if
not
os
.
path
.
exists
(
setup_path
):
logg
ing
.
fatal
(
'
Missing %s
'
,
setup_path
)
_
logg
er
.
fatal
(
'
Missing %s
'
,
setup_path
)
return
12
return
12
c
.
read
(
setup_path
)
c
.
read
(
setup_path
)
...
@@ -293,7 +293,7 @@
...
@@ -293,7 +293,7 @@
if
c
.
has_option
(
'
odoo_scripts
'
,
'
modules
'
):
if
c
.
has_option
(
'
odoo_scripts
'
,
'
modules
'
):
for
entry
in
c
.
get
(
'
odoo_scripts
'
,
'
modules
'
).
split
():
for
entry
in
c
.
get
(
'
odoo_scripts
'
,
'
modules
'
).
split
():
modules
.
extend
(
glob
.
glob
(
entry
))
modules
.
extend
(
glob
.
glob
(
entry
))
logg
ing
.
debug
(
"
addon modules: %s
"
,
modules
)
_
logg
er
.
debug
(
"
addon modules: %s
"
,
modules
)
registry
=
(
registry
=
(
c
.
has_section
(
'
odoo_scripts
'
)
and
c
.
has_section
(
'
odoo_scripts
'
)
and
...
@@ -312,8 +312,8 @@
...
@@ -312,8 +312,8 @@
c
.
has_section
(
'
odoo_scripts
'
)
and
c
.
has_section
(
'
odoo_scripts
'
)
and
c
.
has_option
(
'
odoo_scripts
'
,
'
postgresql_version
'
)
and
c
.
has_option
(
'
odoo_scripts
'
,
'
postgresql_version
'
)
and
c
.
get
(
'
odoo_scripts
'
,
'
postgresql_version
'
))
or
'
9.6
'
c
.
get
(
'
odoo_scripts
'
,
'
postgresql_version
'
))
or
'
9.6
'
logg
ing
.
debug
(
"
Docker image: %s
"
,
image
)
_
logg
er
.
debug
(
"
Docker image: %s
"
,
image
)
# detect if docker image already exists
# detect if docker image already exists
docker_client
=
docker_api
(
base_url
=
'
unix://var/run/docker.sock
'
)
docker_client
=
docker_api
(
base_url
=
'
unix://var/run/docker.sock
'
)
image_list
=
docker_client
.
images
(
name
=
image
,
quiet
=
True
)
image_list
=
docker_client
.
images
(
name
=
image
,
quiet
=
True
)
if
not
image_list
:
if
not
image_list
:
...
@@ -316,6 +316,6 @@
...
@@ -316,6 +316,6 @@
# detect if docker image already exists
# detect if docker image already exists
docker_client
=
docker_api
(
base_url
=
'
unix://var/run/docker.sock
'
)
docker_client
=
docker_api
(
base_url
=
'
unix://var/run/docker.sock
'
)
image_list
=
docker_client
.
images
(
name
=
image
,
quiet
=
True
)
image_list
=
docker_client
.
images
(
name
=
image
,
quiet
=
True
)
if
not
image_list
:
if
not
image_list
:
logg
ing
.
info
(
"
Image %s does not exist
"
,
image
)
_
logg
er
.
info
(
"
Image %s does not exist
"
,
image
)
else
:
else
:
...
@@ -321,3 +321,3 @@
...
@@ -321,3 +321,3 @@
else
:
else
:
logg
ing
.
info
(
"
Image %s exists
"
,
image
)
_
logg
er
.
info
(
"
Image %s exists
"
,
image
)
if
(
not
image_list
and
not
nmspc
.
no_build
)
or
nmspc
.
force_build
:
if
(
not
image_list
and
not
nmspc
.
no_build
)
or
nmspc
.
force_build
:
...
@@ -323,5 +323,5 @@
...
@@ -323,5 +323,5 @@
if
(
not
image_list
and
not
nmspc
.
no_build
)
or
nmspc
.
force_build
:
if
(
not
image_list
and
not
nmspc
.
no_build
)
or
nmspc
.
force_build
:
logg
ing
.
info
(
"
Building image %s
"
,
image
)
_
logg
er
.
info
(
"
Building image %s
"
,
image
)
import
docker_build
import
docker_build
arguments
=
[
arguments
=
[
'
--dev
'
'
--dev
'
...
@@ -416,7 +416,7 @@
...
@@ -416,7 +416,7 @@
if
addresses
:
if
addresses
:
local_ip
=
addresses
[
0
]
local_ip
=
addresses
[
0
]
except
ImportError
:
except
ImportError
:
logg
ing
.
warn
(
"
Consider installing python netifaces
"
_
logg
er
.
warn
(
"
Consider installing python netifaces
"
"
to ease local IP detection
"
)
"
to ease local IP detection
"
)
if
not
local_ip
:
if
not
local_ip
:
import
socket
import
socket
...
@@ -420,7 +420,7 @@
...
@@ -420,7 +420,7 @@
"
to ease local IP detection
"
)
"
to ease local IP detection
"
)
if
not
local_ip
:
if
not
local_ip
:
import
socket
import
socket
logg
ing
.
info
(
'
Contacting Google Public DNS to find our IP
'
)
_
logg
er
.
info
(
'
Contacting Google Public DNS to find our IP
'
)
local_ip
=
[
local_ip
=
[
(
(
s
.
connect
((
'
8.8.8.8
'
,
53
)),
s
.
connect
((
'
8.8.8.8
'
,
53
)),
...
@@ -430,7 +430,7 @@
...
@@ -430,7 +430,7 @@
socket
.
socket
(
socket
.
AF_INET
,
socket
.
SOCK_DGRAM
)]
socket
.
socket
(
socket
.
AF_INET
,
socket
.
SOCK_DGRAM
)]
][
0
][
1
]
][
0
][
1
]
logg
ing
.
debug
(
'
IP found %s
'
,
local_ip
)
_
logg
er
.
debug
(
'
IP found %s
'
,
local_ip
)
arg
.
append
(
'
--db_host
'
)
arg
.
append
(
'
--db_host
'
)
arg
.
append
(
local_ip
)
arg
.
append
(
local_ip
)
...
@@ -445,7 +445,7 @@
...
@@ -445,7 +445,7 @@
user
=
db_user
user
=
db_user
password
=
db_password
password
=
db_password
if
os
.
path
.
isfile
(
local_conf_path
):
if
os
.
path
.
isfile
(
local_conf_path
):
logg
ing
.
info
(
'
Local configuration file found: %s
'
%
local_conf_path
)
_
logg
er
.
info
(
'
Local configuration file found: %s
'
%
local_conf_path
)
binds
.
append
(
'
%s:/opt/odoo/etc
'
%
os
.
path
.
join
(
binds
.
append
(
'
%s:/opt/odoo/etc
'
%
os
.
path
.
join
(
project_path
,
local_conf_dir
))
project_path
,
local_conf_dir
))
cp_local
=
ConfigParser
()
cp_local
=
ConfigParser
()
...
@@ -466,7 +466,7 @@
...
@@ -466,7 +466,7 @@
# data volume handling
# data volume handling
if
odoo_type
!=
'
odoo7
'
:
if
odoo_type
!=
'
odoo7
'
:
data_volume_name
=
'
{}_data
'
.
format
(
project_name
)
data_volume_name
=
'
{}_data
'
.
format
(
project_name
)
logg
ing
.
debug
(
'
Using data volume %s
'
,
data_volume_name
)
_
logg
er
.
debug
(
'
Using data volume %s
'
,
data_volume_name
)
createVolume
(
docker_client
,
data_volume_name
)
createVolume
(
docker_client
,
data_volume_name
)
# make sure the permission in the volume are correct
# make sure the permission in the volume are correct
mount_opts
=
'
{}:/mnt/data
'
.
format
(
data_volume_name
)
mount_opts
=
'
{}:/mnt/data
'
.
format
(
data_volume_name
)
...
@@ -479,7 +479,7 @@
...
@@ -479,7 +479,7 @@
binds
.
append
(
'
{}:/mnt/data
'
.
format
(
data_volume_name
))
binds
.
append
(
'
{}:/mnt/data
'
.
format
(
data_volume_name
))
arg
.
append
(
'
--data-dir /mnt/data
'
)
arg
.
append
(
'
--data-dir /mnt/data
'
)
else
:
else
:
logg
ing
.
debug
(
'
No data volume for this odoo version
'
)
_
logg
er
.
debug
(
'
No data volume for this odoo version
'
)
# avoid the duplication of unbind volumes with all addons
# avoid the duplication of unbind volumes with all addons
# additionnal_addons only in odoo < 10
# additionnal_addons only in odoo < 10
...
@@ -518,9 +518,9 @@
...
@@ -518,9 +518,9 @@
except
OperationalError
as
exception
:
except
OperationalError
as
exception
:
if
nmspc
.
create_user
:
if
nmspc
.
create_user
:
logg
ing
.
debug
(
'
Cannot connect to database with user %s
'
,
user
)
_
logg
er
.
debug
(
'
Cannot connect to database with user %s
'
,
user
)
logg
ing
.
debug
(
exception
)
_
logg
er
.
debug
(
exception
)
logg
ing
.
info
(
'
Creating user %s
'
,
user
)
_
logg
er
.
info
(
'
Creating user %s
'
,
user
)
if
start_postgresql
:
if
start_postgresql
:
connection
=
connect
(
connection
=
connect
(
user
=
'
pg
'
,
user
=
'
pg
'
,
...
@@ -540,5 +540,5 @@
...
@@ -540,5 +540,5 @@
connection
.
commit
()
connection
.
commit
()
connection
.
close
()
connection
.
close
()
else
:
else
:
logg
ing
.
fatal
(
_
logg
er
.
fatal
(
'
Cannot connect to database with user %s
'
,
user
)
'
Cannot connect to database with user %s
'
,
user
)
...
@@ -544,8 +544,8 @@
...
@@ -544,8 +544,8 @@
'
Cannot connect to database with user %s
'
,
user
)
'
Cannot connect to database with user %s
'
,
user
)
logg
ing
.
fatal
(
exception
)
_
logg
er
.
fatal
(
exception
)
logg
ing
.
info
(
_
logg
er
.
info
(
"
You can add the --create-user argument to create it
"
)
"
You can add the --create-user argument to create it
"
)
return
16
return
16
# restore
# restore
if
restore_filename
:
if
restore_filename
:
restore_basename
=
os
.
path
.
basename
(
restore_filename
)
restore_basename
=
os
.
path
.
basename
(
restore_filename
)
...
@@ -547,9 +547,9 @@
...
@@ -547,9 +547,9 @@
"
You can add the --create-user argument to create it
"
)
"
You can add the --create-user argument to create it
"
)
return
16
return
16
# restore
# restore
if
restore_filename
:
if
restore_filename
:
restore_basename
=
os
.
path
.
basename
(
restore_filename
)
restore_basename
=
os
.
path
.
basename
(
restore_filename
)
logg
ing
.
info
(
"
Copying dump file in docker
"
)
_
logg
er
.
info
(
"
Copying dump file in docker
"
)
call
([
call
([
'
docker
'
,
'
cp
'
,
restore_filename
,
'
docker
'
,
'
cp
'
,
restore_filename
,
'
{}:/tmp/{}
'
.
format
(
name
,
restore_basename
)])
'
{}:/tmp/{}
'
.
format
(
name
,
restore_basename
)])
...
@@ -553,6 +553,6 @@
...
@@ -553,6 +553,6 @@
call
([
call
([
'
docker
'
,
'
cp
'
,
restore_filename
,
'
docker
'
,
'
cp
'
,
restore_filename
,
'
{}:/tmp/{}
'
.
format
(
name
,
restore_basename
)])
'
{}:/tmp/{}
'
.
format
(
name
,
restore_basename
)])
logg
ing
.
info
(
"
Creating database
"
)
_
logg
er
.
info
(
"
Creating database
"
)
call
([
call
([
'
docker
'
,
'
exec
'
,
name
,
'
createdb
'
,
'
-U
'
,
user
,
database
])
'
docker
'
,
'
exec
'
,
name
,
'
createdb
'
,
'
-U
'
,
user
,
database
])
...
@@ -557,8 +557,8 @@
...
@@ -557,8 +557,8 @@
call
([
call
([
'
docker
'
,
'
exec
'
,
name
,
'
createdb
'
,
'
-U
'
,
user
,
database
])
'
docker
'
,
'
exec
'
,
name
,
'
createdb
'
,
'
-U
'
,
user
,
database
])
logg
ing
.
info
(
"
Restoring database
"
)
_
logg
er
.
info
(
"
Restoring database
"
)
restore
=
call
([
restore
=
call
([
'
docker
'
,
'
exec
'
,
name
,
'
pg_restore
'
,
'
-U
'
,
user
,
'
-O
'
,
'
docker
'
,
'
exec
'
,
name
,
'
pg_restore
'
,
'
-U
'
,
user
,
'
-O
'
,
'
-d
'
,
database
,
'
/tmp/{}
'
.
format
(
restore_basename
)])
'
-d
'
,
database
,
'
/tmp/{}
'
.
format
(
restore_basename
)])
if
not
restore
:
if
not
restore
:
return
15
return
15
...
@@ -560,9 +560,9 @@
...
@@ -560,9 +560,9 @@
restore
=
call
([
restore
=
call
([
'
docker
'
,
'
exec
'
,
name
,
'
pg_restore
'
,
'
-U
'
,
user
,
'
-O
'
,
'
docker
'
,
'
exec
'
,
name
,
'
pg_restore
'
,
'
-U
'
,
user
,
'
-O
'
,
'
-d
'
,
database
,
'
/tmp/{}
'
.
format
(
restore_basename
)])
'
-d
'
,
database
,
'
/tmp/{}
'
.
format
(
restore_basename
)])
if
not
restore
:
if
not
restore
:
return
15
return
15
logg
ing
.
info
(
"
Removing dump file in docker
"
)
_
logg
er
.
info
(
"
Removing dump file in docker
"
)
call
([
'
docker
'
,
'
exec
'
,
name
,
'
/tmp/{}
'
.
format
(
restore_basename
)])
call
([
'
docker
'
,
'
exec
'
,
name
,
'
/tmp/{}
'
.
format
(
restore_basename
)])
if
not
start_postgresql
and
not
odoo_help
and
restore_filename
:
if
not
start_postgresql
and
not
odoo_help
and
restore_filename
:
...
@@ -566,8 +566,8 @@
...
@@ -566,8 +566,8 @@
call
([
'
docker
'
,
'
exec
'
,
name
,
'
/tmp/{}
'
.
format
(
restore_basename
)])
call
([
'
docker
'
,
'
exec
'
,
name
,
'
/tmp/{}
'
.
format
(
restore_basename
)])
if
not
start_postgresql
and
not
odoo_help
and
restore_filename
:
if
not
start_postgresql
and
not
odoo_help
and
restore_filename
:
logg
ing
.
info
(
"
Creating database %s
"
,
database
)
_
logg
er
.
info
(
"
Creating database %s
"
,
database
)
createdb
=
call
([
createdb
=
call
([
'
createdb
'
,
'
-U
'
,
user
,
database
])
'
createdb
'
,
'
-U
'
,
user
,
database
])
if
not
createdb
:
if
not
createdb
:
return
17
return
17
...
@@ -570,8 +570,8 @@
...
@@ -570,8 +570,8 @@
createdb
=
call
([
createdb
=
call
([
'
createdb
'
,
'
-U
'
,
user
,
database
])
'
createdb
'
,
'
-U
'
,
user
,
database
])
if
not
createdb
:
if
not
createdb
:
return
17
return
17
logg
ing
.
info
(
"
Restoring database %s
"
,
database
)
_
logg
er
.
info
(
"
Restoring database %s
"
,
database
)
restore
=
call
([
restore
=
call
([
'
pg_restore
'
,
'
-U
'
,
user
,
'
-O
'
,
'
pg_restore
'
,
'
-U
'
,
user
,
'
-O
'
,
'
-d
'
,
database
,
restore_filename
])
'
-d
'
,
database
,
restore_filename
])
...
@@ -614,7 +614,7 @@
...
@@ -614,7 +614,7 @@
cmd
.
extend
(
options
)
cmd
.
extend
(
options
)
cmd
.
append
(
image
)
cmd
.
append
(
image
)
cmd
.
extend
(
arg
)
cmd
.
extend
(
arg
)
logg
ing
.
debug
(
'
'
.
join
(
cmd
))
_
logg
er
.
debug
(
'
'
.
join
(
cmd
))
result
=
call
(
cmd
)
result
=
call
(
cmd
)
return
result
return
result
...
@@ -624,6 +624,6 @@
...
@@ -624,6 +624,6 @@
"""
"""
volumes
=
docker_client
.
volumes
(
filters
=
{
'
name
'
:
data_volume_name
})
volumes
=
docker_client
.
volumes
(
filters
=
{
'
name
'
:
data_volume_name
})
if
volumes
[
'
Volumes
'
]:
if
volumes
[
'
Volumes
'
]:
logg
ing
.
debug
(
'
Volume %s already exist
'
,
data_volume_name
)
_
logg
er
.
debug
(
'
Volume %s already exist
'
,
data_volume_name
)
return
volumes
[
'
Volumes
'
][
0
]
return
volumes
[
'
Volumes
'
][
0
]
else
:
else
:
...
@@ -628,6 +628,6 @@
...
@@ -628,6 +628,6 @@
return
volumes
[
'
Volumes
'
][
0
]
return
volumes
[
'
Volumes
'
][
0
]
else
:
else
:
logg
ing
.
debug
(
'
Creating volume %s
'
,
data_volume_name
)
_
logg
er
.
debug
(
'
Creating volume %s
'
,
data_volume_name
)
return
docker_client
.
create_volume
(
name
=
data_volume_name
)
return
docker_client
.
create_volume
(
name
=
data_volume_name
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment