Wiki

Version 252 (Etienne Pallier, 03/22/2016 07:17 pm)

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 251 Etienne Pallier
 * Intégration dans Eclipse
14 125 Etienne Pallier
15 251 Etienne Pallier
 * Séparation des BD Django et Pyros
16 126 Etienne Pallier
17 174 Etienne Pallier
 * Intégration des modules Django déjà développés
18 125 Etienne Pallier
19 121 Etienne Pallier
20 3 Etienne Pallier
---
21 1 Etienne Pallier
22 140 Etienne Pallier
h2. %{margin-left:0px; font-weight:bold; font-size:25px;  display:block; color:red;}I - DATABASE SCHEMA (v0.2.1)%
23 116 Etienne Pallier
24 116 Etienne Pallier
25 117 Etienne Pallier
{{thumbnail(PYROS_PDM_v021.png, size=300, title=Pyros data model)}}
26 121 Etienne Pallier
27 121 Etienne Pallier
28 121 Etienne Pallier
---
29 116 Etienne Pallier
30 141 Etienne Pallier
h2. %{margin-left:0px; font-weight:bold; font-size:25px;  display:block; color:red;}II - Get the project (from gitlab)%
31 141 Etienne Pallier
32 169 Etienne Pallier
h3. Get the project from the terminal
33 1 Etienne Pallier
34 1 Etienne Pallier
<pre>
35 1 Etienne Pallier
git clone https://gitlab.irap.omp.eu/epallier/pyros.git PYROS
36 169 Etienne Pallier
37 174 Etienne Pallier
(or also : git clone git@gitlab.irap.omp.eu:epallier/pyros.git)
38 1 Etienne Pallier
</pre>
39 1 Etienne Pallier
40 197 Etienne Pallier
This creates a PYROS/ folder containing the project (with a .git/ subfolder for synchronization with the git repository)
41 1 Etienne Pallier
42 225 Etienne Pallier
_If you just wanted a static copy of the project (without synchronization) just remove the .git/ folder:_
43 1 Etienne Pallier
<pre>
44 1 Etienne Pallier
$ rm -r .git/
45 1 Etienne Pallier
</pre>
46 226 Etienne Pallier
47 226 Etienne Pallier
You should obtain this structure:
48 226 Etienne Pallier
49 226 Etienne Pallier
<pre>
50 226 Etienne Pallier
51 226 Etienne Pallier
PYROS/
52 226 Etienne Pallier
├── REQUIREMENTS.txt
53 226 Etienne Pallier
├── private/
54 226 Etienne Pallier
│   └── venv_py35_pyros/
55 226 Etienne Pallier
├── public/
56 226 Etienne Pallier
│   └── static/
57 226 Etienne Pallier
├── src/
58 226 Etienne Pallier
│   ├── manage.py
59 226 Etienne Pallier
│   ├── pyros/
60 226 Etienne Pallier
│   │   ├── __init__.py
61 226 Etienne Pallier
│   │   ├── __pycache__
62 226 Etienne Pallier
│   │   ├── settings.py
63 226 Etienne Pallier
│   │   ├── urls.py
64 226 Etienne Pallier
│   │   └── wsgi.py
65 226 Etienne Pallier
│   └── pyrosapp/
66 226 Etienne Pallier
│       ├── __init__.py
67 226 Etienne Pallier
│       ├── admin.py
68 226 Etienne Pallier
│       ├── apps.py
69 226 Etienne Pallier
│       ├── migrations
70 226 Etienne Pallier
│       ├── models.py
71 226 Etienne Pallier
│       ├── tests.py
72 226 Etienne Pallier
│       └── views.py
73 226 Etienne Pallier
74 226 Etienne Pallier
75 226 Etienne Pallier
</pre>
76 226 Etienne Pallier
77 1 Etienne Pallier
h3. Get the project from Eclipse
78 252 Etienne Pallier
ECLIPSE
79 1 Etienne Pallier
80 252 Etienne Pallier
File/Import project from git
81 252 Etienne Pallier
82 252 Etienne Pallier
Select repository source:
83 252 Etienne Pallier
Clone URI
84 252 Etienne Pallier
85 252 Etienne Pallier
URI: https://gitlab.irap.omp.eu/epallier/pyros.git
86 252 Etienne Pallier
87 252 Etienne Pallier
Directory: 
88 252 Etienne Pallier
par défaut, il propose : /Users/epallier/git/pyros
89 252 Etienne Pallier
mais je préfère le mettre ailleurs
90 252 Etienne Pallier
91 252 Etienne Pallier
initial branch: master
92 252 Etienne Pallier
remote name: origin
93 252 Etienne Pallier
94 252 Etienne Pallier
Import as general project
95 252 Etienne Pallier
96 252 Etienne Pallier
Project name: PYROS
97 252 Etienne Pallier
98 252 Etienne Pallier
The project is created. Now, you have to set it as a «PyDev » and a « Django » project.
99 252 Etienne Pallier
100 252 Etienne Pallier
clic droit sur le projet / PyDev / set as a PyDev project
101 252 Etienne Pallier
102 252 Etienne Pallier
clic droit sur le projet / PyDev / set as a Django project
103 252 Etienne Pallier
104 252 Etienne Pallier
clic droit sur le projet : on doit maintenant avoir un sous-menu Django
105 252 Etienne Pallier
106 252 Etienne Pallier
clic droit sur le dossier src / PyDev / set as source folder (add to PYTHONPATH)
107 252 Etienne Pallier
108 252 Etienne Pallier
clic droit sur projet / Properties / Pydev-Django :
109 252 Etienne Pallier
- Django manage.py : src/manage.py
110 252 Etienne Pallier
- Django settings module : pyros.settings
111 252 Etienne Pallier
112 252 Etienne Pallier
RUN SERVER :
113 252 Etienne Pallier
clic droit sur projet, Django/Custom command/runserver
114 252 Etienne Pallier
115 252 Etienne Pallier
check http://localhost:8000/
116 252 Etienne Pallier
117 252 Etienne Pallier
118 252 Etienne Pallier
119 252 Etienne Pallier
mkdir private
120 252 Etienne Pallier
121 252 Etienne Pallier
sudo port install py35-virtualenv
122 252 Etienne Pallier
123 252 Etienne Pallier
virtualenv-3.5 venv_py35_pyros -p /opt/local/bin/python3.5
124 252 Etienne Pallier
125 252 Etienne Pallier
pip install -r ../PYROS/private/REQUIREMENTS.txt
126 252 Etienne Pallier
127 252 Etienne Pallier
128 252 Etienne Pallier
129 252 Etienne Pallier
130 252 Etienne Pallier
clic droit sur projet / Properties / PyDev - Interpreter/Grammar :
131 252 Etienne Pallier
Grammar version : 3
132 252 Etienne Pallier
Interpreter : click on « click here to configure an interpreter not listed »
133 252 Etienne Pallier
click on « New » :
134 252 Etienne Pallier
- Interpreter name : venv_py35_pyros
135 252 Etienne Pallier
- Interpreter executable : click on « Browse »
136 252 Etienne Pallier
	Select your private/venv_py35_pyros/bin/python3.5 executable
137 252 Etienne Pallier
	click OK
138 252 Etienne Pallier
	click OK again
139 252 Etienne Pallier
140 252 Etienne Pallier
Interpreter: select now venv_py35_pyros from the list
141 252 Etienne Pallier
142 252 Etienne Pallier
143 252 Etienne Pallier
Code style checking:
144 252 Etienne Pallier
145 252 Etienne Pallier
Window/Preferences : Pydev / Editor
146 252 Etienne Pallier
- Auto Imports : uncheck « Do auto import »
147 252 Etienne Pallier
- Code style:
148 252 Etienne Pallier
	- Locals … : camelCase
149 252 Etienne Pallier
	- Methods : camelCase() with first lower
150 252 Etienne Pallier
- Code style / Code Formatter: activer « use autopep8.py for code formatting »
151 252 Etienne Pallier
- Tabs : Tab length : 4
152 252 Etienne Pallier
153 252 Etienne Pallier
154 252 Etienne Pallier
155 252 Etienne Pallier
156 169 Etienne Pallier
157 141 Etienne Pallier
h2. %{margin-left:0px; font-weight:bold; font-size:25px;  display:block; color:red;}III - INSTALLATION%
158 2 Etienne Pallier
159 120 Etienne Pallier
160 120 Etienne Pallier
---
161 120 Etienne Pallier
162 184 Etienne Pallier
h3. Install MySql (only if necessary)
163 2 Etienne Pallier
164 49 Etienne Pallier
 * Linux Ubuntu
165 49 Etienne Pallier
<pre>
166 107 Paul Carensac
167 107 Paul Carensac
$ sudo apt-get install mysql-server
168 107 Paul Carensac
$ sudo apt-get install mysql-client
169 107 Paul Carensac
170 49 Etienne Pallier
</pre>
171 49 Etienne Pallier
172 49 Etienne Pallier
 * Linux CentOS
173 49 Etienne Pallier
<pre>
174 49 Etienne Pallier
TODO:
175 49 Etienne Pallier
$ sudo yum install mysql
176 49 Etienne Pallier
...
177 49 Etienne Pallier
</pre>
178 49 Etienne Pallier
179 49 Etienne Pallier
 * Mac OS X
180 1 Etienne Pallier
Install XAMPP
181 1 Etienne Pallier
(but you could also use the pre-installed Mac OS MySql)
182 177 Etienne Pallier
<pre>
183 177 Etienne Pallier
TODO:
184 49 Etienne Pallier
</pre>
185 1 Etienne Pallier
186 49 Etienne Pallier
 * Windows
187 243 Paul Carensac
188 1 Etienne Pallier
<pre>
189 243 Paul Carensac
Download and install the newest version on https://dev.mysql.com/downloads/installer/
190 243 Paul Carensac
191 243 Paul Carensac
Once installed, launch MySQL Installer. Clic on 'Add...' on the right.
192 243 Paul Carensac
In MySQLServers section, choose the newest, then clic on next.
193 243 Paul Carensac
Install and configure the server (just follow the installation guide).
194 243 Paul Carensac
195 243 Paul Carensac
Then launch mysql (via the Windows menu).
196 49 Etienne Pallier
</pre>
197 49 Etienne Pallier
198 49 Etienne Pallier
199 49 Etienne Pallier
---
200 1 Etienne Pallier
201 185 Etienne Pallier
h3. Install Python3.5 (only if necessary)
202 1 Etienne Pallier
203 11 Etienne Pallier
204 11 Etienne Pallier
 * Mac OS X :
205 1 Etienne Pallier
<pre>
206 183 Etienne Pallier
207 24 Etienne Pallier
1) Installer MacPort
208 24 Etienne Pallier
(TODO: doc)
209 24 Etienne Pallier
210 24 Etienne Pallier
2) Installer le "port" python35
211 1 Etienne Pallier
$ sudo port install python35
212 183 Etienne Pallier
213 1 Etienne Pallier
</pre>
214 1 Etienne Pallier
215 1 Etienne Pallier
 * Linux (Ubuntu) :
216 1 Etienne Pallier
<pre>
217 244 Paul Carensac
$ sudo add-apt-repository ppa:fkrull/deadsnakes
218 244 Paul Carensac
$ sudo apt-get update
219 244 Paul Carensac
$ sudo apt-get install python3.5
220 1 Etienne Pallier
221 244 Paul Carensac
$ sudo pip install virtualenv
222 1 Etienne Pallier
</pre>
223 1 Etienne Pallier
224 244 Paul Carensac
225 244 Paul Carensac
 * Windows 7 :
226 244 Paul Carensac
<pre>
227 244 Paul Carensac
Go to https://www.python.org/downloads/windows/ , choose the wanted version
228 244 Paul Carensac
On the wanted version’s page, download Windows x86 executable installer
229 244 Paul Carensac
230 244 Paul Carensac
Run the executable
231 244 Paul Carensac
    * On the first page, check "Add python3.5 to PATH"
232 244 Paul Carensac
    * Choose "Install now" option
233 245 Paul Carensac
234 245 Paul Carensac
Open cmd (windows + R, cmd) :
235 245 Paul Carensac
 $ python -m pip install --upgrade pip
236 245 Paul Carensac
 $ pip install virtualenv
237 244 Paul Carensac
</pre>
238 1 Etienne Pallier
239 183 Etienne Pallier
 * Windows 10 :
240 183 Etienne Pallier
<pre>
241 187 Etienne Pallier
TODO:
242 183 Etienne Pallier
</pre>
243 3 Etienne Pallier
244 4 Etienne Pallier
---
245 5 Etienne Pallier
246 192 Etienne Pallier
h3. Create a Python3 virtual environment dedicated to the project (inside the project folder)
247 127 Etienne Pallier
248 131 Etienne Pallier
<pre>
249 1 Etienne Pallier
250 193 Etienne Pallier
$ mkdir private/
251 193 Etienne Pallier
252 133 Etienne Pallier
$ cd private/
253 3 Etienne Pallier
254 246 Paul Carensac
$ which python3.5 ("where python" for windows)
255 3 Etienne Pallier
/opt/local/bin/python3.5
256 15 Etienne Pallier
257 127 Etienne Pallier
$ virtualenv-3.5 venv_py35_pyros -p /opt/local/bin/python3.5
258 3 Etienne Pallier
=> creates a venv_py35_pyros/ folder inside PYROS/private/
259 1 Etienne Pallier
260 131 Etienne Pallier
</pre>
261 1 Etienne Pallier
262 7 Etienne Pallier
---
263 3 Etienne Pallier
264 65 Etienne Pallier
h3. Activate the python virtual environment (from inside the project)
265 7 Etienne Pallier
266 55 Etienne Pallier
<pre>
267 1 Etienne Pallier
268 65 Etienne Pallier
$ pwd
269 134 Etienne Pallier
.../PYROS/private
270 1 Etienne Pallier
271 247 Paul Carensac
$ source ./venv_py35_pyros/bin/activate (venv_py35_pyros/Scripts/activate on Windows)
272 247 Paul Carensac
273 65 Etienne Pallier
274 3 Etienne Pallier
$ python -V
275 1 Etienne Pallier
Python 3.5.1
276 3 Etienne Pallier
277 3 Etienne Pallier
$ which pip
278 77 Etienne Pallier
.../PYROS/venv_py35_pyros/bin/pip
279 16 Etienne Pallier
280 194 Etienne Pallier
Upgrade pip to last version available:
281 3 Etienne Pallier
$ pip install --upgrade pip
282 3 Etienne Pallier
Collecting pip
283 3 Etienne Pallier
  Downloading pip-8.1.1-py2.py3-none-any.whl (1.2MB)
284 3 Etienne Pallier
Installing collected packages: pip
285 3 Etienne Pallier
  Found existing installation: pip 7.1.2
286 3 Etienne Pallier
    Uninstalling pip-7.1.2:
287 3 Etienne Pallier
      Successfully uninstalled pip-7.1.2
288 1 Etienne Pallier
Successfully installed pip-8.1.1
289 194 Etienne Pallier
290 194 Etienne Pallier
Upgrade wheel to last version available:
291 194 Etienne Pallier
$ pip install --upgrade wheel
292 194 Etienne Pallier
Collecting wheel
293 194 Etienne Pallier
  Downloading wheel-0.29.0-py2.py3-none-any.whl (66kB)
294 194 Etienne Pallier
Installing collected packages: wheel
295 194 Etienne Pallier
  Found existing installation: wheel 0.24.0
296 194 Etienne Pallier
    Uninstalling wheel-0.24.0:
297 194 Etienne Pallier
      Successfully uninstalled wheel-0.24.0
298 194 Etienne Pallier
Successfully installed wheel-0.29.0
299 194 Etienne Pallier
300 55 Etienne Pallier
301 55 Etienne Pallier
</pre>
302 18 Etienne Pallier
303 212 Etienne Pallier
h3. Install the needed Python packages (from within the virtual environment)
304 18 Etienne Pallier
305 66 Etienne Pallier
First, be sure that the virtual environment is activated:
306 66 Etienne Pallier
<pre>
307 66 Etienne Pallier
$ python -V
308 66 Etienne Pallier
Python 3.5.1
309 66 Etienne Pallier
</pre>
310 66 Etienne Pallier
311 62 Etienne Pallier
 * *Automatic Installation of all packages*
312 62 Etienne Pallier
<pre>
313 90 Etienne Pallier
$ pip install -r REQUIREMENTS.txt
314 62 Etienne Pallier
</pre>
315 62 Etienne Pallier
316 93 Etienne Pallier
 * *Or, manual installation of each package*
317 62 Etienne Pallier
318 62 Etienne Pallier
  * *Install Django* :
319 32 Etienne Pallier
<pre>
320 3 Etienne Pallier
$ pip install django
321 3 Etienne Pallier
Collecting django
322 3 Etienne Pallier
  Downloading Django-1.9.4-py2.py3-none-any.whl (6.6MB)
323 3 Etienne Pallier
Installing collected packages: django
324 3 Etienne Pallier
Successfully installed django-1.9.4
325 3 Etienne Pallier
326 3 Etienne Pallier
$ pip install django-admin-tools
327 3 Etienne Pallier
Collecting django-admin-tools
328 3 Etienne Pallier
  Downloading django_admin_tools-0.7.2-py2.py3-none-any.whl (289kB)
329 3 Etienne Pallier
Installing collected packages: django-admin-tools
330 3 Etienne Pallier
Successfully installed django-admin-tools-0.7.2
331 3 Etienne Pallier
332 21 Etienne Pallier
$ pip install django-debug-toolbar
333 21 Etienne Pallier
Collecting django-debug-toolbar
334 21 Etienne Pallier
  Downloading django_debug_toolbar-1.4-py2.py3-none-any.whl (212kB)
335 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)
336 21 Etienne Pallier
Collecting sqlparse (from django-debug-toolbar)
337 21 Etienne Pallier
  Downloading sqlparse-0.1.19.tar.gz (58kB)
338 21 Etienne Pallier
Building wheels for collected packages: sqlparse
339 21 Etienne Pallier
  Running setup.py bdist_wheel for sqlparse ... done
340 21 Etienne Pallier
  Stored in directory: /Users/epallier/Library/Caches/pip/wheels/7b/d4/72/6011bb100dd5fc213164e4bbee13d4e03261dd54ce6a5de6b8
341 21 Etienne Pallier
Successfully built sqlparse
342 21 Etienne Pallier
Installing collected packages: sqlparse, django-debug-toolbar
343 21 Etienne Pallier
Successfully installed django-debug-toolbar-1.4 sqlparse-0.1.19
344 21 Etienne Pallier
345 21 Etienne Pallier
$ pip install django-extensions
346 21 Etienne Pallier
Collecting django-extensions
347 21 Etienne Pallier
  Downloading django_extensions-1.6.1-py2.py3-none-any.whl (202kB)
348 21 Etienne Pallier
Collecting six>=1.2 (from django-extensions)
349 21 Etienne Pallier
  Downloading six-1.10.0-py2.py3-none-any.whl
350 21 Etienne Pallier
Installing collected packages: six, django-extensions
351 21 Etienne Pallier
Successfully installed django-extensions-1.6.1 six-1.10.0
352 21 Etienne Pallier
353 21 Etienne Pallier
$ pip install django-suit
354 21 Etienne Pallier
Collecting django-suit
355 21 Etienne Pallier
  Downloading django-suit-0.2.18.tar.gz (587kB)
356 21 Etienne Pallier
Building wheels for collected packages: django-suit
357 1 Etienne Pallier
  Running setup.py bdist_wheel for django-suit ... done
358 1 Etienne Pallier
  Stored in directory: /Users/epallier/Library/Caches/pip/wheels/12/8b/9a/e02ab0ad9229881638aa040d47d77c8f562999533811927d41
359 1 Etienne Pallier
Successfully built django-suit
360 1 Etienne Pallier
Installing collected packages: django-suit
361 1 Etienne Pallier
Successfully installed django-suit-0.2.18
362 21 Etienne Pallier
363 32 Etienne Pallier
</pre>
364 32 Etienne Pallier
365 63 Etienne Pallier
  * *Install the web application server gunicorn (will be used in production instead of the dev django web server)* :
366 32 Etienne Pallier
<pre>
367 25 Etienne Pallier
$ pip install gunicorn
368 25 Etienne Pallier
Collecting gunicorn
369 25 Etienne Pallier
  Downloading gunicorn-19.4.5-py2.py3-none-any.whl (112kB)
370 21 Etienne Pallier
Installing collected packages: gunicorn
371 26 Etienne Pallier
Successfully installed gunicorn-19.4.5
372 1 Etienne Pallier
</pre>
373 1 Etienne Pallier
374 63 Etienne Pallier
  * *Install the python mysql client*:
375 32 Etienne Pallier
<pre>
376 32 Etienne Pallier
$ pip install mysqlclient
377 72 Etienne Pallier
...
378 72 Etienne Pallier
</pre>
379 33 Etienne Pallier
380 73 Etienne Pallier
   * => Issue under Mac OS X:
381 72 Etienne Pallier
<pre>
382 3 Etienne Pallier
$ pip install mysqlclient
383 3 Etienne Pallier
Collecting mysqlclient
384 1 Etienne Pallier
  Downloading mysqlclient-1.3.7.tar.gz (79kB)
385 22 Etienne Pallier
Building wheels for collected packages: mysqlclient
386 3 Etienne Pallier
  Running setup.py bdist_wheel for mysqlclient ... error
387 3 Etienne Pallier
388 1 Etienne Pallier
  ----------------------------------------
389 1 Etienne Pallier
  Failed building wheel for mysqlclient
390 1 Etienne Pallier
  Running setup.py clean for mysqlclient
391 1 Etienne Pallier
Failed to build mysqlclient
392 1 Etienne Pallier
Installing collected packages: mysqlclient
393 1 Etienne Pallier
  Running setup.py install for mysqlclient ... done
394 1 Etienne Pallier
Successfully installed mysqlclient-1.3.7
395 1 Etienne Pallier
396 1 Etienne Pallier
BOUH !!!
397 1 Etienne Pallier
398 1 Etienne Pallier
$ pip install --upgrade wheel
399 1 Etienne Pallier
Collecting wheel
400 1 Etienne Pallier
  Downloading wheel-0.29.0-py2.py3-none-any.whl (66kB)
401 1 Etienne Pallier
Installing collected packages: wheel
402 1 Etienne Pallier
  Found existing installation: wheel 0.24.0
403 1 Etienne Pallier
    Uninstalling wheel-0.24.0:
404 1 Etienne Pallier
      Successfully uninstalled wheel-0.24.0
405 1 Etienne Pallier
Successfully installed wheel-0.29.0
406 1 Etienne Pallier
407 1 Etienne Pallier
$ pip uninstall mysqlclient
408 1 Etienne Pallier
409 1 Etienne Pallier
$ pip install mysqlclient
410 1 Etienne Pallier
Collecting mysqlclient
411 1 Etienne Pallier
  Using cached mysqlclient-1.3.7.tar.gz
412 1 Etienne Pallier
Building wheels for collected packages: mysqlclient
413 1 Etienne Pallier
  Running setup.py bdist_wheel for mysqlclient ... done
414 1 Etienne Pallier
  Stored in directory: /Users/epallier/Library/Caches/pip/wheels/9b/06/50/d11418c26cf8f2156b13d4363b5afde8e7e75ebb8540d0228d
415 1 Etienne Pallier
Successfully built mysqlclient
416 1 Etienne Pallier
Installing collected packages: mysqlclient
417 1 Etienne Pallier
Successfully installed mysqlclient-1.3.7
418 1 Etienne Pallier
419 1 Etienne Pallier
YES !!!
420 1 Etienne Pallier
421 1 Etienne Pallier
</pre>
422 1 Etienne Pallier
423 107 Paul Carensac
   * => Issues under Ubuntu:
424 107 Paul Carensac
<pre>
425 107 Paul Carensac
$ pip install mysqlclient
426 107 Paul Carensac
Collecting mysqlclient
427 107 Paul Carensac
  Downloading mysqlclient-1.3.7.tar.gz (79kB)
428 107 Paul Carensac
    100% |████████████████████████████████| 81kB 1.5MB/s
429 107 Paul Carensac
    Complete output from command python setup.py egg_info:
430 107 Paul Carensac
    /bin/sh: 1: mysql_config: not found
431 107 Paul Carensac
    Traceback (most recent call last):
432 107 Paul Carensac
      File "<string>", line 1, in <module>
433 107 Paul Carensac
    [...]
434 107 Paul Carensac
    ----------------------------------------
435 107 Paul Carensac
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-q6j4inuz/mysqlclient/
436 1 Etienne Pallier
437 108 Paul Carensac
BOUH !!!
438 108 Paul Carensac
439 107 Paul Carensac
$ sudo apt-get install libmysqlclient-dev
440 108 Paul Carensac
441 107 Paul Carensac
$ pip install mysqlclient
442 107 Paul Carensac
Collecting mysqlclient
443 107 Paul Carensac
  Using cached mysqlclient-1.3.7.tar.gz
444 107 Paul Carensac
Building wheels for collected packages: mysqlclient
445 107 Paul Carensac
  Running setup.py bdist_wheel for mysqlclient ... error
446 107 Paul Carensac
447 107 Paul Carensac
    _mysql.c:40:20: fatal error: Python.h: No such file or directory
448 107 Paul Carensac
     #include "Python.h"
449 107 Paul Carensac
                        ^
450 107 Paul Carensac
    compilation terminated.
451 107 Paul Carensac
    error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
452 107 Paul Carensac
    
453 107 Paul Carensac
    ----------------------------------------
454 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/
455 107 Paul Carensac
456 108 Paul Carensac
BOUH !!!
457 108 Paul Carensac
458 107 Paul Carensac
$ sudo apt-get install python3.5-dev
459 108 Paul Carensac
460 107 Paul Carensac
$ pip install mysqlclient
461 107 Paul Carensac
462 107 Paul Carensac
YES !!!
463 107 Paul Carensac
464 107 Paul Carensac
</pre>
465 12 Etienne Pallier
466 250 Paul Carensac
 * => Issue under Windows
467 250 Paul Carensac
<pre>
468 250 Paul Carensac
Same message as the issue for Mac.
469 250 Paul Carensac
470 250 Paul Carensac
Go to http://www.lfd.uci.edu/~gohlke/pythonlibs/#mysqlclient to download the newest mysqlclient wheel
471 250 Paul Carensac
472 250 Paul Carensac
$ pip install path\to\mysqlclient\wheel
473 250 Paul Carensac
474 250 Paul Carensac
No need to redo "pip install mysqlclient"
475 250 Paul Carensac
</pre>
476 250 Paul Carensac
477 12 Etienne Pallier
---
478 28 Etienne Pallier
479 142 Etienne Pallier
h3. Test the project
480 142 Etienne Pallier
481 142 Etienne Pallier
<pre>
482 142 Etienne Pallier
483 150 Etienne Pallier
$ cd src/
484 150 Etienne Pallier
485 1 Etienne Pallier
$ ./manage.py runserver
486 38 Etienne Pallier
(or gunicorn pyros.wsgi)
487 3 Etienne Pallier
==> http://localhost:8000
488 87 Etienne Pallier
...
489 87 Etienne Pallier
...
490 87 Etienne Pallier
Ctrl-c
491 87 Etienne Pallier
492 1 Etienne Pallier
</pre>
493 142 Etienne Pallier
494 142 Etienne Pallier
495 142 Etienne Pallier
496 142 Etienne Pallier
---
497 142 Etienne Pallier
498 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)%
499 155 Paul Carensac
500 155 Paul Carensac
---
501 155 Paul Carensac
502 155 Paul Carensac
h3. Back Office setup
503 155 Paul Carensac
504 155 Paul Carensac
 * Prerequisites in src/pyros/settings.py :
505 155 Paul Carensac
506 155 Paul Carensac
    * INSTALLED_APPS must (at least) contain :
507 155 Paul Carensac
508 155 Paul Carensac
        * django.contrib.admin
509 155 Paul Carensac
        * django.contrib.auth
510 155 Paul Carensac
        * django.contrib.contenttypes
511 155 Paul Carensac
        * django.contrib.sessions
512 155 Paul Carensac
513 155 Paul Carensac
    * MIDDLEWARES must (at least) contain :
514 155 Paul Carensac
515 155 Paul Carensac
        * django.contrib.sessions.middleware.SessionMiddleware
516 155 Paul Carensac
        * django.middleware.common.CommonMiddleware
517 155 Paul Carensac
        * django.contrib.auth.middleware.AuthenticationMiddleware
518 155 Paul Carensac
519 155 Paul Carensac
 * At least one 'python manage.py migrate' must have been executed
520 155 Paul Carensac
521 155 Paul Carensac
 * Create a superuser for the administration :
522 155 Paul Carensac
523 155 Paul Carensac
<pre>
524 155 Paul Carensac
$ python manage.py createsuperuser
525 155 Paul Carensac
</pre>
526 155 Paul Carensac
527 156 Paul Carensac
* For each app of the project, fill the admin.py file :
528 155 Paul Carensac
529 155 Paul Carensac
<pre>
530 155 Paul Carensac
from django.contrib import admin
531 155 Paul Carensac
from app.models import Model1, Model2
532 155 Paul Carensac
533 155 Paul Carensac
admin.site.register(Model1)
534 155 Paul Carensac
admin.site.register(Model2)
535 155 Paul Carensac
</pre>
536 155 Paul Carensac
537 155 Paul Carensac
*Reminder* : each application must be registered in the settings.py INSTALLED_APPS variable.
538 157 Paul Carensac
539 168 Paul Carensac
* For each model in models.py, add a '__str__()' method in order to identify the object on the back office. Example :
540 157 Paul Carensac
541 157 Paul Carensac
<pre>
542 157 Paul Carensac
class UserLevel(models.Model):
543 157 Paul Carensac
    name = models.CharField(max_length=45, blank=True, null=True)
544 157 Paul Carensac
    desc = models.TextField(blank=True, null=True)
545 157 Paul Carensac
    priority = models.IntegerField(blank=True, null=True)
546 157 Paul Carensac
    quota = models.FloatField(blank=True, null=True)
547 157 Paul Carensac
548 157 Paul Carensac
    class Meta:
549 157 Paul Carensac
        managed = True
550 157 Paul Carensac
        db_table = 'userlevel'
551 157 Paul Carensac
552 157 Paul Carensac
    def __str__(self):
553 163 Paul Carensac
        return (str(self.name))
554 157 Paul Carensac
</pre>
555 157 Paul Carensac
556 159 Paul Carensac
*Naming convention* : Use self.name when possible, the creation time/date otherwise. Example :
557 159 Paul Carensac
558 159 Paul Carensac
<pre>
559 159 Paul Carensac
class SiteWatch(models.Model):
560 159 Paul Carensac
    updated = models.DateTimeField(blank=True, null=True)
561 159 Paul Carensac
    lights = models.CharField(max_length=45, blank=True, null=True)
562 159 Paul Carensac
    dome = models.CharField(max_length=45, blank=True, null=True)
563 159 Paul Carensac
    doors = models.CharField(max_length=45, blank=True, null=True)
564 159 Paul Carensac
    temperature = models.FloatField(blank=True, null=True)
565 159 Paul Carensac
566 159 Paul Carensac
    class Meta:
567 159 Paul Carensac
        managed = True
568 159 Paul Carensac
        db_table = 'sitewatch'
569 159 Paul Carensac
570 159 Paul Carensac
    def __str__(self):
571 160 Paul Carensac
        return (str(self.updated))
572 159 Paul Carensac
</pre>
573 173 Etienne Pallier
574 211 Paul Carensac
---
575 211 Paul Carensac
576 211 Paul Carensac
h3. Adaptation of the one-to-many and many-to-many display
577 211 Paul Carensac
578 211 Paul Carensac
* The one-to-many relationships are the following (One.many format) :
579 211 Paul Carensac
580 211 Paul Carensac
    * Schedule.sequences
581 211 Paul Carensac
    * Request.sequences
582 211 Paul Carensac
    * Sequence.albums
583 211 Paul Carensac
    * Album.plans
584 211 Paul Carensac
    * Plan.images
585 211 Paul Carensac
    * Telescope.detectors
586 211 Paul Carensac
    * Detector.filters
587 211 Paul Carensac
    * NrtAnalysis.images
588 211 Paul Carensac
    * Filter.plans
589 211 Paul Carensac
    * Detector.albums
590 211 Paul Carensac
    * UserLevel.users
591 211 Paul Carensac
    * Country.users
592 211 Paul Carensac
    * ScientificProgram.requests
593 211 Paul Carensac
    * User.requests
594 211 Paul Carensac
    * StrategyObs.alerts
595 211 Paul Carensac
    * SequenceType.sequences
596 211 Paul Carensac
597 211 Paul Carensac
* For each "many", create a new class in admin.py just after the imports, following these examples :
598 211 Paul Carensac
599 211 Paul Carensac
<pre>
600 211 Paul Carensac
601 211 Paul Carensac
For Schedule.sequences, Request.sequences and Sequentype.sequences, we will need :
602 211 Paul Carensac
603 211 Paul Carensac
class SequenceInline(admin.TabularInline):
604 211 Paul Carensac
    model = Sequence
605 211 Paul Carensac
    fields = ("name",)
606 211 Paul Carensac
    show_change_link = True
607 211 Paul Carensac
608 211 Paul Carensac
609 211 Paul Carensac
For Sequence.albums and Detector.albums, we will need :
610 211 Paul Carensac
611 211 Paul Carensac
class AlbumInline(admin.TabularInline):
612 211 Paul Carensac
    model = Album
613 211 Paul Carensac
    fields = ("name",)
614 211 Paul Carensac
    show_change_link = True
615 211 Paul Carensac
616 211 Paul Carensac
617 211 Paul Carensac
For StrategyObs.alerts, we will need :
618 211 Paul Carensac
619 211 Paul Carensac
class AlertInline(admin.TabularInline):
620 211 Paul Carensac
    model = Alert
621 211 Paul Carensac
    fields = ("request.name",) # there is no 'name' attribute in the Alert model
622 211 Paul Carensac
    show_change_link = True
623 211 Paul Carensac
624 211 Paul Carensac
</pre>
625 211 Paul Carensac
626 222 Paul Carensac
* For each "One", declare a new class in admin.py, just after the "Inlines" class declaration, as done in the following examples :
627 211 Paul Carensac
628 222 Paul Carensac
<pre>
629 222 Paul Carensac
For Request.sequences :
630 222 Paul Carensac
631 222 Paul Carensac
class RequestAdmin(admin.ModelAdmin):
632 222 Paul Carensac
    inlines = [
633 222 Paul Carensac
	SequenceInline,
634 222 Paul Carensac
    ]
635 222 Paul Carensac
636 222 Paul Carensac
For Detector.filters and Detector.albums :
637 222 Paul Carensac
638 222 Paul Carensac
class DetectorAdmin(admin.ModelAdmin):
639 222 Paul Carensac
    inlines = [
640 222 Paul Carensac
	FilterInline,
641 222 Paul Carensac
        AlbumInline,
642 222 Paul Carensac
    ]
643 222 Paul Carensac
644 222 Paul Carensac
</pre>
645 222 Paul Carensac
646 232 Paul Carensac
647 222 Paul Carensac
* The many-to-many relationships are the following :
648 232 Paul Carensac
649 222 Paul Carensac
    * ScientificProgram - User
650 222 Paul Carensac
    * ScheduleHistory - Sequence
651 222 Paul Carensac
652 222 Paul Carensac
* For each many-to-many relationship, declare a new "Inline" class in admin.py just after the imports, like this :
653 222 Paul Carensac
654 222 Paul Carensac
<pre>
655 222 Paul Carensac
For ScientificProgram - User :
656 222 Paul Carensac
657 222 Paul Carensac
class UserAndSPInline(admin.TabularInline):
658 222 Paul Carensac
    model = ScientificProgram.users.through
659 222 Paul Carensac
660 222 Paul Carensac
661 222 Paul Carensac
For ScheduleHistory - Sequence
662 222 Paul Carensac
663 222 Paul Carensac
class SequenceAndSHInline(admin.TabularInline):
664 222 Paul Carensac
    model = ScheduleHistory.sequences.through
665 222 Paul Carensac
666 222 Paul Carensac
</pre>
667 222 Paul Carensac
668 222 Paul Carensac
+Note :+ The order in the line "model = ScientificProgram.users.through" is very important : the first model (ScientificProgram) is the one in which is declared the ManyToManyField relationship.
669 232 Paul Carensac
670 232 Paul Carensac
* For each many-to-many relationship, declare two new classes in admin.py, just after the inlines, like in the following examples :
671 232 Paul Carensac
672 232 Paul Carensac
<pre>
673 232 Paul Carensac
For the ScheduleHistory - Sequence relationship :
674 232 Paul Carensac
675 232 Paul Carensac
class ScheduleHistoryAdmin(admin.ModelAdmin):
676 232 Paul Carensac
    inlines = [
677 232 Paul Carensac
        SequenceAndSHInline,
678 232 Paul Carensac
    ]
679 232 Paul Carensac
    exclude = ('sequences',) # ScheduleHistory declares the ManyToManyField, and we want to replace its display in the back office, so we won't display the default field
680 232 Paul Carensac
681 232 Paul Carensac
class SequenceAdmin(admin.ModelAdmin):
682 232 Paul Carensac
    inlines = [
683 232 Paul Carensac
        AlbumInline,        # This is the Inline for the one-to-many relationship Sequence.albums
684 232 Paul Carensac
        SequenceAndSHInline,                                                                
685 232 Paul Carensac
    ]
686 232 Paul Carensac
687 232 Paul Carensac
For the ScientificProgram - User relationship :
688 232 Paul Carensac
689 232 Paul Carensac
class ScientificProgramAdmin(admin.ModelAdmin):
690 232 Paul Carensac
    inlines = [
691 232 Paul Carensac
        RequestInline,
692 232 Paul Carensac
	UserAndSPInline,                                                                         
693 232 Paul Carensac
    ]
694 232 Paul Carensac
    exclude = ('users',) # Same as ScheduleHistory                                                                         
695 232 Paul Carensac
696 232 Paul Carensac
class UserAdmin(admin.ModelAdmin):
697 232 Paul Carensac
    inlines = [
698 232 Paul Carensac
	RequestInline,   # This is the Inline for the one-to-many relationship User.requests
699 232 Paul Carensac
        UserAndSPInline,                                                                    
700 232 Paul Carensac
    ]
701 232 Paul Carensac
702 232 Paul Carensac
</pre>
703 232 Paul Carensac
704 235 Paul Carensac
* For each ModelAdmin class in the admin.py, change the registering line
705 235 Paul Carensac
706 235 Paul Carensac
<pre>
707 235 Paul Carensac
admin.site.register(Album)
708 235 Paul Carensac
</pre>
709 235 Paul Carensac
710 235 Paul Carensac
to
711 235 Paul Carensac
712 235 Paul Carensac
<pre>
713 235 Paul Carensac
admin.site.register(Album, AlbumAdmin)
714 235 Paul Carensac
</pre>
715 211 Paul Carensac
716 229 Etienne Pallier
h2. %{margin-left:0px; font-weight:bold; font-size:25px;  display:block; color:red;}V - INSTALLATION FROM THE BEGINNING (for dev only, history of the initial project creation)%
717 1 Etienne Pallier
718 236 Etienne Pallier
719 242 Etienne Pallier
[[pyros_install_from_start|Pyros installation from the beginning]]