Skip to content

Commit

Permalink
Update to python=3.12, django=4.2 and postgresql=16
Browse files Browse the repository at this point in the history
  • Loading branch information
rosswhitfield committed Jul 2, 2024
1 parent 5f2c914 commit e3ab01f
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 21 deletions.
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
prefix := /var/www/livedata
app_dir := live_data_server
DJANGO_COMPATIBLE:=$(shell python -c "import django;t=0 if django.VERSION[1]<9 else 1; print(t)")
DJANGO_COMPATIBLE:=$(shell python -c "import django;t=0 if django.VERSION[0]<4 else 1; print(t)")
DJANGO_VERSION:=$(shell python -c "import django;print(django.__version__)")

# command to run docker compose. change this to be what you have installed
Expand All @@ -14,13 +14,13 @@ help:

check: ## Check dependencies
@python -c "import django" || echo "\nERROR: Django is not installed: www.djangoproject.com\n"
@python -c "import psycopg2" || echo "\nWARNING: psycopg2 is not installed: http://initd.org/psycopg\n"
@python -c "import psycopg" || echo "\nWARNING: psycopg is not installed: http://initd.org/psycopg\n"
@python -c "import corsheaders" || echo "\nWARNING: django-cors-headers is not installed: https://github.com/ottoyiu/django-cors-headers\n"

ifeq ($(DJANGO_COMPATIBLE),1)
@echo "Detected Django $(DJANGO_VERSION)"
else
$(error Detected Django $(DJANGO_VERSION) < 1.9. The web monitor requires at least Django 1.9)
$(error Detected Django $(DJANGO_VERSION) < 4. The web monitor requires at least Django 4)
endif

docker/pruneall: docker/compose/validate ## stop all containers, then remove all containers, images, networks, and volumes
Expand Down
3 changes: 1 addition & 2 deletions config/docker-compose.envlocal.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ services:
condition: service_healthy

db:
# do not upgrade to version > 9.6.23 unless you also upgrade livedata image
image: postgres:9.6.23
image: postgres:16
environment:
POSTGRES_DB: ${DATABASE_NAME}
POSTGRES_USER: ${DATABASE_USER}
Expand Down
12 changes: 5 additions & 7 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,17 @@ name: livedata
channels:
- conda-forge
dependencies:
- python=3.7
- pip
- postgresql=9.5.3
- python=3.12
- postgresql=16
- sphinx
- sphinx_rtd_theme
- django=2.1
- django-cors-headers
- psycopg2
- django=4.2
- django-cors-headers=4.4
- psycopg=3.2
- gunicorn
- pytest
- build
- versioningit
- toml
- requests<2.31 # can remove this condition once we allow newer versions of openssl
- pre-commit
- coverage
6 changes: 3 additions & 3 deletions src/live_data_server/live_data_server/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
DEBUG = bool(os.environ.get("APP_DEBUG", False))
# CSRF_COOKIE_SECURE = True
# SESSION_COOKIE_SECURE = True
CSRF_TRUSTED_ORIGINS = [".ornl.gov", ".sns.gov", "localhost", "127.0.0.1"]
CSRF_TRUSTED_ORIGINS = ["https://*.ornl.gov", "https://*.sns.gov", "http://localhost", "http://127.0.0.1"]

ALLOWED_HOSTS = [
"localhost",
Expand Down Expand Up @@ -63,7 +63,7 @@

ROOT_URLCONF = "live_data_server.urls"

CORS_ORIGIN_ALLOW_ALL = True
CORS_ALLOW_ALL_ORIGINS = True

TEMPLATES = [
{
Expand All @@ -89,7 +89,7 @@

DATABASES = {
"default": {
"ENGINE": "django.db.backends.postgresql_psycopg2", # , 'mysql', 'sqlite3' or 'oracle'.
"ENGINE": "django.db.backends.postgresql", # , 'mysql', 'sqlite3' or 'oracle'.
"NAME": os.environ.get("DATABASE_NAME"), # Or path to database file if using sqlite3.
"USER": os.environ.get("DATABASE_USER"), # Not used with sqlite3.
"PASSWORD": os.environ.get("DATABASE_PASS"), # Not used with sqlite3.
Expand Down
1 change: 0 additions & 1 deletion src/live_data_server/plots/urls.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# pylint: disable=invalid-name, line-too-long
"""
Define url structure
"""
Expand Down
1 change: 0 additions & 1 deletion src/live_data_server/plots/view_util.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# pylint: disable=invalid-name, bare-except
"""
Utility functions to support views.
"""
Expand Down
1 change: 0 additions & 1 deletion src/live_data_server/plots/views.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# pylint: disable=unused-argument, invalid-name
"""
Definition of views
"""
Expand Down
6 changes: 3 additions & 3 deletions tests/test_post_get.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import json
import os

import psycopg2
import psycopg
import requests

TEST_URL = "http://127.0.0.1"
Expand All @@ -17,8 +17,8 @@ class TestLiveDataServer:
@classmethod
def setup_class(cls):
"""Clean the database before running tests"""
conn = psycopg2.connect(
database=os.environ.get("DATABASE_NAME"),
conn = psycopg.connect(
dbname=os.environ.get("DATABASE_NAME"),
user=os.environ.get("DATABASE_USER"),
password=os.environ.get("DATABASE_PASS"),
port=os.environ.get("DATABASE_PORT"),
Expand Down

0 comments on commit e3ab01f

Please sign in to comment.