Commit b567cfa2 authored by Michal Čihař's avatar Michal Čihař

Move requirements checking earlier in the process

This allows us to check requirements before importing rest of the code,
so that we can tell user in nice way that something is broken instead of
ImportError of deep submodules.

Issue #427
parent d3642be5
......@@ -86,3 +86,8 @@ def get_doc_url(page, anchor=''):
url += '#%s' % anchor
return url
# Check for requirements
from weblate.trans.requirements import check_requirements
check_requirements()
......@@ -41,25 +41,3 @@ def create_permissions_compat(app, **kwargs):
except AttributeError as error:
# See https://code.djangoproject.com/ticket/20442
print 'Failed to create permission objects: {0}'.format(error)
@receiver(post_syncdb)
@receiver(post_migrate)
def check_versions(sender, app, **kwargs):
'''
Check required versions.
'''
if (app == 'trans'
or getattr(app, '__name__', '') == 'weblate.trans.models'):
from weblate.trans.requirements import get_versions, check_version
versions = get_versions()
failure = False
for version in versions:
failure |= check_version(*version)
if failure:
raise Exception(
'Some of required modules are missing or too old! '
'Check above output for details.'
)
......@@ -225,3 +225,20 @@ def get_versions_string():
)
)
return '\n'.join(result)
def check_requirements():
'''
Performs check on requirements and raises an exception on error.
'''
versions = get_versions()
failure = False
for version in versions:
failure |= check_version(*version)
if failure:
raise Exception(
'Some of required modules are missing or too old! '
'Check above output for details.'
)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment