Skip to content

Home Information - Your home, your data, organized.

Python

Moved log filter for development into tests app.

Anthony Cassandrabde377028946
diff --git a/deploy/env-generate.py b/deploy/env-generate.py
index 617af1dd..42027b4a 100755
--- a/deploy/env-generate.py
+++ b/deploy/env-generate.py
@@ -193,8 +193,10 @@ class HiEnvironmentGenerator:
exit(1)
backup_filename = f'{self._destination_filename}.BAK'
- self.print_notice(f'Creating backup: {backup_filename}')
- shutil.copy2(self._destination_filename, backup_filename)
+ if os.path.exists( backup_filename ):
+ os.rename( backup_filename, f'{backup_filename}.BAK' )
+ self.print_notice( f'Creating backup: {backup_filename}' )
+ shutil.copy2( self._destination_filename, backup_filename )
return
def _get_data_directories( self ):
diff --git a/src/hi/settings/development.py b/src/hi/settings/development.py
index 8800bad1..f0d59655 100644
--- a/src/hi/settings/development.py
+++ b/src/hi/settings/development.py
@@ -18,7 +18,7 @@ LOGGING = {
#
'filters': {
'suppress_select_request_endpoints': {
- '()': 'hi.log_filters.SuppressSelectRequestEndpointsFilter',
+ '()': 'hi.tests.utils.log_filters.SuppressSelectRequestEndpointsFilter',
},
},
'formatters': {
diff --git a/src/hi/settings/helpers.py b/src/hi/settings/helpers.py
index 65971463..fd5c4237 100644
--- a/src/hi/settings/helpers.py
+++ b/src/hi/settings/helpers.py
@@ -167,7 +167,7 @@ class EnvironmentSettings:
host_url_tuple_list = cls.parse_url_list_str( extra_host_urls_str )
# Assume first extra host is the SITE_DOMAIN, but this does not
- # matter until Django "sites" feature need to be used (if
+ # matter until the Django "sites" feature needs to be used (if
# ever).
#
if host_url_tuple_list:
diff --git a/src/hi/tests/utils/__init__.py b/src/hi/tests/utils/__init__.py
new file mode 100644
index 00000000..e69de29b
diff --git a/src/hi/log_filters.py b/src/hi/tests/utils/log_filters.py
similarity index 91%
rename from src/hi/log_filters.py
rename to src/hi/tests/utils/log_filters.py
index 4ef48c89..917e7fe4 100644
--- a/src/hi/log_filters.py
+++ b/src/hi/tests/utils/log_filters.py
@@ -17,22 +17,23 @@ class SuppressSelectRequestEndpointsFilter(logging.Filter):
return True
try:
if not hasattr(record, "args") or ( len(record.args) < 1 ):
- return
+ return True
request_line = record.args[0]
if not isinstance( request_line, str ):
# Sometimes it apears to be a PosixPath, but for requests it is a string.
- return
+ return True
match = re.match( r'^[A-Z]+ (/[^ ?]*)', request_line )
if not match:
- return
+ return True
request_path = match.group(1)
match = resolve( request_path )
if match.url_name in self.URL_NAMES_TO_FILTER:
return False
+
except Exception:
pass