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