Skip to content

Commit

Permalink
Minor improvements to remove print statements
Browse files Browse the repository at this point in the history
  • Loading branch information
jacklinke committed Nov 18, 2024
1 parent ddec5ba commit 568facc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
11 changes: 7 additions & 4 deletions src/django_tenant_options/app_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,20 @@
}
"""
import logging

from django.core.exceptions import ImproperlyConfigured


logger = logging.getLogger(__name__)

try:
from django.conf import settings
except ImproperlyConfigured:
print("**** ImproperlyConfigured")
except ImproperlyConfigured as e:
logger.error("Settings could not be imported: %s", e)
settings = None # pylint: disable=C0103
except ImportError:
print("**** ImportError")
except ImportError as e:
logger.error("Django could not be imported. Settings cannot be loaded: %s", e)
settings = None # pylint: disable=C0103
from django.db import models

Expand Down
8 changes: 4 additions & 4 deletions src/django_tenant_options/management/commands/listoptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,18 @@ def listoptions(self):
model_subclasses = all_option_subclasses()

if not model_subclasses:
print("No options found in the project.")
self.stdout.write(self.style.NOTICE("No options found in the project."))
return

for ModelClass in all_option_subclasses(): # pylint: disable=C0103
self.stdout.write(self.style.NOTICE(f"Model: {ModelClass.__name__}"))
self.stdout.write(self.style.WARNING(" Options:"))
for option in ModelClass.objects.active():
if option.tenant is not None:
print(f" - {option.name} (Tenant: {option.tenant})")
self.stdout.write(f" - {option.name} (Tenant: {option.tenant})")
else:
print(f" - {option.name}")
print()
self.stdout.write(f" - {option.name}")
self.stdout.write("")
except Exception as e: # pylint: disable=W0703
logger.error("Error: %s", e)

Expand Down

0 comments on commit 568facc

Please sign in to comment.