Skip to content

Commit c2979ad

Browse files
committed
misc: devcontainer - django debug toolbar profile + dockerfile cleanup
- Legacy-Id: 19529
1 parent 9c903f1 commit c2979ad

7 files changed

Lines changed: 68 additions & 21 deletions

File tree

.devcontainer/Dockerfile

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -64,14 +64,6 @@ RUN apt-get install -qy \
6464
zile \
6565
zlib1g-dev
6666

67-
# Install libyang
68-
# RUN wget -nv http://download.opensuse.org/repositories/home:liberouter/Debian_9.0/Release.key && \
69-
# apt-key add - < Release.key && \
70-
# rm Release.key && \
71-
# echo "deb http://download.opensuse.org/repositories/home:/liberouter/Debian_9.0/ /" >> /etc/apt/sources.list.d/libyang.list && \
72-
# apt-get update && \
73-
# apt-get install -qy libyang1
74-
7567
# Install chromedriver
7668
RUN apt-get update && \
7769
apt-get install -y gnupg wget curl unzip --no-install-recommends && \
@@ -120,12 +112,6 @@ RUN pip3 --disable-pip-version-check --no-cache-dir install -r /tmp/pip-tmp/requ
120112
COPY .devcontainer/init.sh /docker-init.sh
121113
RUN sed -i 's/\r$//' /docker-init.sh && \
122114
chmod +x /docker-init.sh
115+
123116
# ENTRYPOINT ["/usr/local/share/datatracker/.devcontainer/init.sh"]
124117
CMD ["sleep", "infinity"]
125-
126-
# [Optional] Uncomment this section to install additional OS packages.
127-
# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
128-
# && apt-get -y install --no-install-recommends <your-package-list-here>
129-
130-
# [Optional] Uncomment this line to install global node packages.
131-
# RUN su vscode -c "source /usr/local/share/nvm/nvm.sh && npm install -g <your-package-here>" 2>&1

.devcontainer/init.sh

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,16 @@ fi
8383
echo "Activating the virtual python environment ..."
8484
. $VIRTDIR/bin/activate
8585

86-
if [ ! -f $WORKSPACEDIR/ietf/settings_local.py ]; then
86+
if [ ! -f "$WORKSPACEDIR/ietf/settings_local.py" ]; then
8787
echo "Setting up a default settings_local.py ..."
8888
cp $WORKSPACEDIR/.devcontainer/settings_local.py $WORKSPACEDIR/ietf/settings_local.py
8989
fi
9090

91+
if [ ! -f "$WORKSPACEDIR/ietf/settings_local_debug.py" ]; then
92+
echo "Setting up a default settings_local_debug.py ..."
93+
cp $WORKSPACEDIR/.devcontainer/settings_local_debug.py $WORKSPACEDIR/ietf/settings_local_debug.py
94+
fi
95+
9196
for sub in test/id/ test/staging/ test/archive/ test/rfc test/media test/wiki/ietf; do
9297
dir="$WORKSPACEDIR/$sub"
9398
if [ ! -d "$dir" ]; then
@@ -141,7 +146,6 @@ chmod -R g+w /usr/local/lib/ # so we can patch libs if needed
141146

142147
cd "$WORKSPACEDIR" || cd "/home/$USER/"
143148

144-
echo "Done!"
145149
if ! echo "$LANG" | grep "UTF-8"; then
146150
echo ""
147151
echo "Make sure you export LANG=en_GB.UTF-8 (or another UTF-8 locale) in your .bashrc"
@@ -153,6 +157,8 @@ HOME=/opt/home/$USER
153157

154158
/usr/local/bin/python $WORKSPACEDIR/ietf/manage.py check --settings=settings_local
155159

160+
echo "Done!"
161+
156162
# su -p $USER
157163

158164
exec "$@"

.devcontainer/settings_local.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,15 @@
55
if six.PY3:
66
from typing import Collection, Dict, List, Tuple # pyflakes:ignore
77

8+
from ietf.settings import * # pyflakes:ignore
9+
810
ALLOWED_HOSTS = ['*']
911

1012
SECRET_KEY = 'jzv$o93h_lzw4a0%0oz-5t5lk+ai=3f8x@uo*9ahu8w4i300o6'
1113

1214
DATABASES = {
1315
'default': {
14-
'HOST': 'localhost',
16+
'HOST': 'db',
1517
'PORT': 3306,
1618
'NAME': 'ietf_utf8',
1719
'ENGINE': 'django.db.backends.mysql',
@@ -61,5 +63,3 @@
6163
SUBMIT_YANG_INVAL_MODEL_DIR = 'data/developers/ietf-ftp/yang/invalmod/'
6264
SUBMIT_YANG_IANA_MODEL_DIR = 'data/developers/ietf-ftp/yang/ianamod/'
6365
SUBMIT_YANG_RFC_MODEL_DIR = 'data/developers/ietf-ftp/yang/rfcmod/'
64-
65-
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Copyright The IETF Trust 2007-2019, All Rights Reserved
2+
# -*- coding: utf-8 -*-
3+
4+
from ietf.settings import INSTALLED_APPS, MIDDLEWARE
5+
from ietf.settings_local import * # pyflakes:ignore
6+
7+
USE_DEBUG_TOOLBAR = True
8+
9+
INSTALLED_APPS = INSTALLED_APPS + ['debug_toolbar', ]
10+
11+
MIDDLEWARE = ['debug_toolbar.middleware.DebugToolbarMiddleware', ] + MIDDLEWARE
12+
13+
LOGGING = {
14+
'version': 1,
15+
'filters': {
16+
'require_debug_true': {
17+
'()': 'django.utils.log.RequireDebugTrue',
18+
}
19+
},
20+
'handlers': {
21+
'console': {
22+
'level': 'DEBUG',
23+
'filters': ['require_debug_true'],
24+
'class': 'logging.StreamHandler',
25+
}
26+
},
27+
'loggers': {
28+
'django.db.backends': {
29+
'level': 'DEBUG',
30+
'handlers': ['console'],
31+
}
32+
}
33+
}

.vscode/launch.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,19 @@
1616
"--settings=settings_local"
1717
],
1818
"django": true
19+
},
20+
{
21+
"name": "Run Server with Debug Toolbar",
22+
"type": "python",
23+
"request": "launch",
24+
"python": "/usr/local/bin/python",
25+
"program": "${workspaceFolder}/ietf/manage.py",
26+
"args": [
27+
"runserver",
28+
"0.0.0.0:8000",
29+
"--settings=settings_local_debug"
30+
],
31+
"django": true
1932
}
2033
]
2134
}

ietf/group/views.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
import itertools
4040
import io
4141
import json
42+
from traceback import print_list
4243
import markdown
4344
import math
4445
import os
@@ -63,7 +64,7 @@
6364

6465
from ietf.community.models import CommunityList, EmailSubscription
6566
from ietf.community.utils import docs_tracked_by_community_list
66-
from ietf.doc.models import DocTagName, State, DocAlias, RelatedDocument, Document
67+
from ietf.doc.models import DocTagName, State, DocAlias, RelatedDocument, Document, Person
6768
from ietf.doc.templatetags.ietf_filters import clean_whitespace
6869
from ietf.doc.utils import get_chartering_type, get_tags_for_stream_id
6970
from ietf.doc.utils_charter import charter_name_for_group, replace_charter_of_replaced_group

ietf/urls.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from django.views import static as static_view
1010
from django.views.generic import TemplateView
1111
from django.views.defaults import server_error
12+
from django.urls import path
1213

1314
import debug # pyflakes:ignore
1415

@@ -89,3 +90,10 @@
8990
urlpatterns += static_url(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
9091
settings.DEBUG = save_debug
9192

93+
# Debug Toolbar
94+
if hasattr(settings, 'USE_DEBUG_TOOLBAR') and settings.USE_DEBUG_TOOLBAR:
95+
try:
96+
import debug_toolbar
97+
path('__debug__/', include(debug_toolbar.urls)),
98+
except ImportError:
99+
pass

0 commit comments

Comments
 (0)