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() run("virtualenv %s --distribute" % env.proj_name)
def deploy(preflight): if preflight: logger.info('running preflight checks') if not preflight_checks(): return logger.info('deploying') run() js_code_snippet()
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")
def init_git(): with project(): run("git init") run("echo '.idea/' >> .gitignore") run("echo 'last.commit' >> .gitignore") run("echo 'gunicorn.pid' >> .gitignore") run("git add .") run("git commit -m'init'") #TODO: We shouldn't assume unfuddle here with settings(warn_only=True): run("git remote add unfuddle %s" % env.repo_url) run("git config remote.unfuddle.push refs/heads/master:refs/heads/master") run("git push unfuddle master")
def lfm_deploy(path, **kwargs): deploy.run(path, {k: v for k, v in utils.iteritems(kwargs) if v})
def lfm_deploy(uri, **kwargs): if kwargs['profile'] is not None: boto3.setup_default_session(profile_name=kwargs['profile']) del kwargs['profile'] deploy.run(uri, {k: v for k, v in utils.iteritems(kwargs) if v})