Created
July 24, 2013 02:46
-
-
Save cchurch/6067733 to your computer and use it in GitHub Desktop.
Django manage.py example to support .pyc files.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import os | |
import sys | |
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 | |
if __name__ == "__main__": | |
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "myproject.settings") | |
import django.core.management | |
django.core.management.find_commands = find_commands | |
from django.core.management import execute_from_command_line | |
execute_from_command_line(sys.argv) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment