Wiki
Version 178 (Etienne Pallier, 03/22/2016 10:07 am)
1 | 1 | Etienne Pallier | h1. Technical Documentation for the PYROS project (FGFT-CC) |
---|---|---|---|
2 | 1 | Etienne Pallier | |
3 | 1 | Etienne Pallier | |
4 | 1 | Etienne Pallier | HOWTO Format Redmine Wiki : http://www.redmine.org/projects/redmine/wiki/FrRedmineWikiFormatting |
5 | 1 | Etienne Pallier | |
6 | 1 | Etienne Pallier | {{>toc}} |
7 | 1 | Etienne Pallier | |
8 | 1 | Etienne Pallier | |
9 | 121 | Etienne Pallier | --- |
10 | 1 | Etienne Pallier | |
11 | 121 | Etienne Pallier | h2. %{margin-left:0px; font-weight:bold; font-size:25px; display:block; color:red;}I - TODO% |
12 | 121 | Etienne Pallier | |
13 | 126 | Etienne Pallier | * installation sur windows |
14 | 125 | Etienne Pallier | |
15 | 126 | Etienne Pallier | * gitlab |
16 | 1 | Etienne Pallier | |
17 | 126 | Etienne Pallier | * séparation des BD Django et Pyros |
18 | 125 | Etienne Pallier | |
19 | 126 | Etienne Pallier | * intégration dans Eclipse |
20 | 126 | Etienne Pallier | |
21 | 174 | Etienne Pallier | * Intégration des modules Django déjà développés |
22 | 125 | Etienne Pallier | |
23 | 121 | Etienne Pallier | |
24 | 3 | Etienne Pallier | --- |
25 | 1 | Etienne Pallier | |
26 | 140 | Etienne Pallier | h2. %{margin-left:0px; font-weight:bold; font-size:25px; display:block; color:red;}I - DATABASE SCHEMA (v0.2.1)% |
27 | 116 | Etienne Pallier | |
28 | 116 | Etienne Pallier | |
29 | 117 | Etienne Pallier | {{thumbnail(PYROS_PDM_v021.png, size=300, title=Pyros data model)}} |
30 | 121 | Etienne Pallier | |
31 | 121 | Etienne Pallier | |
32 | 121 | Etienne Pallier | --- |
33 | 116 | Etienne Pallier | |
34 | 141 | Etienne Pallier | h2. %{margin-left:0px; font-weight:bold; font-size:25px; display:block; color:red;}II - Get the project (from gitlab)% |
35 | 141 | Etienne Pallier | |
36 | 141 | Etienne Pallier | https://gitlab.irap.omp.eu/epallier/pyros |
37 | 141 | Etienne Pallier | |
38 | 161 | Etienne Pallier | https://gitlab.irap.omp.eu/epallier/pyros.git |
39 | 161 | Etienne Pallier | |
40 | 161 | Etienne Pallier | ssh git@gitlab.irap.omp.eu:epallier/pyros.git |
41 | 141 | Etienne Pallier | |
42 | 1 | Etienne Pallier | |
43 | 169 | Etienne Pallier | |
44 | 169 | Etienne Pallier | h3. Get the project from the terminal |
45 | 169 | Etienne Pallier | |
46 | 174 | Etienne Pallier | <pre> |
47 | 1 | Etienne Pallier | git clone https://gitlab.irap.omp.eu/epallier/pyros.git PYROS |
48 | 1 | Etienne Pallier | |
49 | 174 | Etienne Pallier | (or also : git clone git@gitlab.irap.omp.eu:epallier/pyros.git) |
50 | 174 | Etienne Pallier | </pre> |
51 | 174 | Etienne Pallier | |
52 | 174 | Etienne Pallier | If you just want a static copy of the project (without synchronization) just remove the .git/ folder : |
53 | 174 | Etienne Pallier | <pre> |
54 | 174 | Etienne Pallier | $ rm -r .git/ |
55 | 174 | Etienne Pallier | </pre> |
56 | 169 | Etienne Pallier | |
57 | 169 | Etienne Pallier | h3. Get the project from Eclipse |
58 | 169 | Etienne Pallier | |
59 | 169 | Etienne Pallier | TODO: |
60 | 169 | Etienne Pallier | |
61 | 141 | Etienne Pallier | h2. %{margin-left:0px; font-weight:bold; font-size:25px; display:block; color:red;}III - INSTALLATION% |
62 | 2 | Etienne Pallier | |
63 | 120 | Etienne Pallier | |
64 | 120 | Etienne Pallier | --- |
65 | 120 | Etienne Pallier | |
66 | 51 | Etienne Pallier | h3. If necessary, install MySql |
67 | 2 | Etienne Pallier | |
68 | 49 | Etienne Pallier | * Linux Ubuntu |
69 | 49 | Etienne Pallier | <pre> |
70 | 107 | Paul Carensac | |
71 | 107 | Paul Carensac | $ sudo apt-get install mysql-server |
72 | 107 | Paul Carensac | $ sudo apt-get install mysql-client |
73 | 107 | Paul Carensac | |
74 | 49 | Etienne Pallier | </pre> |
75 | 49 | Etienne Pallier | |
76 | 49 | Etienne Pallier | * Linux CentOS |
77 | 49 | Etienne Pallier | <pre> |
78 | 49 | Etienne Pallier | TODO: |
79 | 49 | Etienne Pallier | $ sudo yum install mysql |
80 | 49 | Etienne Pallier | ... |
81 | 49 | Etienne Pallier | </pre> |
82 | 49 | Etienne Pallier | |
83 | 49 | Etienne Pallier | * Mac OS X |
84 | 177 | Etienne Pallier | |
85 | 1 | Etienne Pallier | Install XAMPP |
86 | 1 | Etienne Pallier | (but you could also use the pre-installed Mac OS MySql) |
87 | 177 | Etienne Pallier | |
88 | 177 | Etienne Pallier | <pre> |
89 | 177 | Etienne Pallier | TODO: |
90 | 49 | Etienne Pallier | </pre> |
91 | 1 | Etienne Pallier | |
92 | 49 | Etienne Pallier | * Windows |
93 | 178 | Etienne Pallier | |
94 | 177 | Etienne Pallier | Install XAMPP |
95 | 49 | Etienne Pallier | <pre> |
96 | 49 | Etienne Pallier | TODO: |
97 | 49 | Etienne Pallier | </pre> |
98 | 49 | Etienne Pallier | |
99 | 49 | Etienne Pallier | |
100 | 49 | Etienne Pallier | --- |
101 | 1 | Etienne Pallier | |
102 | 6 | Etienne Pallier | h3. Create database |
103 | 1 | Etienne Pallier | |
104 | 52 | Etienne Pallier | |
105 | 52 | Etienne Pallier | * Linux and Mac OS X: |
106 | 52 | Etienne Pallier | <pre> |
107 | 3 | Etienne Pallier | One liner: |
108 | 115 | Etienne Pallier | $ mysql -u root < pyros_create.sql |
109 | 1 | Etienne Pallier | |
110 | 3 | Etienne Pallier | Or : |
111 | 3 | Etienne Pallier | $ mysql -u root |
112 | 3 | Etienne Pallier | mysql> create database pyros; |
113 | 3 | Etienne Pallier | mysql> use pyros; |
114 | 115 | Etienne Pallier | mysql> source pyros_create.sql; |
115 | 1 | Etienne Pallier | |
116 | 3 | Etienne Pallier | ( |
117 | 3 | Etienne Pallier | TODO: |
118 | 3 | Etienne Pallier | mysql> grant all on pyros.* to pyros@localhost identified by ‘pyros’;) |
119 | 3 | Etienne Pallier | mysql> flush privileges; |
120 | 3 | Etienne Pallier | ) |
121 | 52 | Etienne Pallier | </pre> |
122 | 1 | Etienne Pallier | |
123 | 53 | Etienne Pallier | |
124 | 53 | Etienne Pallier | * Windows: |
125 | 52 | Etienne Pallier | <pre> |
126 | 52 | Etienne Pallier | TODO: Use phpmyadmin ? |
127 | 52 | Etienne Pallier | </pre> |
128 | 1 | Etienne Pallier | |
129 | 1 | Etienne Pallier | |
130 | 4 | Etienne Pallier | --- |
131 | 5 | Etienne Pallier | |
132 | 6 | Etienne Pallier | h3. Install python3.5 |
133 | 1 | Etienne Pallier | |
134 | 11 | Etienne Pallier | |
135 | 11 | Etienne Pallier | * Mac OS X : |
136 | 23 | Etienne Pallier | <pre> |
137 | 24 | Etienne Pallier | 1) Installer MacPort |
138 | 24 | Etienne Pallier | (TODO: doc) |
139 | 24 | Etienne Pallier | |
140 | 24 | Etienne Pallier | 2) Installer le "port" python35 |
141 | 1 | Etienne Pallier | $ sudo port install python35 |
142 | 1 | Etienne Pallier | </pre> |
143 | 1 | Etienne Pallier | |
144 | 1 | Etienne Pallier | * Linux (Ubuntu) : |
145 | 1 | Etienne Pallier | <pre> |
146 | 107 | Paul Carensac | sudo add-apt-repository ppa:fkrull/deadsnakes |
147 | 107 | Paul Carensac | sudo apt-get update |
148 | 107 | Paul Carensac | sudo apt-get install python3.5 |
149 | 107 | Paul Carensac | |
150 | 107 | Paul Carensac | sudo pip install virtualenv |
151 | 23 | Etienne Pallier | </pre> |
152 | 1 | Etienne Pallier | |
153 | 5 | Etienne Pallier | |
154 | 3 | Etienne Pallier | |
155 | 4 | Etienne Pallier | --- |
156 | 5 | Etienne Pallier | |
157 | 59 | Etienne Pallier | h3. Get the project (from git) |
158 | 59 | Etienne Pallier | |
159 | 78 | Etienne Pallier | <pre> |
160 | 59 | Etienne Pallier | TODO: |
161 | 79 | Etienne Pallier | |
162 | 130 | Etienne Pallier | $ git http://pyros... PYROS |
163 | 78 | Etienne Pallier | </pre> |
164 | 1 | Etienne Pallier | |
165 | 130 | Etienne Pallier | This creates a PYROS folder containing the project |
166 | 59 | Etienne Pallier | |
167 | 59 | Etienne Pallier | |
168 | 59 | Etienne Pallier | --- |
169 | 59 | Etienne Pallier | |
170 | 131 | Etienne Pallier | h3. Create project structure |
171 | 131 | Etienne Pallier | |
172 | 131 | Etienne Pallier | <pre> |
173 | 131 | Etienne Pallier | $ mkdir PYROS |
174 | 132 | Etienne Pallier | </pre> |
175 | 131 | Etienne Pallier | |
176 | 131 | Etienne Pallier | Example of a good organization : |
177 | 131 | Etienne Pallier | |
178 | 131 | Etienne Pallier | 1 project = N applis |
179 | 158 | Etienne Pallier | 1 appli = N models |
180 | 158 | Etienne Pallier | A! L’appli est à côté du projet, PAS DEDANS, |
181 | 158 | Etienne Pallier | cela facilite la REUTILISATION |
182 | 158 | Etienne Pallier | (an appli can be part of many projects => reuse) |
183 | 131 | Etienne Pallier | 1 appli = 1 Python module, organized for Django, by default = appli web (but not mandatory) |
184 | 131 | Etienne Pallier | |
185 | 131 | Etienne Pallier | <pre> |
186 | 131 | Etienne Pallier | |
187 | 131 | Etienne Pallier | MYPROJECT/ |
188 | 171 | Etienne Pallier | REQUIREMENTS.txt |
189 | 131 | Etienne Pallier | src/ |
190 | 131 | Etienne Pallier | myproject/ |
191 | 131 | Etienne Pallier | appli1/ |
192 | 131 | Etienne Pallier | appli2/ |
193 | 131 | Etienne Pallier | … |
194 | 131 | Etienne Pallier | appliN/ |
195 | 131 | Etienne Pallier | |
196 | 131 | Etienne Pallier | public/ |
197 | 131 | Etienne Pallier | static/ |
198 | 131 | Etienne Pallier | |
199 | 131 | Etienne Pallier | private/ |
200 | 148 | Etienne Pallier | venv_py35_pyros/ |
201 | 131 | Etienne Pallier | |
202 | 131 | Etienne Pallier | </pre> |
203 | 131 | Etienne Pallier | |
204 | 131 | Etienne Pallier | |
205 | 131 | Etienne Pallier | Set needed folders: |
206 | 131 | Etienne Pallier | <pre> |
207 | 131 | Etienne Pallier | $ cd PYROS/ |
208 | 131 | Etienne Pallier | $ mkdir private public |
209 | 131 | Etienne Pallier | $ mkdir public/static |
210 | 131 | Etienne Pallier | </pre> |
211 | 131 | Etienne Pallier | |
212 | 131 | Etienne Pallier | |
213 | 131 | Etienne Pallier | |
214 | 131 | Etienne Pallier | --- |
215 | 131 | Etienne Pallier | |
216 | 3 | Etienne Pallier | h3. Create virtualenv with python3.5 dedicated to pyros project (inside the project folder) |
217 | 127 | Etienne Pallier | |
218 | 131 | Etienne Pallier | <pre> |
219 | 1 | Etienne Pallier | |
220 | 133 | Etienne Pallier | $ cd private/ |
221 | 3 | Etienne Pallier | |
222 | 3 | Etienne Pallier | $ which python3.5 |
223 | 3 | Etienne Pallier | /opt/local/bin/python3.5 |
224 | 15 | Etienne Pallier | |
225 | 127 | Etienne Pallier | $ virtualenv-3.5 venv_py35_pyros -p /opt/local/bin/python3.5 |
226 | 3 | Etienne Pallier | => creates a venv_py35_pyros/ folder inside PYROS/private/ |
227 | 1 | Etienne Pallier | |
228 | 131 | Etienne Pallier | </pre> |
229 | 1 | Etienne Pallier | |
230 | 7 | Etienne Pallier | --- |
231 | 3 | Etienne Pallier | |
232 | 65 | Etienne Pallier | h3. Activate the python virtual environment (from inside the project) |
233 | 7 | Etienne Pallier | |
234 | 55 | Etienne Pallier | <pre> |
235 | 1 | Etienne Pallier | |
236 | 65 | Etienne Pallier | $ pwd |
237 | 134 | Etienne Pallier | .../PYROS/private |
238 | 1 | Etienne Pallier | |
239 | 65 | Etienne Pallier | $ source ./venv_py35_pyros/bin/activate |
240 | 65 | Etienne Pallier | |
241 | 3 | Etienne Pallier | $ python -V |
242 | 1 | Etienne Pallier | Python 3.5.1 |
243 | 3 | Etienne Pallier | |
244 | 3 | Etienne Pallier | $ which pip |
245 | 77 | Etienne Pallier | .../PYROS/venv_py35_pyros/bin/pip |
246 | 16 | Etienne Pallier | |
247 | 18 | Etienne Pallier | Upgrade pip to last version available : |
248 | 3 | Etienne Pallier | $ pip install --upgrade pip |
249 | 3 | Etienne Pallier | Collecting pip |
250 | 3 | Etienne Pallier | Downloading pip-8.1.1-py2.py3-none-any.whl (1.2MB) |
251 | 3 | Etienne Pallier | Installing collected packages: pip |
252 | 3 | Etienne Pallier | Found existing installation: pip 7.1.2 |
253 | 3 | Etienne Pallier | Uninstalling pip-7.1.2: |
254 | 3 | Etienne Pallier | Successfully uninstalled pip-7.1.2 |
255 | 1 | Etienne Pallier | Successfully installed pip-8.1.1 |
256 | 55 | Etienne Pallier | |
257 | 55 | Etienne Pallier | </pre> |
258 | 18 | Etienne Pallier | |
259 | 27 | Etienne Pallier | h3. Install needed python packages (from within the virtual environment) |
260 | 18 | Etienne Pallier | |
261 | 66 | Etienne Pallier | First, be sure that the virtual environment is activated: |
262 | 66 | Etienne Pallier | <pre> |
263 | 66 | Etienne Pallier | $ python -V |
264 | 66 | Etienne Pallier | Python 3.5.1 |
265 | 66 | Etienne Pallier | </pre> |
266 | 66 | Etienne Pallier | |
267 | 62 | Etienne Pallier | * *Automatic Installation of all packages* |
268 | 62 | Etienne Pallier | <pre> |
269 | 90 | Etienne Pallier | $ pip install -r REQUIREMENTS.txt |
270 | 62 | Etienne Pallier | </pre> |
271 | 62 | Etienne Pallier | |
272 | 93 | Etienne Pallier | * *Or, manual installation of each package* |
273 | 62 | Etienne Pallier | |
274 | 62 | Etienne Pallier | * *Install Django* : |
275 | 32 | Etienne Pallier | <pre> |
276 | 3 | Etienne Pallier | $ pip install django |
277 | 3 | Etienne Pallier | Collecting django |
278 | 3 | Etienne Pallier | Downloading Django-1.9.4-py2.py3-none-any.whl (6.6MB) |
279 | 3 | Etienne Pallier | Installing collected packages: django |
280 | 3 | Etienne Pallier | Successfully installed django-1.9.4 |
281 | 3 | Etienne Pallier | |
282 | 3 | Etienne Pallier | $ pip install django-admin-tools |
283 | 3 | Etienne Pallier | Collecting django-admin-tools |
284 | 3 | Etienne Pallier | Downloading django_admin_tools-0.7.2-py2.py3-none-any.whl (289kB) |
285 | 3 | Etienne Pallier | Installing collected packages: django-admin-tools |
286 | 3 | Etienne Pallier | Successfully installed django-admin-tools-0.7.2 |
287 | 3 | Etienne Pallier | |
288 | 21 | Etienne Pallier | $ pip install django-debug-toolbar |
289 | 21 | Etienne Pallier | Collecting django-debug-toolbar |
290 | 21 | Etienne Pallier | Downloading django_debug_toolbar-1.4-py2.py3-none-any.whl (212kB) |
291 | 21 | Etienne Pallier | Requirement already satisfied (use --upgrade to upgrade): Django>=1.7 in ./venv_py35_pyros/lib/python3.5/site-packages (from django-debug-toolbar) |
292 | 21 | Etienne Pallier | Collecting sqlparse (from django-debug-toolbar) |
293 | 21 | Etienne Pallier | Downloading sqlparse-0.1.19.tar.gz (58kB) |
294 | 21 | Etienne Pallier | Building wheels for collected packages: sqlparse |
295 | 21 | Etienne Pallier | Running setup.py bdist_wheel for sqlparse ... done |
296 | 21 | Etienne Pallier | Stored in directory: /Users/epallier/Library/Caches/pip/wheels/7b/d4/72/6011bb100dd5fc213164e4bbee13d4e03261dd54ce6a5de6b8 |
297 | 21 | Etienne Pallier | Successfully built sqlparse |
298 | 21 | Etienne Pallier | Installing collected packages: sqlparse, django-debug-toolbar |
299 | 21 | Etienne Pallier | Successfully installed django-debug-toolbar-1.4 sqlparse-0.1.19 |
300 | 21 | Etienne Pallier | |
301 | 21 | Etienne Pallier | $ pip install django-extensions |
302 | 21 | Etienne Pallier | Collecting django-extensions |
303 | 21 | Etienne Pallier | Downloading django_extensions-1.6.1-py2.py3-none-any.whl (202kB) |
304 | 21 | Etienne Pallier | Collecting six>=1.2 (from django-extensions) |
305 | 21 | Etienne Pallier | Downloading six-1.10.0-py2.py3-none-any.whl |
306 | 21 | Etienne Pallier | Installing collected packages: six, django-extensions |
307 | 21 | Etienne Pallier | Successfully installed django-extensions-1.6.1 six-1.10.0 |
308 | 21 | Etienne Pallier | |
309 | 21 | Etienne Pallier | $ pip install django-suit |
310 | 21 | Etienne Pallier | Collecting django-suit |
311 | 21 | Etienne Pallier | Downloading django-suit-0.2.18.tar.gz (587kB) |
312 | 21 | Etienne Pallier | Building wheels for collected packages: django-suit |
313 | 1 | Etienne Pallier | Running setup.py bdist_wheel for django-suit ... done |
314 | 1 | Etienne Pallier | Stored in directory: /Users/epallier/Library/Caches/pip/wheels/12/8b/9a/e02ab0ad9229881638aa040d47d77c8f562999533811927d41 |
315 | 1 | Etienne Pallier | Successfully built django-suit |
316 | 1 | Etienne Pallier | Installing collected packages: django-suit |
317 | 1 | Etienne Pallier | Successfully installed django-suit-0.2.18 |
318 | 21 | Etienne Pallier | |
319 | 32 | Etienne Pallier | </pre> |
320 | 32 | Etienne Pallier | |
321 | 63 | Etienne Pallier | * *Install the web application server gunicorn (will be used in production instead of the dev django web server)* : |
322 | 32 | Etienne Pallier | <pre> |
323 | 25 | Etienne Pallier | $ pip install gunicorn |
324 | 25 | Etienne Pallier | Collecting gunicorn |
325 | 25 | Etienne Pallier | Downloading gunicorn-19.4.5-py2.py3-none-any.whl (112kB) |
326 | 21 | Etienne Pallier | Installing collected packages: gunicorn |
327 | 26 | Etienne Pallier | Successfully installed gunicorn-19.4.5 |
328 | 1 | Etienne Pallier | </pre> |
329 | 1 | Etienne Pallier | |
330 | 63 | Etienne Pallier | * *Install the python mysql client*: |
331 | 32 | Etienne Pallier | <pre> |
332 | 32 | Etienne Pallier | $ pip install mysqlclient |
333 | 72 | Etienne Pallier | ... |
334 | 72 | Etienne Pallier | </pre> |
335 | 33 | Etienne Pallier | |
336 | 73 | Etienne Pallier | * => Issue under Mac OS X: |
337 | 72 | Etienne Pallier | <pre> |
338 | 3 | Etienne Pallier | $ pip install mysqlclient |
339 | 3 | Etienne Pallier | Collecting mysqlclient |
340 | 1 | Etienne Pallier | Downloading mysqlclient-1.3.7.tar.gz (79kB) |
341 | 22 | Etienne Pallier | Building wheels for collected packages: mysqlclient |
342 | 3 | Etienne Pallier | Running setup.py bdist_wheel for mysqlclient ... error |
343 | 3 | Etienne Pallier | … |
344 | 1 | Etienne Pallier | ---------------------------------------- |
345 | 1 | Etienne Pallier | Failed building wheel for mysqlclient |
346 | 1 | Etienne Pallier | Running setup.py clean for mysqlclient |
347 | 1 | Etienne Pallier | Failed to build mysqlclient |
348 | 1 | Etienne Pallier | Installing collected packages: mysqlclient |
349 | 1 | Etienne Pallier | Running setup.py install for mysqlclient ... done |
350 | 1 | Etienne Pallier | Successfully installed mysqlclient-1.3.7 |
351 | 1 | Etienne Pallier | |
352 | 1 | Etienne Pallier | BOUH !!! |
353 | 1 | Etienne Pallier | |
354 | 1 | Etienne Pallier | $ pip install --upgrade wheel |
355 | 1 | Etienne Pallier | Collecting wheel |
356 | 1 | Etienne Pallier | Downloading wheel-0.29.0-py2.py3-none-any.whl (66kB) |
357 | 1 | Etienne Pallier | Installing collected packages: wheel |
358 | 1 | Etienne Pallier | Found existing installation: wheel 0.24.0 |
359 | 1 | Etienne Pallier | Uninstalling wheel-0.24.0: |
360 | 1 | Etienne Pallier | Successfully uninstalled wheel-0.24.0 |
361 | 1 | Etienne Pallier | Successfully installed wheel-0.29.0 |
362 | 1 | Etienne Pallier | |
363 | 1 | Etienne Pallier | $ pip uninstall mysqlclient |
364 | 1 | Etienne Pallier | |
365 | 1 | Etienne Pallier | $ pip install mysqlclient |
366 | 1 | Etienne Pallier | Collecting mysqlclient |
367 | 1 | Etienne Pallier | Using cached mysqlclient-1.3.7.tar.gz |
368 | 1 | Etienne Pallier | Building wheels for collected packages: mysqlclient |
369 | 1 | Etienne Pallier | Running setup.py bdist_wheel for mysqlclient ... done |
370 | 1 | Etienne Pallier | Stored in directory: /Users/epallier/Library/Caches/pip/wheels/9b/06/50/d11418c26cf8f2156b13d4363b5afde8e7e75ebb8540d0228d |
371 | 1 | Etienne Pallier | Successfully built mysqlclient |
372 | 1 | Etienne Pallier | Installing collected packages: mysqlclient |
373 | 1 | Etienne Pallier | Successfully installed mysqlclient-1.3.7 |
374 | 1 | Etienne Pallier | |
375 | 1 | Etienne Pallier | YES !!! |
376 | 1 | Etienne Pallier | |
377 | 1 | Etienne Pallier | </pre> |
378 | 1 | Etienne Pallier | |
379 | 107 | Paul Carensac | * => Issues under Ubuntu: |
380 | 107 | Paul Carensac | <pre> |
381 | 107 | Paul Carensac | $ pip install mysqlclient |
382 | 107 | Paul Carensac | Collecting mysqlclient |
383 | 107 | Paul Carensac | Downloading mysqlclient-1.3.7.tar.gz (79kB) |
384 | 107 | Paul Carensac | 100% |████████████████████████████████| 81kB 1.5MB/s |
385 | 107 | Paul Carensac | Complete output from command python setup.py egg_info: |
386 | 107 | Paul Carensac | /bin/sh: 1: mysql_config: not found |
387 | 107 | Paul Carensac | Traceback (most recent call last): |
388 | 107 | Paul Carensac | File "<string>", line 1, in <module> |
389 | 107 | Paul Carensac | [...] |
390 | 107 | Paul Carensac | ---------------------------------------- |
391 | 107 | Paul Carensac | Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-q6j4inuz/mysqlclient/ |
392 | 1 | Etienne Pallier | |
393 | 108 | Paul Carensac | BOUH !!! |
394 | 108 | Paul Carensac | |
395 | 107 | Paul Carensac | $ sudo apt-get install libmysqlclient-dev |
396 | 108 | Paul Carensac | |
397 | 107 | Paul Carensac | $ pip install mysqlclient |
398 | 107 | Paul Carensac | Collecting mysqlclient |
399 | 107 | Paul Carensac | Using cached mysqlclient-1.3.7.tar.gz |
400 | 107 | Paul Carensac | Building wheels for collected packages: mysqlclient |
401 | 107 | Paul Carensac | Running setup.py bdist_wheel for mysqlclient ... error |
402 | 107 | Paul Carensac | … |
403 | 107 | Paul Carensac | _mysql.c:40:20: fatal error: Python.h: No such file or directory |
404 | 107 | Paul Carensac | #include "Python.h" |
405 | 107 | Paul Carensac | ^ |
406 | 107 | Paul Carensac | compilation terminated. |
407 | 107 | Paul Carensac | error: command 'x86_64-linux-gnu-gcc' failed with exit status 1 |
408 | 107 | Paul Carensac | |
409 | 107 | Paul Carensac | ---------------------------------------- |
410 | 107 | Paul Carensac | Command "/home/carens_p/pyros/venv_py35_pyros/bin/python3.5 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-k3klv92j/mysqlclient/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-gz242xxs-record/install-record.txt --single-version-externally-managed --compile --install-headers /home/carens_p/pyros/venv_py35_pyros/include/site/python3.5/mysqlclient" failed with error code 1 in /tmp/pip-build-k3klv92j/mysqlclient/ |
411 | 107 | Paul Carensac | |
412 | 108 | Paul Carensac | BOUH !!! |
413 | 108 | Paul Carensac | |
414 | 107 | Paul Carensac | $ sudo apt-get install python3.5-dev |
415 | 108 | Paul Carensac | |
416 | 107 | Paul Carensac | $ pip install mysqlclient |
417 | 107 | Paul Carensac | |
418 | 107 | Paul Carensac | YES !!! |
419 | 107 | Paul Carensac | |
420 | 107 | Paul Carensac | </pre> |
421 | 12 | Etienne Pallier | |
422 | 82 | Etienne Pallier | * *Set Requirements* |
423 | 82 | Etienne Pallier | |
424 | 82 | Etienne Pallier | <pre> |
425 | 82 | Etienne Pallier | $ pip freeze > REQUIREMENTS.txt |
426 | 82 | Etienne Pallier | </pre> |
427 | 12 | Etienne Pallier | |
428 | 12 | Etienne Pallier | --- |
429 | 28 | Etienne Pallier | |
430 | 7 | Etienne Pallier | h3. Create Django project pyros |
431 | 38 | Etienne Pallier | |
432 | 38 | Etienne Pallier | <pre> |
433 | 1 | Etienne Pallier | |
434 | 83 | Etienne Pallier | From inside the project: |
435 | 83 | Etienne Pallier | $ pwd |
436 | 83 | Etienne Pallier | .../PYROS/ |
437 | 83 | Etienne Pallier | |
438 | 1 | Etienne Pallier | $ django-admin startproject pyros |
439 | 1 | Etienne Pallier | |
440 | 149 | Etienne Pallier | Rename the project folder "pyros/" as "src/" |
441 | 149 | Etienne Pallier | |
442 | 84 | Etienne Pallier | $ mv pyros src |
443 | 84 | Etienne Pallier | |
444 | 1 | Etienne Pallier | We have then this architecture: |
445 | 86 | Etienne Pallier | |
446 | 86 | Etienne Pallier | PYROS |
447 | 172 | Etienne Pallier | ├── REQUIREMENTS.txt |
448 | 86 | Etienne Pallier | ├── private |
449 | 137 | Etienne Pallier | │ └── venv_py35_pyros |
450 | 83 | Etienne Pallier | ├── public |
451 | 83 | Etienne Pallier | │ └── static |
452 | 83 | Etienne Pallier | ├── src |
453 | 83 | Etienne Pallier | │ ├── manage.py |
454 | 1 | Etienne Pallier | │ ├── pyros |
455 | 84 | Etienne Pallier | │ │ ├── __init__.py |
456 | 84 | Etienne Pallier | │ │ ├── settings.py |
457 | 84 | Etienne Pallier | │ │ ├── urls.py |
458 | 1 | Etienne Pallier | │ │ └── wsgi.py |
459 | 137 | Etienne Pallier | |
460 | 142 | Etienne Pallier | </pre> |
461 | 3 | Etienne Pallier | |
462 | 3 | Etienne Pallier | |
463 | 1 | Etienne Pallier | |
464 | 142 | Etienne Pallier | |
465 | 142 | Etienne Pallier | --- |
466 | 142 | Etienne Pallier | |
467 | 142 | Etienne Pallier | h3. Test the project |
468 | 142 | Etienne Pallier | |
469 | 142 | Etienne Pallier | <pre> |
470 | 142 | Etienne Pallier | |
471 | 150 | Etienne Pallier | $ cd src/ |
472 | 150 | Etienne Pallier | |
473 | 1 | Etienne Pallier | $ ./manage.py runserver |
474 | 38 | Etienne Pallier | (or gunicorn pyros.wsgi) |
475 | 3 | Etienne Pallier | ==> http://localhost:8000 |
476 | 87 | Etienne Pallier | ... |
477 | 87 | Etienne Pallier | ... |
478 | 87 | Etienne Pallier | Ctrl-c |
479 | 87 | Etienne Pallier | |
480 | 1 | Etienne Pallier | </pre> |
481 | 142 | Etienne Pallier | |
482 | 142 | Etienne Pallier | |
483 | 142 | Etienne Pallier | |
484 | 142 | Etienne Pallier | --- |
485 | 142 | Etienne Pallier | |
486 | 142 | Etienne Pallier | h3. The Web server |
487 | 142 | Etienne Pallier | |
488 | 142 | Etienne Pallier | |
489 | 142 | Etienne Pallier | Apache : gère tous les fichiers statiques (images, html…), et délègue les fichiers python au serveur django (par défaut) |
490 | 142 | Etienne Pallier | |
491 | 143 | Etienne Pallier | Le fichier pyros/urls.py prend le relai pour tout ce qui est django |
492 | 143 | Etienne Pallier | |
493 | 142 | Etienne Pallier | Le moteur web django sera soit du wsgi soit du unicorn |
494 | 142 | Etienne Pallier | |
495 | 142 | Etienne Pallier | Par défaut, 1 seul worker, mais on peut en configurer plusieurs, l’idéal étant de faire "nb coeurs + 1" |
496 | 142 | Etienne Pallier | (le worker maître qui fait le dispatching aux autres) |
497 | 142 | Etienne Pallier | |
498 | 142 | Etienne Pallier | Frontend : Apache ou Ngininx |
499 | 142 | Etienne Pallier | |
500 | 142 | Etienne Pallier | Backend : gunicorn (gère facilement des workers) ou uwsgi |
501 | 142 | Etienne Pallier | |
502 | 152 | Etienne Pallier | <pre> |
503 | 152 | Etienne Pallier | $ gunicorn pyros.wsgi |
504 | 1 | Etienne Pallier | (à la place de manage runserver => A EVITER EN PROD) |
505 | 152 | Etienne Pallier | |
506 | 1 | Etienne Pallier | Ou encore: |
507 | 1 | Etienne Pallier | |
508 | 152 | Etienne Pallier | $ gunicorn --workers 5 library.wsgi |
509 | 152 | Etienne Pallier | </pre> |
510 | 3 | Etienne Pallier | |
511 | 42 | Etienne Pallier | --- |
512 | 7 | Etienne Pallier | |
513 | 3 | Etienne Pallier | h3. Set Database engine as MySql |
514 | 3 | Etienne Pallier | |
515 | 41 | Etienne Pallier | Edit src/pyros/settings.py |
516 | 3 | Etienne Pallier | |
517 | 3 | Etienne Pallier | <pre> |
518 | 3 | Etienne Pallier | DATABASES = { |
519 | 1 | Etienne Pallier | 'default': { |
520 | 3 | Etienne Pallier | 'ENGINE': 'django.db.backends.mysql', |
521 | 1 | Etienne Pallier | 'NAME': 'pyros', |
522 | 1 | Etienne Pallier | 'USER': 'root', |
523 | 1 | Etienne Pallier | 'PASSWORD': '' |
524 | 41 | Etienne Pallier | } |
525 | 3 | Etienne Pallier | } |
526 | 7 | Etienne Pallier | </pre> |
527 | 3 | Etienne Pallier | |
528 | 43 | Etienne Pallier | --- |
529 | 7 | Etienne Pallier | |
530 | 43 | Etienne Pallier | h3. Import database into Django (with inspectdb) |
531 | 3 | Etienne Pallier | |
532 | 101 | Etienne Pallier | From src/ : |
533 | 94 | Etienne Pallier | |
534 | 3 | Etienne Pallier | <pre> |
535 | 44 | Etienne Pallier | $ ./manage.py inspectdb > models.py |
536 | 94 | Etienne Pallier | </pre> |
537 | 44 | Etienne Pallier | |
538 | 97 | Etienne Pallier | Issue on Mac OS X: |
539 | 3 | Etienne Pallier | <pre> |
540 | 3 | Etienne Pallier | Traceback (most recent call last): |
541 | 3 | Etienne Pallier | File "/Users/epallier/Documents/_W_more/PROJECTS/GFT/SOFT/PYROS/pyros/venv_py35_pyros/lib/python3.5/site-packages/django/db/backends/mysql/base.py", line 25, in <module> |
542 | 3 | Etienne Pallier | import MySQLdb as Database |
543 | 3 | Etienne Pallier | File "/Users/epallier/Documents/_W_more/PROJECTS/GFT/SOFT/PYROS/pyros/venv_py35_pyros/lib/python3.5/site-packages/MySQLdb/__init__.py", line 19, in <module> |
544 | 3 | Etienne Pallier | import _mysql |
545 | 3 | Etienne Pallier | ImportError: dlopen(/Users/epallier/Documents/_W_more/PROJECTS/GFT/SOFT/PYROS/pyros/venv_py35_pyros/lib/python3.5/site-packages/_mysql.cpython-35m-darwin.so, 2): Library not loaded: libmysqlclient.18.dylib |
546 | 3 | Etienne Pallier | Referenced from: /Users/epallier/Documents/_W_more/PROJECTS/GFT/SOFT/PYROS/pyros/venv_py35_pyros/lib/python3.5/site-packages/_mysql.cpython-35m-darwin.so |
547 | 3 | Etienne Pallier | Reason: image not found |
548 | 3 | Etienne Pallier | |
549 | 3 | Etienne Pallier | => BOUH !!! |
550 | 3 | Etienne Pallier | |
551 | 3 | Etienne Pallier | LA SOLUTION EST ICI : http://stackoverflow.com/questions/6383310/python-mysqldb-library-not-loaded-libmysqlclient-18-dylib |
552 | 3 | Etienne Pallier | |
553 | 124 | Etienne Pallier | Il suffit de faire ceci: |
554 | 3 | Etienne Pallier | |
555 | 124 | Etienne Pallier | $ sudo mkdir -p /usr/local/lib |
556 | 124 | Etienne Pallier | $ sudo ln -s /Applications/XAMPP/xamppfiles/lib/libmysql* /usr/local/lib/ |
557 | 124 | Etienne Pallier | |
558 | 124 | Etienne Pallier | Mais on peut aussi faire ceci: |
559 | 3 | Etienne Pallier | |
560 | 123 | Etienne Pallier | Okay, so the offending file is /Users/epallier/Documents/_W_more/PROJECTS/GFT/SOFT/PYROS/pyros/venv_py35_pyros/lib/python3.5/site-packages/_mysql.cpython-35m-darwin.so |
561 | 123 | Etienne Pallier | |
562 | 123 | Etienne Pallier | Next, figure out where _mysql.so thinks it should find libmysqlclient.18.dylib: |
563 | 123 | Etienne Pallier | |
564 | 1 | Etienne Pallier | $ otool -L /Users/epallier/Documents/_W_more/PROJECTS/GFT/SOFT/PYROS/pyros/venv_py35_pyros/lib/python3.5/site-packages/_mysql.cpython-35m-darwin.so |
565 | 10 | Etienne Pallier | /Users/epallier/Documents/_W_more/PROJECTS/GFT/SOFT/PYROS/pyros/venv_py35_pyros/lib/python3.5/site-packages/_mysql.cpython-35m-darwin.so: |
566 | 3 | Etienne Pallier | libmysqlclient.18.dylib (compatibility version 18.0.0, current version 18.0.0) |
567 | 3 | Etienne Pallier | ... |
568 | 3 | Etienne Pallier | |
569 | 123 | Etienne Pallier | So, it's looking for libmysqlclient.18.dylib with no path information, let's fix that: |
570 | 123 | Etienne Pallier | |
571 | 1 | Etienne Pallier | $ locate libmysqlclient.18.dylib |
572 | 1 | Etienne Pallier | /Applications/XAMPP/xamppfiles/lib/libmysqlclient.18.dylib |
573 | 1 | Etienne Pallier | /Library/SystemMigration/History/Migration-68137DFB-CB6A-4FBB-81E2-11BDB5D01E48/QuarantineRoot/usr/lib/libmysqlclient.18.dylib |
574 | 1 | Etienne Pallier | |
575 | 10 | Etienne Pallier | $ sudo install_name_tool -change libmysqlclient.18.dylib /Applications/XAMPP/xamppfiles/lib/libmysqlclient.18.dylib /Users/epallier/Documents/_W_more/PROJECTS/GFT/SOFT/PYROS/pyros/venv_py35_pyros/lib/python3.5/site-packages/_mysql.cpython-35m-darwin.so |
576 | 123 | Etienne Pallier | |
577 | 123 | Etienne Pallier | Now _mysql.so knows the full path to the library and everything works, regardless of environment variables. |
578 | 10 | Etienne Pallier | |
579 | 10 | Etienne Pallier | $ otool -L /Users/epallier/Documents/_W_more/PROJECTS/GFT/SOFT/PYROS/pyros/venv_py35_pyros/lib/python3.5/site-packages/_mysql.cpython-35m-darwin.so |
580 | 10 | Etienne Pallier | /Users/epallier/Documents/_W_more/PROJECTS/GFT/SOFT/PYROS/pyros/venv_py35_pyros/lib/python3.5/site-packages/_mysql.cpython-35m-darwin.so: |
581 | 3 | Etienne Pallier | /Applications/XAMPP/xamppfiles/lib/libmysqlclient.18.dylib (compatibility version 18.0.0, current version 18.0.0) |
582 | 1 | Etienne Pallier | ... |
583 | 1 | Etienne Pallier | |
584 | 3 | Etienne Pallier | $ ./manage.py inspectdb > models.py |
585 | 44 | Etienne Pallier | |
586 | 3 | Etienne Pallier | => YES !!! |
587 | 3 | Etienne Pallier | </pre> |
588 | 7 | Etienne Pallier | |
589 | 3 | Etienne Pallier | |
590 | 48 | Etienne Pallier | --- |
591 | 7 | Etienne Pallier | |
592 | 3 | Etienne Pallier | h3. Create a Django application pyrosapp |
593 | 3 | Etienne Pallier | |
594 | 102 | Etienne Pallier | From src/ : |
595 | 98 | Etienne Pallier | |
596 | 102 | Etienne Pallier | <pre> |
597 | 1 | Etienne Pallier | $ ./manage.py startapp pyrosapp |
598 | 1 | Etienne Pallier | </pre> |
599 | 1 | Etienne Pallier | |
600 | 103 | Etienne Pallier | We obtain this structure: |
601 | 1 | Etienne Pallier | |
602 | 103 | Etienne Pallier | <pre> |
603 | 104 | Etienne Pallier | |
604 | 103 | Etienne Pallier | PYROS/ |
605 | 172 | Etienne Pallier | ├── REQUIREMENTS.txt |
606 | 1 | Etienne Pallier | ├── private/ |
607 | 153 | Etienne Pallier | │ └── venv_py35_pyros/ |
608 | 153 | Etienne Pallier | ├── public/ |
609 | 153 | Etienne Pallier | │ └── static/ |
610 | 103 | Etienne Pallier | ├── src/ |
611 | 103 | Etienne Pallier | │ ├── manage.py |
612 | 153 | Etienne Pallier | │ ├── pyros/ |
613 | 103 | Etienne Pallier | │ │ ├── __init__.py |
614 | 103 | Etienne Pallier | │ │ ├── __pycache__ |
615 | 103 | Etienne Pallier | │ │ ├── settings.py |
616 | 103 | Etienne Pallier | │ │ ├── urls.py |
617 | 103 | Etienne Pallier | │ │ └── wsgi.py |
618 | 153 | Etienne Pallier | │ └── pyrosapp/ |
619 | 1 | Etienne Pallier | │ ├── __init__.py |
620 | 103 | Etienne Pallier | │ ├── admin.py |
621 | 103 | Etienne Pallier | │ ├── apps.py |
622 | 103 | Etienne Pallier | │ ├── migrations |
623 | 103 | Etienne Pallier | │ ├── models.py |
624 | 103 | Etienne Pallier | │ ├── tests.py |
625 | 103 | Etienne Pallier | │ └── views.py |
626 | 153 | Etienne Pallier | |
627 | 103 | Etienne Pallier | |
628 | 7 | Etienne Pallier | </pre> |
629 | 1 | Etienne Pallier | |
630 | 7 | Etienne Pallier | --- |
631 | 7 | Etienne Pallier | |
632 | 3 | Etienne Pallier | h3. Replace the default pyrosapp models.py with the inspectdb generated one |
633 | 3 | Etienne Pallier | |
634 | 105 | Etienne Pallier | From src/ : |
635 | 1 | Etienne Pallier | |
636 | 105 | Etienne Pallier | <pre> |
637 | 105 | Etienne Pallier | $ mv models.py pyrosapp/ |
638 | 105 | Etienne Pallier | </pre> |
639 | 3 | Etienne Pallier | |
640 | 139 | Paul Carensac | Add pyrosapp to the project's applications : |
641 | 7 | Etienne Pallier | |
642 | 139 | Paul Carensac | Edit src/pyros/settings.py |
643 | 1 | Etienne Pallier | |
644 | 139 | Paul Carensac | <pre> |
645 | 139 | Paul Carensac | INSTALLED_APPS = [ |
646 | 139 | Paul Carensac | 'django.contrib.admin', |
647 | 139 | Paul Carensac | 'django.contrib.auth', |
648 | 139 | Paul Carensac | 'django.contrib.contenttypes', |
649 | 139 | Paul Carensac | 'django.contrib.sessions', |
650 | 139 | Paul Carensac | 'django.contrib.messages', |
651 | 139 | Paul Carensac | 'django.contrib.staticfiles', |
652 | 139 | Paul Carensac | 'pyrosapp', |
653 | 139 | Paul Carensac | ] |
654 | 139 | Paul Carensac | </pre> |
655 | 9 | Etienne Pallier | |
656 | 47 | Etienne Pallier | --- |
657 | 3 | Etienne Pallier | |
658 | 145 | Paul Carensac | h3. Fix and improve the pyrosapp models.py file (generated by inspectdb) |
659 | 1 | Etienne Pallier | |
660 | 145 | Paul Carensac | Once models.py file generated, we need to delete the database and create an empty one : |
661 | 145 | Paul Carensac | |
662 | 145 | Paul Carensac | <pre> |
663 | 145 | Paul Carensac | $ mysql -u root [-p (if password needed)] |
664 | 106 | Etienne Pallier | |
665 | 145 | Paul Carensac | mysql> DROP DATABSE pyros |
666 | 145 | Paul Carensac | mysql> CREATE SCHEMA IF NOT EXISTS 'pyros' DEFAULT CHARACTER SET utf8; |
667 | 1 | Etienne Pallier | |
668 | 145 | Paul Carensac | </pre> |
669 | 1 | Etienne Pallier | |
670 | 145 | Paul Carensac | Then edit pyrosapp/models.py : |
671 | 1 | Etienne Pallier | |
672 | 145 | Paul Carensac | * Change 'managed = False' to 'managed = True' for every model |
673 | 145 | Paul Carensac | |
674 | 145 | Paul Carensac | * Change classes names to CamelCase (do not change the 'db_table = ...' lines). *Be careful* : it is needed to change all occurences : |
675 | 145 | Paul Carensac | |
676 | 145 | Paul Carensac | * NrtAlanysis |
677 | 145 | Paul Carensac | * ScheduleHistory |
678 | 145 | Paul Carensac | * ScientificProgram |
679 | 145 | Paul Carensac | * SequenceType |
680 | 145 | Paul Carensac | * SiteWatch |
681 | 145 | Paul Carensac | * SiteWatchHistory |
682 | 145 | Paul Carensac | * StrategyObs |
683 | 154 | Paul Carensac | * UserLevel |
684 | 145 | Paul Carensac | * WeatherWatch |
685 | 145 | Paul Carensac | * WeatherWatchHistory |
686 | 145 | Paul Carensac | |
687 | 145 | Paul Carensac | * Change the deleting mode from 'models.DO_NOTHING' to 'models.CASCADE' for the following foreign keys : |
688 | 145 | Paul Carensac | |
689 | 145 | Paul Carensac | * Image.plan |
690 | 145 | Paul Carensac | * Plan.album |
691 | 145 | Paul Carensac | * Album.sequence |
692 | 145 | Paul Carensac | * Sequence.request |
693 | 145 | Paul Carensac | |
694 | 145 | Paul Carensac | * Change the 'ForeignKey' liaisons to 'OneToOneField' liaisons (just replace ForeignKey by OneToOneField), and change deleting mode to 'models.CASCADE' for the following foreign keys : |
695 | 145 | Paul Carensac | |
696 | 145 | Paul Carensac | * Alert.request |
697 | 145 | Paul Carensac | * Detector.device |
698 | 145 | Paul Carensac | * Filter.device |
699 | 145 | Paul Carensac | * Telescope.device |
700 | 145 | Paul Carensac | |
701 | 145 | Paul Carensac | * We need to redefine many to many relationships for the following classes : |
702 | 145 | Paul Carensac | |
703 | 145 | Paul Carensac | * User - ScientificProgram : |
704 | 145 | Paul Carensac | |
705 | 145 | Paul Carensac | * add 'users = models.ManyToManyField('User')' in ScientificProgram class |
706 | 145 | Paul Carensac | * delete UserHasScientificProgram class |
707 | 145 | Paul Carensac | |
708 | 145 | Paul Carensac | * Sequence - ScheduleHistory |
709 | 145 | Paul Carensac | |
710 | 145 | Paul Carensac | * add 'sequences = models.ManyToManyField('Sequence')' in ScheduleHistory class |
711 | 145 | Paul Carensac | * delete ScheduleHasSequences class |
712 | 145 | Paul Carensac | |
713 | 145 | Paul Carensac | * Finally apply modifications to the database : |
714 | 145 | Paul Carensac | |
715 | 145 | Paul Carensac | <pre> |
716 | 145 | Paul Carensac | $ pwd |
717 | 145 | Paul Carensac | .../PYROS/src |
718 | 145 | Paul Carensac | $ python manage.py makemigrations pyrosapp |
719 | 145 | Paul Carensac | $ python manage.py migrate |
720 | 145 | Paul Carensac | </pre> |
721 | 109 | Etienne Pallier | |
722 | 109 | Etienne Pallier | --- |
723 | 111 | Etienne Pallier | |
724 | 156 | Paul Carensac | h2. %{margin-left:0px; font-weight:bold; font-size:25px; display:block; color:red;}IV - CONFIGURATION of the Django Back Office (administration interface)% |
725 | 155 | Paul Carensac | |
726 | 155 | Paul Carensac | --- |
727 | 155 | Paul Carensac | |
728 | 155 | Paul Carensac | h3. Back Office setup |
729 | 155 | Paul Carensac | |
730 | 155 | Paul Carensac | * Prerequisites in src/pyros/settings.py : |
731 | 155 | Paul Carensac | |
732 | 155 | Paul Carensac | * INSTALLED_APPS must (at least) contain : |
733 | 155 | Paul Carensac | |
734 | 155 | Paul Carensac | * django.contrib.admin |
735 | 155 | Paul Carensac | * django.contrib.auth |
736 | 155 | Paul Carensac | * django.contrib.contenttypes |
737 | 155 | Paul Carensac | * django.contrib.sessions |
738 | 155 | Paul Carensac | |
739 | 155 | Paul Carensac | * MIDDLEWARES must (at least) contain : |
740 | 155 | Paul Carensac | |
741 | 155 | Paul Carensac | * django.contrib.sessions.middleware.SessionMiddleware |
742 | 155 | Paul Carensac | * django.middleware.common.CommonMiddleware |
743 | 155 | Paul Carensac | * django.contrib.auth.middleware.AuthenticationMiddleware |
744 | 155 | Paul Carensac | |
745 | 155 | Paul Carensac | * At least one 'python manage.py migrate' must have been executed |
746 | 155 | Paul Carensac | |
747 | 155 | Paul Carensac | * Create a superuser for the administration : |
748 | 155 | Paul Carensac | |
749 | 155 | Paul Carensac | <pre> |
750 | 155 | Paul Carensac | $ python manage.py createsuperuser |
751 | 155 | Paul Carensac | </pre> |
752 | 155 | Paul Carensac | |
753 | 156 | Paul Carensac | * For each app of the project, fill the admin.py file : |
754 | 155 | Paul Carensac | |
755 | 155 | Paul Carensac | <pre> |
756 | 155 | Paul Carensac | from django.contrib import admin |
757 | 155 | Paul Carensac | from app.models import Model1, Model2 |
758 | 155 | Paul Carensac | |
759 | 155 | Paul Carensac | admin.site.register(Model1) |
760 | 155 | Paul Carensac | admin.site.register(Model2) |
761 | 155 | Paul Carensac | </pre> |
762 | 155 | Paul Carensac | |
763 | 155 | Paul Carensac | *Reminder* : each application must be registered in the settings.py INSTALLED_APPS variable. |
764 | 157 | Paul Carensac | |
765 | 168 | Paul Carensac | * For each model in models.py, add a '__str__()' method in order to identify the object on the back office. Example : |
766 | 157 | Paul Carensac | |
767 | 157 | Paul Carensac | <pre> |
768 | 157 | Paul Carensac | class UserLevel(models.Model): |
769 | 157 | Paul Carensac | name = models.CharField(max_length=45, blank=True, null=True) |
770 | 157 | Paul Carensac | desc = models.TextField(blank=True, null=True) |
771 | 157 | Paul Carensac | priority = models.IntegerField(blank=True, null=True) |
772 | 157 | Paul Carensac | quota = models.FloatField(blank=True, null=True) |
773 | 157 | Paul Carensac | |
774 | 157 | Paul Carensac | class Meta: |
775 | 157 | Paul Carensac | managed = True |
776 | 157 | Paul Carensac | db_table = 'userlevel' |
777 | 157 | Paul Carensac | |
778 | 157 | Paul Carensac | def __str__(self): |
779 | 163 | Paul Carensac | return (str(self.name)) |
780 | 157 | Paul Carensac | </pre> |
781 | 157 | Paul Carensac | |
782 | 159 | Paul Carensac | *Naming convention* : Use self.name when possible, the creation time/date otherwise. Example : |
783 | 159 | Paul Carensac | |
784 | 159 | Paul Carensac | <pre> |
785 | 159 | Paul Carensac | class SiteWatch(models.Model): |
786 | 159 | Paul Carensac | updated = models.DateTimeField(blank=True, null=True) |
787 | 159 | Paul Carensac | lights = models.CharField(max_length=45, blank=True, null=True) |
788 | 159 | Paul Carensac | dome = models.CharField(max_length=45, blank=True, null=True) |
789 | 159 | Paul Carensac | doors = models.CharField(max_length=45, blank=True, null=True) |
790 | 159 | Paul Carensac | temperature = models.FloatField(blank=True, null=True) |
791 | 159 | Paul Carensac | |
792 | 159 | Paul Carensac | class Meta: |
793 | 159 | Paul Carensac | managed = True |
794 | 159 | Paul Carensac | db_table = 'sitewatch' |
795 | 159 | Paul Carensac | |
796 | 159 | Paul Carensac | def __str__(self): |
797 | 160 | Paul Carensac | return (str(self.updated)) |
798 | 159 | Paul Carensac | </pre> |
799 | 173 | Etienne Pallier | |
800 | 176 | Etienne Pallier | h2. %{margin-left:0px; font-weight:bold; font-size:25px; display:block; color:red;}V - INSTALLATION FROM THE BEGINNING (for dev only)% |
801 | 173 | Etienne Pallier | |
802 | 1 | Etienne Pallier | |
803 | 176 | Etienne Pallier | h3. How the git repository was created |
804 | 176 | Etienne Pallier | |
805 | 176 | Etienne Pallier | *Git global setup:* |
806 | 176 | Etienne Pallier | |
807 | 176 | Etienne Pallier | <pre> |
808 | 176 | Etienne Pallier | $ git config --global user.name "Etienne Pallier" |
809 | 176 | Etienne Pallier | $ git config --global user.email "etienne.pallier@irap.omp.eu" |
810 | 176 | Etienne Pallier | |
811 | 176 | Etienne Pallier | $ cat ~/.gitconfig |
812 | 176 | Etienne Pallier | [user] |
813 | 176 | Etienne Pallier | name = Etienne Pallier |
814 | 176 | Etienne Pallier | email = epallier@irap.omp.eu |
815 | 176 | Etienne Pallier | [http] |
816 | 176 | Etienne Pallier | sslVerify = false |
817 | 176 | Etienne Pallier | </pre> |
818 | 176 | Etienne Pallier | |
819 | 176 | Etienne Pallier | |
820 | 176 | Etienne Pallier | *Create a new repository:* |
821 | 176 | Etienne Pallier | |
822 | 176 | Etienne Pallier | <pre> |
823 | 176 | Etienne Pallier | $ cd PYROS/ |
824 | 176 | Etienne Pallier | |
825 | 176 | Etienne Pallier | Define files and folders to be ignored: |
826 | 176 | Etienne Pallier | $ vi .gitignore |
827 | 176 | Etienne Pallier | .DS_Store |
828 | 176 | Etienne Pallier | private |
829 | 176 | Etienne Pallier | __pycache__ |
830 | 176 | Etienne Pallier | |
831 | 176 | Etienne Pallier | $ touch README.md |
832 | 176 | Etienne Pallier | |
833 | 176 | Etienne Pallier | $ git add README.md |
834 | 176 | Etienne Pallier | |
835 | 176 | Etienne Pallier | $ git commit -m "first commit" |
836 | 176 | Etienne Pallier | |
837 | 176 | Etienne Pallier | $ git remote add origin https://gitlab.irap.omp.eu/epallier/pyros.git |
838 | 176 | Etienne Pallier | |
839 | 176 | Etienne Pallier | $ git push -u origin master |
840 | 176 | Etienne Pallier | |
841 | 176 | Etienne Pallier | $ git add . |
842 | 176 | Etienne Pallier | |
843 | 176 | Etienne Pallier | ( if you want to be sure to add ALL files: |
844 | 176 | Etienne Pallier | $ git add -A |
845 | 176 | Etienne Pallier | ) |
846 | 176 | Etienne Pallier | |
847 | 176 | Etienne Pallier | ( if you wanted to remove added files, just type: |
848 | 176 | Etienne Pallier | $ git reset HEAD |
849 | 176 | Etienne Pallier | ) |
850 | 176 | Etienne Pallier | |
851 | 176 | Etienne Pallier | $ git commit -m "first full project commit" |
852 | 176 | Etienne Pallier | |
853 | 176 | Etienne Pallier | $ git push -u origin master |
854 | 176 | Etienne Pallier | Counting objects: 43, done. |
855 | 176 | Etienne Pallier | Delta compression using up to 4 threads. |
856 | 176 | Etienne Pallier | Compressing objects: 100% (41/41), done. |
857 | 176 | Etienne Pallier | Writing objects: 100% (43/43), 575.13 KiB ö 0 bytes/s, done. |
858 | 176 | Etienne Pallier | Total 43 (delta 2), reused 0 (delta 0) |
859 | 176 | Etienne Pallier | To https://gitlab.irap.omp.eu/epallier/pyros.git |
860 | 176 | Etienne Pallier | 9c7128c..64501c9 master -> master |
861 | 176 | Etienne Pallier | Branch master set up to track remote branch master from origin. |
862 | 176 | Etienne Pallier | |
863 | 176 | Etienne Pallier | $ git status |
864 | 176 | Etienne Pallier | On branch master |
865 | 176 | Etienne Pallier | Your branch is up-to-date with 'origin/master'. |
866 | 176 | Etienne Pallier | nothing to commit, working directory clean |
867 | 176 | Etienne Pallier | |
868 | 176 | Etienne Pallier | |
869 | 176 | Etienne Pallier | </pre> |