Skip to content

Home Information - Your home, your data, organized.

Python

Added blurb and link to GettingStarted.md and CI workflow changes. Issue #2

Tony C318cf47a1c9d
diff --git a/.github/workflows/django-tests.yml b/.github/workflows/django-tests.yml
index f58278cb..21646d8e 100644
--- a/.github/workflows/django-tests.yml
+++ b/.github/workflows/django-tests.yml
@@ -9,6 +9,27 @@ jobs:
runs-on: ubuntu-latest
+ services:
+ redis:
+ image: redis:7 # Use the latest Redis version
+ ports:
+ - 6379:6379
+ options: >-
+ --health-cmd "redis-cli ping"
+ --health-interval 5s
+ --health-timeout 3s
+ --health-retries 5
+
+ env:
+ DJANGO_SETTINGS_MODULE: "hi.settings.ci"
+ DJANGO_SECRET_KEY: "django-insecure-@egpl51khoap^%x8*jc4xj0(hv)foor-%5897+@h665k3txo))7"
+ DJANGO_SUPERUSER_EMAIL: "[email protected]"
+ DJANGO_SUPERUSER_PASSWORD: "foobar"
+ HI_REDIS_HOST: "localhost"
+ HI_REDIS_PORT: "6379"
+ HI_DB_PATH: "/tmp"
+ HI_MEDIA_PATH: "/tmp"
+
steps:
- uses: actions/checkout@v3
@@ -25,7 +46,7 @@ jobs:
- name: Run Unit Tests
working-directory: ./src
run: |
- python manage.py test --keepdb
+ python manage.py test
- name: Check Code Style
working-directory: ./src
diff --git a/README.md b/README.md
index f7b58f10..070daba5 100644
--- a/README.md
+++ b/README.md
@@ -6,6 +6,8 @@ An application to visually organizes data about your home and the things in it.
<img src="docs/img/screenshot-kitchen.png" alt="Kitchen Example" width="250"> <img src="docs/img/screenshot-security.png" alt="Security Example" width="250"> <img src="docs/img/screenshot-cameras.png" alt="Camera Example" width="250">
+You can also see the [Getting Started Page](docs/GettingStarted.md) to get a feel for how it looks and works.
+
## Project Status
We are looking for early adopters and contributors. The software is functional, but early in its development with many additional features planned.
diff --git a/src/hi/settings/ci.py b/src/hi/settings/ci.py
new file mode 100644
index 00000000..696494bd
--- /dev/null
+++ b/src/hi/settings/ci.py
@@ -0,0 +1,42 @@
+# -*- coding: utf-8 -*-
+from .base import *
+
+# SECURITY WARNING: don't run with debug turned on in production!
+DEBUG = True
+
+STATIC_ROOT = '/tmp/hi/static'
+
+LOGGING = {
+ 'version': 1,
+ 'disable_existing_loggers': False,
+ 'formatters': {
+ 'simple': {
+ 'format': '{levelname} {message}',
+ 'style': '{',
+ },
+ },
+ 'handlers': {
+ 'console': {
+ 'class': 'logging.StreamHandler',
+ 'formatter': 'simple',
+ },
+ },
+ 'loggers': {
+ 'django': {
+ 'handlers': ['console'],
+ 'level': 'INFO',
+ },
+ 'hi': {
+ 'handlers': ['console' ],
+ 'level': 'INFO',
+ 'propagate': False,
+ },
+ },
+}
+
+BASE_URL_FOR_EMAIL_LINKS = 'http:/127.0.0.1:8411/'
+
+EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
+
+SUPPRESS_SELECT_REQUEST_ENPOINTS_LOGGING = True
+SUPPRESS_MONITORS = True
diff --git a/src/hi/settings/helpers.py b/src/hi/settings/helpers.py
index fd5c4237..8f302098 100644
--- a/src/hi/settings/helpers.py
+++ b/src/hi/settings/helpers.py
@@ -10,11 +10,16 @@ from django.core.exceptions import ImproperlyConfigured
@dataclass
class EnvironmentSettings:
"""
- Encapsulates the processing for the environment variables that are needed.
+ Encapsulates the parsing of the environment variables that are needed.
"""
- DJANGO_SETTINGS_MODULE : str = ''
+
+ # If the default value is "None" then the variable is required and its
+ # absence will raise an ImproperlyConfigured error. Optional
+ # arguments should have a non-None value (empty string, zero, etc.)
+ #
+ DJANGO_SETTINGS_MODULE : str = None
DJANGO_SERVER_PORT : int = 8000
- SECRET_KEY : str = ''
+ SECRET_KEY : str = None
DJANGO_SUPERUSER_EMAIL : str = None
DJANGO_SUPERUSER_PASSWORD : str = None
SITE_ID : str = 1
@@ -23,9 +28,9 @@ class EnvironmentSettings:
ALLOWED_HOSTS : Tuple[ str ] = field( default_factory = tuple )
CORS_ALLOWED_ORIGINS : Tuple[ str ] = field( default_factory = tuple )
EXTRA_CSP_URLS : Tuple[ str ] = field( default_factory = tuple )
- DATABASES_NAME_PATH : str = ''
- MEDIA_ROOT : str = ''
- REDIS_HOST : str = ''
+ DATABASES_NAME_PATH : str = None
+ MEDIA_ROOT : str = None
+ REDIS_HOST : str = 'localhost'
REDIS_PORT : int = 6379
REDIS_KEY_PREFIX : str = ''
SUPPRESS_AUTHENTICATION : bool = True
@@ -57,7 +62,10 @@ class EnvironmentSettings:
)
try:
env_settings.DJANGO_SERVER_PORT = int(
- cls.get_env_variable( 'DJANGO_SERVER_PORT', required = False )
+ cls.get_env_variable(
+ 'DJANGO_SERVER_PORT',
+ env_settings.DJANGO_SERVER_PORT,
+ )
)
except ( TypeError, ValueError ):
pass
@@ -99,7 +107,6 @@ class EnvironmentSettings:
env_settings.REDIS_KEY_PREFIX = cls.get_env_variable(
'HI_REDIS_KEY_PREFIX',
env_settings.REDIS_KEY_PREFIX,
-
)
###########
@@ -162,7 +169,7 @@ class EnvironmentSettings:
f'http://localhost:{env_settings.DJANGO_SERVER_PORT}',
]
- extra_host_urls_str = cls.get_env_variable( 'HI_EXTRA_HOST_URLS' )
+ extra_host_urls_str = cls.get_env_variable( 'HI_EXTRA_HOST_URLS', '' )
if extra_host_urls_str:
host_url_tuple_list = cls.parse_url_list_str( extra_host_urls_str )
@@ -178,7 +185,7 @@ class EnvironmentSettings:
cors_allowed_origins_list.append( url )
continue
- extra_csp_urls_str = cls.get_env_variable( 'HI_EXTRA_CSP_URLS' )
+ extra_csp_urls_str = cls.get_env_variable( 'HI_EXTRA_CSP_URLS', '' )
if extra_csp_urls_str:
host_url_tuple_list = cls.parse_url_list_str( extra_csp_urls_str )
for host, url in host_url_tuple_list:
@@ -204,11 +211,11 @@ class EnvironmentSettings:
return env_settings
@classmethod
- def get_env_variable( cls, var_name, default = None, required = True ) -> str:
+ def get_env_variable( cls, var_name, default = None ) -> str:
try:
return os.environ[var_name]
except KeyError:
- if default:
+ if default is not None:
return default
error_msg = "Set the %s environment variable" % var_name
raise ImproperlyConfigured(error_msg)