mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Better exception handling
This commit is contained in:
parent
7832ccccc2
commit
be6e2aa276
@ -6,7 +6,7 @@ from django.apps import AppConfig
|
|||||||
from django.core.exceptions import AppRegistryNotReady
|
from django.core.exceptions import AppRegistryNotReady
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
|
|
||||||
from InvenTree.ready import canAppAccessDatabase
|
from InvenTree.ready import isInTestMode, canAppAccessDatabase
|
||||||
import InvenTree.tasks
|
import InvenTree.tasks
|
||||||
|
|
||||||
|
|
||||||
@ -20,7 +20,9 @@ class InvenTreeConfig(AppConfig):
|
|||||||
|
|
||||||
if canAppAccessDatabase():
|
if canAppAccessDatabase():
|
||||||
self.start_background_tasks()
|
self.start_background_tasks()
|
||||||
self.update_exchange_rates()
|
|
||||||
|
if not isInTestMode():
|
||||||
|
self.update_exchange_rates()
|
||||||
|
|
||||||
def start_background_tasks(self):
|
def start_background_tasks(self):
|
||||||
|
|
||||||
@ -95,5 +97,9 @@ class InvenTreeConfig(AppConfig):
|
|||||||
print("Exchange backend not found - updating")
|
print("Exchange backend not found - updating")
|
||||||
update = True
|
update = True
|
||||||
|
|
||||||
|
except:
|
||||||
|
# Some other error - potentially the tables are not ready yet
|
||||||
|
return
|
||||||
|
|
||||||
if update:
|
if update:
|
||||||
update_exchange_rates()
|
update_exchange_rates()
|
||||||
|
@ -1,6 +1,17 @@
|
|||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
|
||||||
|
def isInTestMode():
|
||||||
|
"""
|
||||||
|
Returns True if the database is in testing mode
|
||||||
|
"""
|
||||||
|
|
||||||
|
if 'test' in sys.argv:
|
||||||
|
return True
|
||||||
|
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
def canAppAccessDatabase():
|
def canAppAccessDatabase():
|
||||||
"""
|
"""
|
||||||
Returns True if the apps.py file can access database records.
|
Returns True if the apps.py file can access database records.
|
||||||
|
Loading…
Reference in New Issue
Block a user