Created
September 2, 2010 07:33
-
-
Save kmmbvnr/562005 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
This file contains hidden or 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 python2.6 | |
# -*- coding: utf-8 -*- | |
from os import path | |
import shutil, sys | |
try: | |
from ve_setup import use_virtualenv | |
except ImportError: | |
import urllib | |
urllib.urlretrieve("http://tiny.cc/ve-setup", 've_setup.py') | |
from ve_setup import use_virtualenv | |
PROJECT_ROOT = path.abspath(path.dirname(__file__)) | |
REQUIREMENTS = path.join(PROJECT_ROOT, 'requirements.pip') | |
VE_ROOT = path.join(PROJECT_ROOT, '.ve') | |
VE_TIMESTAMP = path.join(VE_ROOT, 'timestamp') | |
envreqs = path.exists(VE_TIMESTAMP) and path.getmtime(VE_TIMESTAMP) or 0 | |
envspec = path.getmtime(REQUIREMENTS) | |
def setup_ve(): | |
use_virtualenv(argv=[VE_ROOT], | |
requirements="requirements.pip", | |
activate=True) | |
if 'update_ve' in sys.argv: | |
if path.exists(VE_ROOT): | |
shutil.rmtree(VE_ROOT) | |
setup_ve() | |
file(VE_TIMESTAMP, 'w').close() | |
sys.exit(0) | |
elif envreqs < envspec: | |
print "VirtualEnv need to be updated" | |
print "Run ./manage.py update_ve" | |
sys.exit(1) | |
setup_ve() | |
# run django | |
from django.core.management import execute_manager | |
try: | |
import settings # Assumed to be in the same directory. | |
except ImportError: | |
import sys | |
sys.stderr.write("Error: Can't find the file 'settings.py' in the directory") | |
sys.exit(1) | |
if __name__ == "__main__": | |
execute_manager(settings) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment