Commit a6603b26cb78a806a9c3d93d15d71a4b4ce638d0

Authored by Alexis Koralewski
1 parent d10072bb
Exists in dev

Django and Python versions migration to Django 3 and Python 3.8

1 -FROM python:3.6.9 1 +FROM python:3.8
2 2
3 RUN apt-get update && apt-get install -y \ 3 RUN apt-get update && apt-get install -y \
4 default-mysql-client \ 4 default-mysql-client \
@@ -9,7 +9,6 @@ RUN apt-get update && apt-get install -y \ @@ -9,7 +9,6 @@ RUN apt-get update && apt-get install -y \
9 # Get IRAP self signed certificate 9 # Get IRAP self signed certificate
10 RUN echo | openssl s_client -connect gitlab.irap.omp.eu:443 -servername gitlab.irap.omp.eu 2>/dev/null | openssl x509 > /etc/ssl/certs/gitlab.irap.omp.eu.crt 10 RUN echo | openssl s_client -connect gitlab.irap.omp.eu:443 -servername gitlab.irap.omp.eu 2>/dev/null | openssl x509 > /etc/ssl/certs/gitlab.irap.omp.eu.crt
11 11
12 -RUN pip install --upgrade pip  
13 12
14 # adding new user (pyros_user) and creating his home folder 13 # adding new user (pyros_user) and creating his home folder
15 RUN useradd --create-home --shell /bin/bash pyros_user 14 RUN useradd --create-home --shell /bin/bash pyros_user
@@ -21,6 +20,9 @@ WORKDIR /home/pyros_user/app @@ -21,6 +20,9 @@ WORKDIR /home/pyros_user/app
21 # switch from root to pyros_user 20 # switch from root to pyros_user
22 USER pyros_user 21 USER pyros_user
23 22
  23 +RUN pip install --user --upgrade pip
  24 +RUN pip install --user wheel
  25 +RUN pip install --user numpy
24 # copy local host machine files to image 26 # copy local host machine files to image
25 COPY --chown=pyros_user:pyros_user . . 27 COPY --chown=pyros_user:pyros_user . .
26 28
install/requirements.txt
1 -anyjson==0.3.3 1 +anyjson
2 click 2 click
3 -DateTime==4.2  
4 -Django==2.0.5  
5 -django-admin-tools==0.8.1  
6 -django-bootstrap3==10.0.1  
7 -django-extensions==2.0.7 3 +DateTime
  4 +Django==3.2
  5 +django-admin-tools
  6 +django-bootstrap3
  7 +django-extensions
8 8
9 # for Choices 9 # for Choices
10 django-model-utils 10 django-model-utils
11 11
12 -django-suit==0.2.26  
13 -django-test-without-migrations==0.6 12 +django-suit
  13 +django-test-without-migrations
14 #gunicorn==19.8.1 14 #gunicorn==19.8.1
15 -iso8601==0.1.12  
16 -jdcal==1.4 15 +iso8601
  16 +jdcal
17 #lxml==4.3.0 17 #lxml==4.3.0
18 -lxml==4.5.1  
19 -mysqlclient==1.3.12 18 +lxml
  19 +mysqlclient
20 #pluggy>=0.7 20 #pluggy>=0.7
21 -pluggy==0.8.1  
22 -py==1.5.3  
23 -pytz==2018.4  
24 -requests==2.18.4  
25 -six==1.11.0  
26 -sqlparse==0.2.4  
27 -Twisted==18.4.0  
28 -voevent-parse==1.0.3  
29 -zope.interface==5.2.0 21 +pluggy
  22 +py
  23 +pytz
  24 +requests
  25 +six
  26 +sqlparse
  27 +Twisted
  28 +voevent-parse
  29 +zope.interface
30 30
31 # For DEV 31 # For DEV
32 -django-debug-toolbar==1.9.1 32 +django-debug-toolbar
33 33
34 # Modifications 2021 : 34 # Modifications 2021 :
35 # removing plantuml because we need a unofficial version (maybe we could force to go back on an old version where the bug wasn't happening 35 # removing plantuml because we need a unofficial version (maybe we could force to go back on an old version where the bug wasn't happening
@@ -59,9 +59,12 @@ GitPython @@ -59,9 +59,12 @@ GitPython
59 # For working with date 59 # For working with date
60 python-dateutil 60 python-dateutil
61 61
62 -# Celme / guitastro packages 62 +# Celme / guitastro packages
  63 +# pypylon not available for 3.10 at 2021/11/10 (cf https://github.com/basler/pypylon#binary-installation)
63 pypylon 64 pypylon
64 sep 65 sep
65 astroquery 66 astroquery
66 astroalign 67 astroalign
  68 +# ccdproc requires astroscrappy which doesn't work on Python versions > 3.8 (cf https://github.com/astropy/astroscrappy/issues/55)
  69 +# There is also an issue with astroscrappy with numpy (module not found despite installing numpy in advance)
67 ccdproc 70 ccdproc
68 \ No newline at end of file 71 \ No newline at end of file
@@ -660,7 +660,7 @@ def start(agent:str, configfile:str,observatory:str,unit:str): @@ -660,7 +660,7 @@ def start(agent:str, configfile:str,observatory:str,unit:str):
660 if unit: 660 if unit:
661 os.environ["unit_name"] = unit 661 os.environ["unit_name"] = unit
662 else: 662 else:
663 - os.environ["unit_name"] = None 663 + os.environ["unit_name"] = ""
664 # add path to pyros_django folder as the config class is supposed to work within this folder 664 # add path to pyros_django folder as the config class is supposed to work within this folder
665 #cmd_test_obs_config = f"-c \"from src.core.pyros_django.obsconfig.configpyros import ConfigPyros\nConfigPyros('{os.path.join(PYROS_DJANGO_BASE_DIR,os.environ.get('PATH_TO_OBSCONF_FILE'))}')\"" 665 #cmd_test_obs_config = f"-c \"from src.core.pyros_django.obsconfig.configpyros import ConfigPyros\nConfigPyros('{os.path.join(PYROS_DJANGO_BASE_DIR,os.environ.get('PATH_TO_OBSCONF_FILE'))}')\""
666 cmd_test_obs_config = f"-c \"from src.core.pyros_django.obsconfig.configpyros import ConfigPyros\nConfigPyros('{obs_config_file_path}')\"" 666 cmd_test_obs_config = f"-c \"from src.core.pyros_django.obsconfig.configpyros import ConfigPyros\nConfigPyros('{obs_config_file_path}')\""
src/core/pyros_django/dashboard/views.py
@@ -43,7 +43,7 @@ log = l.setupLogger("dashboard", "dashboard") @@ -43,7 +43,7 @@ log = l.setupLogger("dashboard", "dashboard")
43 def index(request): 43 def index(request):
44 config = ConfigPyros(os.environ["PATH_TO_OBSCONF_FILE"],os.environ["unit_name"]) 44 config = ConfigPyros(os.environ["PATH_TO_OBSCONF_FILE"],os.environ["unit_name"])
45 observatory_name = config.get_obs_name() 45 observatory_name = config.get_obs_name()
46 - unit_name = os.environ["unit_name"] 46 + unit_name = config.unit_name
47 request.session["obsname"] = observatory_name+" "+unit_name 47 request.session["obsname"] = observatory_name+" "+unit_name
48 48
49 message = "" 49 message = ""
src/core/pyros_django/misc/templates/base.html
@@ -2,7 +2,7 @@ @@ -2,7 +2,7 @@
2 <html lang="en"> 2 <html lang="en">
3 <head> 3 <head>
4 4
5 - {% load staticfiles %} 5 + {% load static %}
6 <meta charset="utf-8"> 6 <meta charset="utf-8">
7 <meta http-equiv="X-UA-Compatible" content="IE=edge"> 7 <meta http-equiv="X-UA-Compatible" content="IE=edge">
8 <meta name="viewport" content="width=device-width, initial-scale=1"> 8 <meta name="viewport" content="width=device-width, initial-scale=1">
src/core/pyros_django/pyros/settings.py
@@ -286,6 +286,8 @@ else: @@ -286,6 +286,8 @@ else:
286 } 286 }
287 } 287 }
288 CONN_MAX_AGE = 0 288 CONN_MAX_AGE = 0
  289 +# New in Django 3.2 : we have to tell that we want auto field for id
  290 +DEFAULT_AUTO_FIELD='django.db.models.AutoField'
289 # SIMULATOR==True ==> 'TEST (simu)' RUN MODE, use pyros_test database 291 # SIMULATOR==True ==> 'TEST (simu)' RUN MODE, use pyros_test database
290 if SIMULATOR: 292 if SIMULATOR:
291 DATABASES = { 293 DATABASES = {
@@ -352,7 +354,8 @@ USE_L10N = True @@ -352,7 +354,8 @@ USE_L10N = True
352 USE_TZ = True 354 USE_TZ = True
353 355
354 # To find the media files {{ MEDIA_URL }} 356 # To find the media files {{ MEDIA_URL }}
355 -MEDIA_URL = '/public/static/media/' 357 +# change with Django 3.2 : media url can't be within static folder
  358 +MEDIA_URL = '/public/media/'
356 359
357 360
358 # To find the static files in the app/static/app/... folders 361 # To find the static files in the app/static/app/... folders
src/core/pyros_django/scientific_program/tests.py
@@ -209,16 +209,16 @@ class ScientificProgramTests(TestCase): @@ -209,16 +209,16 @@ class ScientificProgramTests(TestCase):
209 "public_visibility":SP_Period.VISIBILITY_YES, 209 "public_visibility":SP_Period.VISIBILITY_YES,
210 "quota_minimal":2, 210 "quota_minimal":2,
211 "quota_nominal":5, 211 "quota_nominal":5,
212 - "quota_allocated":None, 212 + "quota_allocated":"",
213 "over_quota_duration":2, 213 "over_quota_duration":2,
214 - "over_quota_duration_allocated":None, 214 + "over_quota_duration_allocated":"",
215 "token":2, 215 "token":2,
216 - "token_allocated":None,  
217 - "vote_referee1":None,  
218 - "reason_referee1":None,  
219 - "vote_referee2":None,  
220 - "reason_referee2":None,  
221 - "priority":None, 216 + "token_allocated":"",
  217 + "vote_referee1":"",
  218 + "reason_referee1":"",
  219 + "vote_referee2":"",
  220 + "reason_referee2":"",
  221 + "priority":"",
222 "is_valid":False 222 "is_valid":False
223 } 223 }
224 response = self.client.post(path,post_data) 224 response = self.client.post(path,post_data)
src/core/pyros_django/user_manager/forms.py
@@ -27,9 +27,10 @@ class PyrosUserCreationForm(forms.ModelForm): @@ -27,9 +27,10 @@ class PyrosUserCreationForm(forms.ModelForm):
27 27
28 def __init__(self, *args, **kwargs): 28 def __init__(self, *args, **kwargs):
29 super(PyrosUserCreationForm, self).__init__(*args, **kwargs) 29 super(PyrosUserCreationForm, self).__init__(*args, **kwargs)
30 - self.fields.move_to_end('tel', True)  
31 - self.fields.move_to_end('laboratory', True)  
32 - self.fields.move_to_end('address', True) 30 + # Python > 3.7 : move_to_end isn't a function of Dict anymore (but works on OrderedDict)
  31 + # self.fields.move_to_end('tel', True)
  32 + # self.fields.move_to_end('laboratory', True)
  33 + # self.fields.move_to_end('address', True)
33 for field in self.fields.values(): 34 for field in self.fields.values():
34 field.required = True 35 field.required = True
35 field.widget.attrs['class'] = "form-control" 36 field.widget.attrs['class'] = "form-control"
src/core/pyros_django/user_manager/templates/user_manager/base_home.html
@@ -5,7 +5,7 @@ @@ -5,7 +5,7 @@
5 <!DOCTYPE html> 5 <!DOCTYPE html>
6 <html lang="en"> 6 <html lang="en">
7 <head> 7 <head>
8 - {% load staticfiles %} 8 + {% load static %}
9 9
10 <meta charset="utf-8"> 10 <meta charset="utf-8">
11 <meta http-equiv="X-UA-Compatible" content="IE=edge"> 11 <meta http-equiv="X-UA-Compatible" content="IE=edge">