mirror of
https://github.com/ansible/awx.git
synced 2026-03-09 05:29:26 -02:30
Support South migrations and Django management commands in .pyc files.
This commit is contained in:
@@ -16,6 +16,22 @@ try:
|
|||||||
except ImportError:
|
except ImportError:
|
||||||
MODE = 'production'
|
MODE = 'production'
|
||||||
|
|
||||||
|
def find_commands(management_dir):
|
||||||
|
# Modified version of function from django/core/management/__init__.py.
|
||||||
|
command_dir = os.path.join(management_dir, 'commands')
|
||||||
|
commands = []
|
||||||
|
try:
|
||||||
|
for f in os.listdir(command_dir):
|
||||||
|
if f.startswith('_'):
|
||||||
|
continue
|
||||||
|
elif f.endswith('.py') and f[:-3] not in commands:
|
||||||
|
commands.append(f[:-3])
|
||||||
|
elif f.endswith('.pyc') and f[:-4] not in commands:
|
||||||
|
commands.append(f[:-4])
|
||||||
|
except OSError:
|
||||||
|
pass
|
||||||
|
return commands
|
||||||
|
|
||||||
def manage():
|
def manage():
|
||||||
# Update the default settings environment variable based on current mode.
|
# Update the default settings environment variable based on current mode.
|
||||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'awx.settings.%s' % MODE)
|
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'awx.settings.%s' % MODE)
|
||||||
@@ -23,6 +39,10 @@ def manage():
|
|||||||
local_site_packages = os.path.join(os.path.dirname(__file__), 'lib',
|
local_site_packages = os.path.join(os.path.dirname(__file__), 'lib',
|
||||||
'site-packages')
|
'site-packages')
|
||||||
sys.path.insert(0, local_site_packages)
|
sys.path.insert(0, local_site_packages)
|
||||||
|
# Monkeypatch Django find_commands to also work with .pyc files.
|
||||||
|
import django.core.management
|
||||||
|
django.core.management.find_commands = find_commands
|
||||||
|
# Now run the command (or display the version).
|
||||||
from django.core.management import execute_from_command_line
|
from django.core.management import execute_from_command_line
|
||||||
if len(sys.argv) >= 2 and sys.argv[1] in ('version', '--version'):
|
if len(sys.argv) >= 2 and sys.argv[1] in ('version', '--version'):
|
||||||
sys.stdout.write('awx-%s\n' % __version__)
|
sys.stdout.write('awx-%s\n' % __version__)
|
||||||
|
|||||||
@@ -11,6 +11,9 @@ TEMPLATE_DEBUG = DEBUG
|
|||||||
# Clear database settings to force production environment to define them.
|
# Clear database settings to force production environment to define them.
|
||||||
DATABASES = {}
|
DATABASES = {}
|
||||||
|
|
||||||
|
# Enable South to look for migrations in .pyc files.
|
||||||
|
SOUTH_USE_PYC = True
|
||||||
|
|
||||||
# Clear the secret key to force production environment to define it.
|
# Clear the secret key to force production environment to define it.
|
||||||
SECRET_KEY = None
|
SECRET_KEY = None
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user