Use import instead of sys.modules for verifying ara-server availability

If ara.server hasn't been imported already, it won't be there.

Change-Id: I6d9c79142b33882cf634db1c439c1df6f2c96c5c
This commit is contained in:
David Moreau Simard 2019-01-21 11:48:28 -05:00
parent f5edb8d609
commit 4a3f2b4418
No known key found for this signature in database
GPG Key ID: CBEB466764A9E621
1 changed files with 5 additions and 2 deletions

View File

@ -33,8 +33,11 @@ class AraOfflineClient(AraHttpClient):
def __init__(self):
self.log = logging.getLogger(__name__)
# Validate that ara-server is installed
if "ara.server" not in sys.modules:
# Validate that ara-server is available before letting Django attempt to
# import it
try:
import ara.server
except ImportError:
raise ImportError("AraOfflineClient requires ara-server to be installed.")
from django import setup as django_setup