def create_virtualenv(): with cd(env.venv_home): if exists(env.proj_name): if not confirm("Virtualenv exists: %s\n Do you want to replace it?" % env.proj_name): print "\nAborting!" return False removeapp() sudo("virtualenv %s --distribute" % env.proj_name)
def pip_install_task(): with virtualenv(): sudo("pip install -r %s/%s" % (env.proj_path, env.reqs_path))
def create_compressor(): sudo("apt-get install -y -q g++ make checkinstall") if not remote_exists("~/src", use_sudo=True): sudo("mkdir ~/src") with cd("~/src"): sudo("wget -N http://nodejs.org/dist/v0.10.13/node-v0.10.13.tar.gz") sudo("tar xzvf node-v0.10.13.tar.gz") with cd("node-v0.10.13"): sudo("./configure") #TODO: Currently prompts you to fill out documentation and change node version number sudo("checkinstall") sudo("dpkg -i node_*") sudo("npm install -g less")
def create_project(): pip("mezzanine") with activate_venv(): # /vagrant is the shared mounted folder between vagrant and your local filesystem with cd("/vagrant"): sudo("mezzanine-project %s" % env.proj_name) with project(): sudo("pip freeze > requirements.txt") sudo("%s startapp %s" % (env.manage, env.app_name)) get("settings.py", "remote_settings.py") Helper().add_line_to_list("remote_settings.py", "settings.py.tmp", "INSTALLED_APPS = (", ' "%s",' % env.app_name) put("settings.py.tmp", "settings.py", use_sudo=True) put("%s/vagrant_settings.py" % os.path.dirname(os.path.realpath(__file__)), "deploy/vagrant_settings.py", use_sudo=True) put("%s/celeryd.conf" % os.path.dirname(os.path.realpath(__file__)), "deploy/celeryd.conf", use_sudo=True) # Add the appropriate fabric settings for local and development deployment put("fabric_settings.py", "fabric_settings.py", use_sudo=True) with open("%s/fabric_import.py" % os.path.dirname(os.path.realpath(__file__))) as f: file_path = _expand_path("settings.py") sudo("echo '%s' >> %s" % ("", file_path)) for line in f: sudo("echo '%s' >> %s" % (line.rstrip('\n').replace("'", r"'\\''"), file_path)) # Set fabric settings according to user's input sed("fabric_settings.py", "\"DB_PASS\": \"vagrant\"", "\"DB_PASS\": \"%s\"" % env.db_pass, use_sudo=True, backup="", shell=True) sed("fabric_settings.py", "\"DB_PASS\": \"\"", "\"DB_PASS\": \"%s\"" % env.db_pass, use_sudo=True, backup="", shell=True) sed("fabric_settings.py", "\"PROJECT_NAME\": \"\"", "\"PROJECT_NAME\": \"%s\"" % env.proj_name, use_sudo=True, backup="", shell=True) sed("fabric_settings.py", "\"REPO_URL\": \"\"", "\"REPO_URL\": \"%s\"" % env.repo_url, use_sudo=True, backup="", shell=True) sed("fabric_settings.py", "\"PROJECT_PATH\": \"\"", "\"PROJECT_PATH\": \"%s\"" % env.proj_path, use_sudo=True, backup="", shell=True) # We will be using the manticore fabfile not Mezzanine's sudo("rm fabfile.py") # Change Mezzanine project to be compatible with this fabfile sed("deploy/live_settings.py", "\"HOST\": \"127.0.0.1\"", "\"HOST\": \"%s\"" % "%(primary_database_host)s", use_sudo=True, backup="", shell=True) append("deploy/live_settings.py", "\n# Django 1.5+ requires a set of allowed hosts\nALLOWED_HOSTS = [%(allowed_hosts)s]\n\n# Celery configuration (if django-celery is installed in requirements/requirements.txt)\nBROKER_URL = 'amqp://%(proj_name)s:%(admin_pass)[email protected]:5672/%(proj_name)s'\n\n") #TODO: Install and Link manticore-django fabfile package? run("cp deploy/live_settings.py deploy/development_settings.py") run("cp deploy/live_settings.py deploy/staging_settings.py") run("cp deploy/live_settings.py deploy/production_settings.py") run("rm deploy/live_settings.py") local("rm settings.py.tmp remote_settings.py")
def create_project(is_new=False): pip("django mezzanine pep8 pyflakes django-model-utils") with activate_venv(): # /vagrant is the shared mounted folder between vagrant and your local filesystem with cd("/vagrant"): sudo("mezzanine-project %s" % env.proj_name) with project(): sudo("pip freeze > requirements.txt") sudo("%s startapp %s" % (env.manage, env.app_name)) settings_path = "settings.py" if is_new: settings_path = "{}/{}".format(env.proj_name, settings_path) get(settings_path, "remote_settings.py") Helper().add_line_to_list("remote_settings.py", "settings.py.tmp", "INSTALLED_APPS = (", ' "%s",' % env.app_name) put("settings.py.tmp", "settings.py", use_sudo=True) sed("settings.py", "USE_SOUTH = True", "USE_SOUTH = False", use_sudo=True, backup="", shell=True) put("%s/vagrant_settings.py" % os.path.dirname(os.path.realpath(__file__)), "deploy/vagrant_settings.py", use_sudo=True) put("%s/celeryd.conf" % os.path.dirname(os.path.realpath(__file__)), "deploy/celeryd.conf", use_sudo=True) # Add the appropriate fabric settings for local and development deployment put("fabric_settings.py", "fabric_settings.py", use_sudo=True) with open("%s/fabric_import.py" % os.path.dirname(os.path.realpath(__file__))) as f: file_path = _expand_path("settings.py") sudo("echo '%s' >> %s" % ("", file_path)) for line in f: sudo("echo '%s' >> %s" % (line.rstrip('\n').replace("'", r"'\\''"), file_path)) # Set fabric settings according to user's input sed("fabric_settings.py", "\"DB_PASS\": \"vagrant\"", "\"DB_PASS\": \"%s\"" % env.db_pass, use_sudo=True, backup="", shell=True) sed("fabric_settings.py", "\"DB_PASS\": \"\"", "\"DB_PASS\": \"%s\"" % env.db_pass, use_sudo=True, backup="", shell=True) sed("fabric_settings.py", "\"PROJECT_NAME\": \"\"", "\"PROJECT_NAME\": \"%s\"" % env.proj_name, use_sudo=True, backup="", shell=True) sed("fabric_settings.py", "\"REPO_URL\": \"\"", "\"REPO_URL\": \"%s\"" % env.repo_url, use_sudo=True, backup="", shell=True) sed("fabric_settings.py", "\"PROJECT_PATH\": \"\"", "\"PROJECT_PATH\": \"%s\"" % env.proj_path, use_sudo=True, backup="", shell=True) # We will be using the manticore fabfile not Mezzanine's sudo("rm fabfile.py") # Change Mezzanine project to be compatible with this fabfile sed("deploy/local_settings.py.template", "\"HOST\": \"127.0.0.1\"", "\"HOST\": \"%s\"" % "%(primary_database_host)s", use_sudo=True, backup="", shell=True) append("deploy/local_settings.py.template", "\n# Django 1.5+ requires a set of allowed hosts\nALLOWED_HOSTS = [%(allowed_hosts)s]\n\n# Celery configuration (if django-celery is installed in requirements/requirements.txt)\nBROKER_URL = 'amqp://%(proj_name)s:%(admin_pass)[email protected]:5672/%(proj_name)s'\n\n") #TODO: Install and Link manticore-django fabfile package? run("cp deploy/local_settings.py.template deploy/development_settings.py") run("cp deploy/local_settings.py.template deploy/staging_settings.py") run("cp deploy/local_settings.py.template deploy/production_settings.py") run("rm deploy/local_settings.py.template") local("rm settings.py.tmp remote_settings.py")