diff --git a/install/INSTALLATION.html b/install/INSTALLATION.html index 426f95c..be726ce 100644 --- a/install/INSTALLATION.html +++ b/install/INSTALLATION.html @@ -1,7 +1,7 @@
-HOWTO Format Redmine Wiki : http://www.redmine.org/projects/redmine/wiki/FrRedmineWikiFormatting
- - -Project Development page : Project Development
- -HOWTO Format Redmine Wiki : http://www.redmine.org/projects/redmine/wiki/FrRedmineWikiFormatting
--git clone https://gitlab.irap.omp.eu/epallier/pyros.git PYROS - -(or also : git clone git@gitlab.irap.omp.eu:epallier/pyros.git) -- -
This creates a PYROS/ folder containing the project (with a .git/ subfolder for synchronization with the git repository)
+https://gitlab.irap.omp.eu/epallier/pyros/tree/master
-If you just wanted a static copy of the project (without synchronization) just remove the .git/ folder:
-$ rm -r .git/ -+ +
You should obtain this structure:
+Once you have fetched the project, you should obtain this structure:
PYROS/ -├── REQUIREMENTS.txt -├── private/ -│ └── venv_py35_pyros/ +├── install/ +│ └── REQUIREMENTS.txt +│ └── INSTALLATION.txt ├── public/ │ └── static/ ├── src/ @@ -126,14 +90,109 @@ PYROS/- -
-TODO: +git clone https://gitlab.irap.omp.eu/epallier/pyros.git PYROS +(or also : git clone git@gitlab.irap.omp.eu:epallier/pyros.git PYROS)+
This creates a PYROS/ folder containing the project (with a .git/ subfolder for synchronization with the git repository)
+ + +If you just wanted a static copy of the project (without synchronization), just remove the .git/ folder:
+$ rm -r .git/ ++ + + +
0) Install Eclipse (if necessary)
+ + +Get the Eclipse version for Php
+ + +Install the plug-in pydev (via install new software, add http://pydev.org/updates)
+ + +1) Deactivate CA certificate verification
+ + +Window -> Preferences -> Team -> git -> configuration -> Add entry
+ + +Key = http.sslVerify
Value = false
2) Fetch the project
+ + +File/Import project from git
+ + +Select repository source: Clone URI: https://gitlab.irap.omp.eu/epallier/pyros.git
+ + +Directory:
par défaut, il propose : /Users/epallier/git/pyros
mais on peut le mettre ailleurs (c'est ce que j'ai fait)
initial branch: master
remote name: origin
Import as general project
+ + +Project name: PYROS
+ + +3) Configure the project
+ + +The project is created. Now, you have to set it as a «PyDev » and a « Django » project.
+ + +clic droit sur le projet / PyDev / set as a PyDev project
+ + +clic droit sur le projet / PyDev / set as a Django project
+ + +clic droit sur le projet : on doit maintenant avoir un sous-menu Django
+ + +clic droit sur le dossier src / PyDev / set as source folder (add to PYTHONPATH)
+ + +clic droit sur projet / Properties / Pydev-Django :
- Django manage.py : src/manage.py
- Django settings module : pyros.settings
4) Set Code style
+ + +Window/Preferences : Pydev / Editor
- Auto Imports : uncheck « Do auto import »
- Code style:
- Locals … : camelCase
- Methods : camelCase() with first lower
- Code style / Code Formatter: activer « use autopep8.py for code formatting »
- Tabs : Tab length : 4
(
il faudra aussi faire un peu plus loin :
https://projects.irap.omp.eu/projects/pyros/wiki/Project_Installation#Eclipse-only-Set-the-Python3-virtual-environment-as-the-project-interpreter
)
By default, Mysql will be used, but then you will need to install the Mysql database server.
+ + +Thus, in order to skip Mysql installation, use Sqlite instead as the database server (which will need no installation at all) :
+ + +Edit pyros/settings.py and just set MYSQL variable to False, and that's it.
+ +Skip this step if you are using Sqlite instead of MySql +
@@ -174,6 +235,7 @@ TODO:
@@ -303,6 +365,9 @@ Successfully installed wheel-0.29.0+
+Same message as the issue for Mac. -+Go to http://www.lfd.uci.edu/~gohlke/pythonlibs/#mysqlclient to download the newest mysqlclient wheel -$ cd src/ +$ pip install path\to\mysqlclient\wheel -$ ./manage.py runserver -(or gunicorn pyros.wsgi) -==> http://localhost:8000 -... -... -Ctrl-c +No need to redo "pip install mysqlclient" +
clic droit sur projet / Properties / PyDev - Interpreter/Grammar :
Grammar version : 3
Interpreter : click on « click here to configure an interpreter not listed »
-click on « New » :
- Interpreter name : venv_py35_pyros
- Interpreter executable : click on « Browse »
Select your private/venv_py35_pyros/bin/python3.5 executable
click OK
click OK again
Interpreter: select now venv_py35_pyros from the list
-TODO: more details... (notamment sur localhost:8000/admin)
--$ python manage.py createsuperuser --
-from django.contrib import admin -from app.models import Model1, Model2 - -admin.site.register(Model1) -admin.site.register(Model2) --
Reminder : each application must be registered in the settings.py INSTALLED_APPS variable.
- - --class UserLevel(models.Model): - name = models.CharField(max_length=45, blank=True, null=True) - desc = models.TextField(blank=True, null=True) - priority = models.IntegerField(blank=True, null=True) - quota = models.FloatField(blank=True, null=True) - - class Meta: - managed = True - db_table = 'userlevel' - - def __str__(self): - return (str(self.name))-
Naming convention : Use self.name when possible, the creation time/date otherwise. Example :
+ +-class SiteWatch(models.Model): - updated = models.DateTimeField(blank=True, null=True) - lights = models.CharField(max_length=45, blank=True, null=True) - dome = models.CharField(max_length=45, blank=True, null=True) - doors = models.CharField(max_length=45, blank=True, null=True) - temperature = models.FloatField(blank=True, null=True) - - class Meta: - managed = True - db_table = 'sitewatch' - - def __str__(self): - return (str(self.updated)) -- -
Right clic on project -> Django/Custom command/runserver
- -Error on Ubuntu :
--
Project -> Properties -> Pydev interpreter -> Clic here to configure an interpreter not listed
-+-select venv_py35_pyros
-For Schedule.sequences, Request.sequences and Sequentype.sequences, we will need : -class SequenceInline(admin.TabularInline): - model = Sequence - fields = ("name",) - show_change_link = True +In Libraries, clic on 'New folder', then select your virtualenv's lib/python3.5/site-packages folder.
-For Sequence.albums and Detector.albums, we will need : -class AlbumInline(admin.TabularInline): - model = Album - fields = ("name",) - show_change_link = True +OK -> re-select venv_py35_pyros in 'Interpreter' dropdown menu
-For StrategyObs.alerts, we will need : -class AlertInline(admin.TabularInline): - model = Alert - fields = ("request.name",) # there is no 'name' attribute in the Alert model - show_change_link = True +Then right clic on project -> Django/Custom command/runserver
-
check http://localhost:8000/
--For Request.sequences : ++
-class RequestAdmin(admin.ModelAdmin): - inlines = [ - SequenceInline, - ] -For Detector.filters and Detector.albums : + +IV - TEST¶
-class DetectorAdmin(admin.ModelAdmin): - inlines = [ - FilterInline, - AlbumInline, - ] -
Tests are classes declared in all apps' test.py file. The test classes inherit from django.test.TestCase
-You can run the tests suite, just to be sure that the software is well installed.
--For ScientificProgram - User : - -class UserAndSPInline(admin.TabularInline): - model = ScientificProgram.users.through +$ cd src/ -For ScheduleHistory - Sequence +$ ./manage.py test -class SequenceAndSHInline(admin.TabularInline): - model = ScheduleHistory.sequences.through +Ran 5 tests in 0.093s +OK-
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.
+ +-For the ScheduleHistory - Sequence relationship : - -class ScheduleHistoryAdmin(admin.ModelAdmin): - inlines = [ - SequenceAndSHInline, - ] - 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 - -class SequenceAdmin(admin.ModelAdmin): - inlines = [ - AlbumInline, # This is the Inline for the one-to-many relationship Sequence.albums - SequenceAndSHInline, - ] - -For the ScientificProgram - User relationship : - -class ScientificProgramAdmin(admin.ModelAdmin): - inlines = [ - RequestInline, - UserAndSPInline, - ] - exclude = ('users',) # Same as ScheduleHistory - -class UserAdmin(admin.ModelAdmin): - inlines = [ - RequestInline, # This is the Inline for the one-to-many relationship User.requests - UserAndSPInline, - ] - --
-admin.site.register(Album) -- -
to
- - --admin.site.register(Album, AlbumAdmin) -- - -
Pyros installation from the beginning
+$ [./manage.py] test app.tests # Run tests for the application 'app'
$ [./manage.py] test app.tests.ModelTests # Run test methods declared in the class app.tests.ModelTests
$ [./manage.py] test app.tests.ModelTests.test_method # Only run the method test_method declared in app.tests.ModelTests
-git clone https://gitlab.irap.omp.eu/epallier/pyros.git PYROS +h3. Browse the code from gitlab -(or also : git clone git@gitlab.irap.omp.eu:epallier/pyros.git) -+https://gitlab.irap.omp.eu/epallier/pyros/tree/master -This creates a PYROS/ folder containing the project (with a .git/ subfolder for synchronization with the git repository) +h3. Project structure -_If you just wanted a static copy of the project (without synchronization) just remove the .git/ folder:_ -
-$ rm -r .git/ -- -You should obtain this structure: +Once you have fetched the project, you should obtain this structure:
PYROS/ -├── REQUIREMENTS.txt -├── private/ -│ └── venv_py35_pyros/ +├── install/ +│ └── REQUIREMENTS.txt +│ └── INSTALLATION.txt ├── public/ │ └── static/ ├── src/ @@ -78,13 +57,94 @@ PYROS/+h3. From the terminal + +
+git clone https://gitlab.irap.omp.eu/epallier/pyros.git PYROS +(or also : git clone git@gitlab.irap.omp.eu:epallier/pyros.git PYROS) +-h3. Get the project from Eclipse +This creates a PYROS/ folder containing the project (with a .git/ subfolder for synchronization with the git repository) +_If you just wanted a static copy of the project (without synchronization), just remove the .git/ folder:_
-TODO: +$ rm -r .git/+h3. From Eclipse + +0) Install Eclipse (if necessary) + +Get the Eclipse version for Php + +Install the plug-in pydev (via install new software, add http://pydev.org/updates) + + +1) Deactivate CA certificate verification + +Window -> Preferences -> Team -> git -> configuration -> Add entry + +Key = http.sslVerify +Value = false + +2) Fetch the project + +File/Import project from git + +Select repository source: Clone URI: https://gitlab.irap.omp.eu/epallier/pyros.git + +Directory: +par défaut, il propose : /Users/epallier/git/pyros +mais on peut le mettre ailleurs (c'est ce que j'ai fait) + +initial branch: master +remote name: origin + +Import as general project + +Project name: PYROS + + +3) Configure the project + +The project is created. Now, you have to set it as a «PyDev » and a « Django » project. + +clic droit sur le projet / PyDev / set as a PyDev project + +clic droit sur le projet / PyDev / set as a Django project + +clic droit sur le projet : on doit maintenant avoir un sous-menu Django + +clic droit sur le dossier src / PyDev / set as source folder (add to PYTHONPATH) + +clic droit sur projet / Properties / Pydev-Django : + - Django manage.py : src/manage.py + - Django settings module : pyros.settings + + +4) Set Code style + +Window/Preferences : Pydev / Editor +- Auto Imports : uncheck « Do auto import » +- Code style: + - Locals … : camelCase + - Methods : camelCase() with first lower +- Code style / Code Formatter: activer « use autopep8.py for code formatting » +- Tabs : Tab length : 4 + +( +il faudra aussi faire un peu plus loin : +https://projects.irap.omp.eu/projects/pyros/wiki/Project_Installation#Eclipse-only-Set-the-Python3-virtual-environment-as-the-project-interpreter +) + +h3. For easier installation, you can use Sqlite instead of Mysql + +By default, Mysql will be used, but then you will need to install the Mysql database server. + +Thus, in order to skip Mysql installation, use Sqlite instead as the database server (which will need no installation at all) : + +Edit pyros/settings.py and just set MYSQL variable to False, and that's it. + h2. %{margin-left:0px; font-weight:bold; font-size:25px; display:block; color:red;}III - INSTALLATION% @@ -92,6 +152,8 @@ h2. %{margin-left:0px; font-weight:bold; font-size:25px; display:block; color:r h3. Install MySql (only if necessary) +*Skip this step if you are using Sqlite instead of MySql* + * Linux Ubuntu
@@ -172,8 +234,8 @@ Open cmd (windows + R, cmd) : TODO:---- - +--- + h3. Create a Python3 virtual environment dedicated to the project (inside the project folder)
@@ -190,8 +252,8 @@ $ virtualenv-3.5 venv_py35_pyros -p /opt/local/bin/python3.5---- - +--- + h3. Activate the python virtual environment (from inside the project)
@@ -229,8 +291,10 @@ Installing collected packages: wheel Successfully installed wheel-0.29.0 -- + + +--- + h3. Install the needed Python packages (from within the virtual environment) First, be sure that the virtual environment is activated: @@ -356,7 +420,6 @@ YES !!! $ pip install mysqlclient Collecting mysqlclient Downloading mysqlclient-1.3.7.tar.gz (79kB) - 100% |████████████████████████████████| 81kB 1.5MB/s Complete output from command python setup.py egg_info: /bin/sh: 1: mysql_config: not found Traceback (most recent call last): @@ -394,246 +457,113 @@ YES !!! ---- - -h3. Test the project - + * => Issue under Windows
+Same message as the issue for Mac. -$ cd src/ +Go to http://www.lfd.uci.edu/~gohlke/pythonlibs/#mysqlclient to download the newest mysqlclient wheel -$ ./manage.py runserver -(or gunicorn pyros.wsgi) -==> http://localhost:8000 -... -... -Ctrl-c +$ pip install path\to\mysqlclient\wheel +No need to redo "pip install mysqlclient"- - ---- - -h2. %{margin-left:0px; font-weight:bold; font-size:25px; display:block; color:red;}IV - CONFIGURATION of the Django Back Office (administration interface)% - --- -h3. Back Office setup +h3. (Eclipse only) Set the Python3 virtual environment as the project interpreter - * Prerequisites in src/pyros/settings.py : +clic droit sur projet / Properties / PyDev - Interpreter/Grammar : +Grammar version : 3 - * INSTALLED_APPS must (at least) contain : +Interpreter : click on « click here to configure an interpreter not listed » - * django.contrib.admin - * django.contrib.auth - * django.contrib.contenttypes - * django.contrib.sessions +click on « New » : +- Interpreter name : venv_py35_pyros +- Interpreter executable : click on « Browse » + Select your private/venv_py35_pyros/bin/python3.5 executable + click OK + click OK again - * MIDDLEWARES must (at least) contain : +Interpreter: select now venv_py35_pyros from the list - * django.contrib.sessions.middleware.SessionMiddleware - * django.middleware.common.CommonMiddleware - * django.contrib.auth.middleware.AuthenticationMiddleware - - * At least one 'python manage.py migrate' must have been executed +--- - * Create a superuser for the administration : +h3. Run the project -
-$ python manage.py createsuperuser -+TODO: more details... (notamment sur localhost:8000/admin) -* For each app of the project, fill the admin.py file : +h4. From the terminal
-from django.contrib import admin -from app.models import Model1, Model2 -admin.site.register(Model1) -admin.site.register(Model2) -- -*Reminder* : each application must be registered in the settings.py INSTALLED_APPS variable. - -* For each model in models.py, add a '__str__()' method in order to identify the object on the back office. Example : - -
-class UserLevel(models.Model): - name = models.CharField(max_length=45, blank=True, null=True) - desc = models.TextField(blank=True, null=True) - priority = models.IntegerField(blank=True, null=True) - quota = models.FloatField(blank=True, null=True) - - class Meta: - managed = True - db_table = 'userlevel' - - def __str__(self): - return (str(self.name)) -+$ cd src/ -*Naming convention* : Use self.name when possible, the creation time/date otherwise. Example : +$ ./manage.py runserver +(or gunicorn pyros.wsgi) +==> http://localhost:8000 +... +... +Ctrl-c -
-class SiteWatch(models.Model): - updated = models.DateTimeField(blank=True, null=True) - lights = models.CharField(max_length=45, blank=True, null=True) - dome = models.CharField(max_length=45, blank=True, null=True) - doors = models.CharField(max_length=45, blank=True, null=True) - temperature = models.FloatField(blank=True, null=True) - - class Meta: - managed = True - db_table = 'sitewatch' - - def __str__(self): - return (str(self.updated))---- - -h3. Adaptation of the one-to-many and many-to-many display - -* The one-to-many relationships are the following (One.many format) : - - * Schedule.sequences - * Request.sequences - * Sequence.albums - * Album.plans - * Plan.images - * Telescope.detectors - * Detector.filters - * NrtAnalysis.images - * Filter.plans - * Detector.albums - * UserLevel.users - * Country.users - * ScientificProgram.requests - * User.requests - * StrategyObs.alerts - * SequenceType.sequences - -* For each "many", create a new class in admin.py just after the imports, following these examples : - -
- -For Schedule.sequences, Request.sequences and Sequentype.sequences, we will need : - -class SequenceInline(admin.TabularInline): - model = Sequence - fields = ("name",) - show_change_link = True - - -For Sequence.albums and Detector.albums, we will need : - -class AlbumInline(admin.TabularInline): - model = Album - fields = ("name",) - show_change_link = True - +h4. From Eclipse -For StrategyObs.alerts, we will need : +Right clic on project -> Django/Custom command/runserver -class AlertInline(admin.TabularInline): - model = Alert - fields = ("request.name",) # there is no 'name' attribute in the Alert model - show_change_link = True - -- -* For each "One", declare a new class in admin.py, just after the "Inlines" class declaration, as done in the following examples : +Error on Ubuntu :
-For Request.sequences : - -class RequestAdmin(admin.ModelAdmin): - inlines = [ - SequenceInline, - ] -For Detector.filters and Detector.albums : - -class DetectorAdmin(admin.ModelAdmin): - inlines = [ - FilterInline, - AlbumInline, - ] +Traceback (most recent call last): + File "/home/carens_p/git/pyros/src/manage.py", line 8, in+Project -> Properties -> Pydev interpreter -> Clic here to configure an interpreter not listed -* The many-to-many relationships are the following : +select venv_py35_pyros - * ScientificProgram - User - * ScheduleHistory - Sequence +In Libraries, clic on 'New folder', then select your virtualenv's lib/python3.5/site-packages folder. -* For each many-to-many relationship, declare a new "Inline" class in admin.py just after the imports, like this : +OK -> re-select venv_py35_pyros in 'Interpreter' dropdown menu -+ from django.core.management import execute_from_command_line +ImportError: No module named 'django'
-For ScientificProgram - User : +Then right clic on project -> Django/Custom command/runserver -class UserAndSPInline(admin.TabularInline): - model = ScientificProgram.users.through +check http://localhost:8000/ -For ScheduleHistory - Sequence +--- + +h2. %{margin-left:0px; font-weight:bold; font-size:25px; display:block; color:red;}IV - TEST% -class SequenceAndSHInline(admin.TabularInline): - model = ScheduleHistory.sequences.through +Tests are classes declared in all apps' test.py file. The test classes inherit from django.test.TestCase -+You can run the tests suite, just to be sure that the software is well installed. -+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. +h3. From Terminal -* For each many-to-many relationship, declare two new classes in admin.py, just after the inlines, like in the following examples :
-For the ScheduleHistory - Sequence relationship : - -class ScheduleHistoryAdmin(admin.ModelAdmin): - inlines = [ - SequenceAndSHInline, - ] - 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 - -class SequenceAdmin(admin.ModelAdmin): - inlines = [ - AlbumInline, # This is the Inline for the one-to-many relationship Sequence.albums - SequenceAndSHInline, - ] - -For the ScientificProgram - User relationship : - -class ScientificProgramAdmin(admin.ModelAdmin): - inlines = [ - RequestInline, - UserAndSPInline, - ] - exclude = ('users',) # Same as ScheduleHistory - -class UserAdmin(admin.ModelAdmin): - inlines = [ - RequestInline, # This is the Inline for the one-to-many relationship User.requests - UserAndSPInline, - ] +$ cd src/ -+$ ./manage.py test -* For each ModelAdmin class in the admin.py, change the registering line +Ran 5 tests in 0.093s -
-admin.site.register(Album) +OK-to +h3. From Eclipse: -
-admin.site.register(Album, AlbumAdmin) -- -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)% +* Right-clic on the project / Django / Run Django tests + +* Right-clic on the project / Django / Custom command / ... +h3. Custom commands : -[[pyros_install_from_start|Pyros installation from the beginning]] +$ [./manage.py] test app.tests # Run tests for the application 'app' +$ [./manage.py] test app.tests.ModelTests # Run test methods declared in the class app.tests.ModelTests +$ [./manage.py] test app.tests.ModelTests.test_method # Only run the method test_method declared in app.tests.ModelTests \ No newline at end of file -- libgit2 0.21.2