def new(project_name='', app_name='', db_password='', repo_url='', is_new=''): if len(project_name) == 0 or len(app_name) == 0 or len(db_password) == 0 or len(repo_url) == 0: print "Usage: fab new:<project_name>,<app_name>,<db_password>,<repo_url>,<is_new>" print "" print "Common usage:" print " <project_name> should be different than <app_name>" return # triggers usage of the new django file-structure if is_new and is_new == 'True': is_new = True # ensure that project_name and app_name are different if project_name == app_name and not confirm("Your app_name is the same as the project_name. They should be different. Continue?"): return if not create_vagrantfile(): return False # Add the current directory to our sys path so we can import fabric_settings sys.path.append(os.getcwd()) # Create a fake settings file for access to vagrant local("cp %s/fabric_settings.py fabric_settings.py" % os.path.dirname(os.path.realpath(__file__))) env.settings = __import__("fabric_settings", globals(), locals(), [], 0).FABRIC vagrant() # Set appropriate settings from inputs env.proj_path = "/vagrant/%s" % project_name env.proj_name = project_name env.venv_path = "%s/%s" % (env.venv_home, env.proj_name) env.db_pass = db_password env.app_name = app_name env.manage = "%s/bin/python /vagrant/%s/manage.py" % (env.venv_path, env.proj_name) env.repo_url = repo_url # Set up vagrant box with appropriate system packages execute(install_prereq) execute(installdb) execute(fix_db_permissions) execute(installapp) execute(copy_db_ssh_keys) # Set up a virtualenv and mezzanine project execute(create_prereq) execute(create_virtualenv) execute(create_project, is_new=is_new) # Remove temp settings and change local working path permanently into project folder so we can copy deploy templates local("rm fabric_settings.py fabric_settings.pyc") os.chdir(env.proj_name) # Finish setting up the database and copy over appropriate templates createdb(True) execute(createapp2, is_new=is_new) execute(create_rabbit, True) execute(init_db) execute(init_git)
def pip_install(): """Runs pip install""" env.settings = __import__("fabric_settings", globals(), locals(), [], 0).FABRIC print env.settings vagrant() execute(pip_install_task)