Skip to content

Commit 5e60fdd

Browse files
[IMP] Add suppor for Pydevd/Pycharm
1 parent 680669d commit 5e60fdd

File tree

10 files changed

+69
-0
lines changed

10 files changed

+69
-0
lines changed

11.0.Dockerfile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ ENV DB_FILTER=.* \
2626
DEBUGPY_ENABLE=0 \
2727
PUDB_RDB_HOST=0.0.0.0 \
2828
PUDB_RDB_PORT=6899 \
29+
PYDEVD_PORT=6988 \
30+
PYDEVD_ENABLE=0 \
31+
PYCHARM_ENABLE=0 \
2932
PYTHONOPTIMIZE="" \
3033
UNACCENT=true \
3134
WAIT_DB=true \
@@ -94,6 +97,8 @@ RUN pip install \
9497
ptvsd \
9598
debugpy \
9699
pydevd-odoo \
100+
pydevd \
101+
pydevd-pycharm \
97102
pudb \
98103
watchdog \
99104
wdb \

12.0.Dockerfile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ ENV DB_FILTER=.* \
2626
DEBUGPY_ENABLE=0 \
2727
PUDB_RDB_HOST=0.0.0.0 \
2828
PUDB_RDB_PORT=6899 \
29+
PYDEVD_PORT=6988 \
30+
PYDEVD_ENABLE=0 \
31+
PYCHARM_ENABLE=0 \
2932
PYTHONOPTIMIZE="" \
3033
UNACCENT=true \
3134
WAIT_DB=true \
@@ -88,6 +91,8 @@ RUN pip install \
8891
ptvsd \
8992
debugpy \
9093
pydevd-odoo \
94+
pydevd \
95+
pydevd-pycharm \
9196
pudb \
9297
python-magic \
9398
watchdog \

13.0.Dockerfile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ ENV DB_FILTER=.* \
2626
DEBUGPY_ENABLE=0 \
2727
PUDB_RDB_HOST=0.0.0.0 \
2828
PUDB_RDB_PORT=6899 \
29+
PYDEVD_PORT=6988 \
30+
PYDEVD_ENABLE=0 \
31+
PYCHARM_ENABLE=0 \
2932
PYTHONOPTIMIZE="" \
3033
UNACCENT=true \
3134
WAIT_DB=true \
@@ -138,6 +141,8 @@ RUN build_deps=" \
138141
ptvsd \
139142
debugpy \
140143
pydevd-odoo \
144+
pydevd \
145+
pydevd-pycharm \
141146
pudb \
142147
python-magic \
143148
watchdog \

14.0.Dockerfile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ ENV DB_FILTER=.* \
2525
DEBUGPY_ENABLE=0 \
2626
PUDB_RDB_HOST=0.0.0.0 \
2727
PUDB_RDB_PORT=6899 \
28+
PYDEVD_PORT=6988 \
29+
PYDEVD_ENABLE=0 \
30+
PYCHARM_ENABLE=0 \
2831
PYTHONOPTIMIZE="" \
2932
UNACCENT=true \
3033
WAIT_DB=true \
@@ -149,6 +152,8 @@ RUN build_deps=" \
149152
git+https://github.com/Tecnativa/click-odoo-contrib.git@fix-active-modules-hashing \
150153
debugpy \
151154
pydevd-odoo \
155+
pydevd \
156+
pydevd-pycharm \
152157
geoip2 \
153158
"git-aggregator<3.0.0" \
154159
inotify \

15.0.Dockerfile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ ENV DB_FILTER=.* \
2525
DEBUGPY_ENABLE=0 \
2626
PUDB_RDB_HOST=0.0.0.0 \
2727
PUDB_RDB_PORT=6899 \
28+
PYDEVD_PORT=6988 \
29+
PYDEVD_ENABLE=0 \
30+
PYCHARM_ENABLE=0 \
2831
PYTHONOPTIMIZE="" \
2932
UNACCENT=true \
3033
WAIT_DB=true \
@@ -146,6 +149,8 @@ RUN build_deps=" \
146149
click-odoo-contrib \
147150
debugpy \
148151
pydevd-odoo \
152+
pydevd \
153+
pydevd-pycharm \
149154
flanker[validator] \
150155
geoip2 \
151156
"git-aggregator<3.0.0" \

16.0.Dockerfile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ ENV DB_FILTER=.* \
3131
DEBUGPY_ENABLE=0 \
3232
PUDB_RDB_HOST=0.0.0.0 \
3333
PUDB_RDB_PORT=6899 \
34+
PYDEVD_PORT=6988 \
35+
PYDEVD_ENABLE=0 \
36+
PYCHARM_ENABLE=0 \
3437
PYTHONOPTIMIZE="" \
3538
UNACCENT=true \
3639
WAIT_DB=true \
@@ -152,6 +155,8 @@ RUN build_deps=" \
152155
click-odoo-contrib \
153156
debugpy \
154157
pydevd-odoo \
158+
pydevd \
159+
pydevd-pycharm \
155160
git+https://github.com/mailgun/flanker.git@v0.9.15#egg=flanker[validator] \
156161
geoip2 \
157162
"git-aggregator==4.0" \

17.0.Dockerfile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ ENV DB_FILTER=.* \
3030
DEBUGPY_ENABLE=0 \
3131
PUDB_RDB_HOST=0.0.0.0 \
3232
PUDB_RDB_PORT=6899 \
33+
PYDEVD_PORT=6988 \
34+
PYDEVD_ENABLE=0 \
35+
PYCHARM_ENABLE=0 \
3336
PYTHONOPTIMIZE="" \
3437
UNACCENT=true \
3538
WAIT_DB=true \
@@ -151,6 +154,8 @@ RUN build_deps=" \
151154
click-odoo-contrib \
152155
debugpy \
153156
pydevd-odoo \
157+
pydevd \
158+
pydevd-pycharm \
154159
git+https://github.com/mailgun/flanker.git@v0.9.15#egg=flanker[validator] \
155160
geoip2 \
156161
"git-aggregator==4.0" \

18.0.Dockerfile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ ENV DB_FILTER=.* \
3030
DEBUGPY_ENABLE=0 \
3131
PUDB_RDB_HOST=0.0.0.0 \
3232
PUDB_RDB_PORT=6899 \
33+
PYDEVD_PORT=6988 \
34+
PYDEVD_ENABLE=0 \
35+
PYCHARM_ENABLE=0 \
3336
PYTHONOPTIMIZE="" \
3437
UNACCENT=true \
3538
WAIT_DB=true \
@@ -151,6 +154,8 @@ RUN build_deps=" \
151154
click-odoo-contrib \
152155
debugpy \
153156
pydevd-odoo \
157+
pydevd \
158+
pydevd-pycharm \
154159
git+https://github.com/mailgun/flanker.git@v0.9.15#egg=flanker[validator] \
155160
geoip2 \
156161
"git-aggregator==4.0" \

bin/direxec

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ if extra_command:
6767
+ os.environ["DEBUGPY_ARGS"].split()
6868
+ extra_command
6969
)
70+
elif os.environ["PYDEVD_ENABLE"] == "1" or os.environ["PYCHARM_ENABLE"] == "1":
71+
extra_command[0] = "/usr/local/bin/odoo_pydevd"
7072
logger.log(
7173
DEBUG if extra_command[0] == "/qa/insider" else INFO,
7274
"Executing %s",

bin/odoo_pydevd

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/usr/bin/env python3
2+
3+
# set server timezone in UTC before time module imported
4+
import os
5+
os.environ["TZ"] = "UTC"
6+
7+
# import regular pydevd or pycharm's version depending on flags
8+
if os.environ["PYCHARM_ENABLE"] == "1":
9+
import pydevd_pycharm as pydevd
10+
else:
11+
import pydevd
12+
import odoo
13+
14+
# If we don't get host, we guess it from within the container
15+
if os.environ.get("PYDEVD_HOST", False):
16+
pydevd_host = os.environ["PYDEVD_HOST"]
17+
else:
18+
import socket
19+
local_ip = socket.gethostbyname(socket.gethostname())
20+
pydevd_host = ".".join(local_ip.split(".")[0:3] + ["1"])
21+
# Port needs casting to int if obtained from env variable
22+
port=int(os.environ.get("PYDEVD_PORT", 6988))
23+
pydevd.settrace(
24+
pydevd_host, port=port, suspend=False, stdoutToServer=True, stderrToServer=True
25+
)
26+
if __name__ == "__main__":
27+
odoo.cli.main()

0 commit comments

Comments
 (0)