def django_project(): """Créer un projet django dans son virtualenv""" with settings(show("user"), hide("warnings", "running", "stdout", "stderr")): project() domain() locale() if not exists("/home/%(user)s/.virtualenvs/%(projet)s" % env): # if confirm('Pas de virtualenv "%(projet)s", faut-il le créer ?' % env, default=False): run("mkvirtualenv %(projet)s" % env) run("source .bash_profile") with prefix("workon %(projet)s" % env): run("pip install django") print(green("Django installé.")) if not exists("projects/%s/" % (env.projet)): print(yellow("le projet %(projet)s n’existe pas encore" % env)) if confirm('Créer un projet django nommé "%(projet)s" ?' % env, default=False): with cd("projects/"): with prefix("workon %(projet)s" % env): run("django-admin.py startproject %s" % (env.projet)) print(green('Projet Django "%(projet)s" : OK.' % env)) else: print(green('Projet Django "%(projet)s" : OK.' % env)) # créer la db avec le nom du projet (idempotent) icanhaz.postgres.database(env.projet, env.user, template="template_postgis", locale=env.locale) print(green("Base de données %(projet)s : OK." % env)) django_wsgi() apache_vhost() dependencies() sudo("apachectl restart")
def deploy(upload_assets='yes'): """部署""" # 编译并上传静态文件 if upload_assets == 'yes': env.host_string = "localhost" with cd('/var/www/dianchang'): with settings(warn_only=True): local('rm -r output') with prefix('source venv/bin/activate'): local('python manage.py build') local('python manage.py upload') # 远程部署 env.host_string = config.HOST_STRING with cd('/var/www/dianchang'): with shell_env(MODE='PRODUCTION'): run('git reset --hard HEAD') run('git pull') run('git submodule foreach git checkout master') run('git submodule foreach git pull origin master') with prefix('source venv/bin/activate'): run('pip install -r requirements.txt') run('pip install -r application/models/requirements.txt') run('python manage.py db upgrade') run('python manage.py build') run('supervisorctl restart dianchang')
def deploy(key_file_name="../ec2.pem"): env.key_filename = key_file_name changes = local("git status --porcelain", capture=True) if len(changes): print " {}".format(changes) proceed = prompt( "you have uncommited changes, do you want to proceed", default=False, validate=bool ) if not proceed: return git_branch_name = local('git rev-parse --abbrev-ref HEAD', capture=True) with prefix(". /usr/share/virtualenvwrapper/virtualenvwrapper.sh"): with prefix("workon {}".format(virtual_env_name)): run("git fetch") run("git checkout {}".format(git_branch_name)) run("git pull origin {}".format(git_branch_name)) run("pip install -r requirements.txt") run("python manage.py migrate") run("python manage.py collectstatic --noinput") run("supervisorctl -c etc/test.conf restart gunicorn") run("supervisorctl -c etc/test.conf restart celery")
def clean_build(): """Nuke all testing directories before we get started.""" # export WORKON_HOME=${HOME}/.virtualenvs # export PROJECT_HOME=${HOME}/dev # export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3 # export VIRTUALENVWRAPPER_VIRTUALENV=/usr/local/bin/virtualenv # source /usr/local/bin/virtualenvwrapper.sh # export PYTHONSTARTUP=$HOME/.pythonrc # export PIP_DOWNLOAD_CACHE=$HOME/.pip/cache ################################################################################ with prefix("export VIRTUALENV_WRAPPER_SH=`which virtualenvwrapper.sh`"): with prefix("export VIRTUALENVWRAPPER_PYTHON=`which python3.5`"): with prefix("export VIRTUALENVWRAPPER_VIRTUALENV=`which virtualenv`"): with prefix("export WORKON_HOME=${HOME}/.virtualenvs"): with prefix("export PROJECT_HOME=${HOME}/dev"): with prefix("source $VIRTUALENV_WRAPPER_SH"): with prefix("export PYTHONSTARTUP=$HOME/.pythonrc"): with prefix( "export PIP_DOWNLOAD_CACHE=$HOME/.pip/cache" ): with prefix("workon scarlett_os"): with cd("/home/vagrant"): sudo( "pip3.5 install virtualenv virtualenvwrapper" ) run( "rm -rf /home/vagrant/dev/bossjones-github/scarlett_os" ) run("rm -rf /home/vagrant/gnome") run("rm -rf /home/vagrant/jhbuild") with prefix("deactivate"): run("rmvirtualenv scarlett_os")
def install_python_taiga_deps(cloned_xor_updated): remote_home = run('printf $HOME') apt_depends( 'python3', 'python3-pip', 'python-dev', 'python3-dev', 'python-pip', 'libzmq3-dev', 'virtualenvwrapper', 'libxml2-dev', 'libxslt1-dev', 'gettext', 'libgettextpo-dev' ) if not run("dpkg-query --showformat='${Version}' --show python3-lxml") == '3.5.0-1': download_and_install(url_prefix='https://launchpad.net/ubuntu/+source/lxml/3.5.0-1/+build/8393479/+files/', packages=('python3-lxml_3.5.0-1_amd64.deb',)) with shell_env(WORKON_HOME=run('printf $HOME/.virtualenvs')), prefix( 'source /usr/share/virtualenvwrapper/virtualenvwrapper.sh'): mkvirtualenv_if_needed_factory('-p /usr/bin/python3.4 --system-site-packages')('taiga') with prefix('workon taiga'), cd('taiga-back'): run("sed -i '0,/lxml==3.5.0b1/s//lxml==3.5.0/' requirements.txt") run('pip install -r requirements.txt') if cloned_xor_updated == 'cloned': put(taiga_dir('django.settings.py'), 'settings/local.py') run('python manage.py migrate --noinput') run('python manage.py compilemessages') run('python manage.py collectstatic --noinput') run('python manage.py loaddata initial_user') run('python manage.py loaddata initial_project_templates') run('python manage.py loaddata initial_role') run('python manage.py sample_data') install_circus(template_vars={'HOME': remote_home, 'USER': run('printf $USER')}, local_tpl_dir=taiga_dir()) else: run('python manage.py migrate --noinput') run('python manage.py compilemessages') run('python manage.py collectstatic --noinput') sudo('service circus restart')
def coop_project_setup(): '''Créer un projet django dans son virtualenv''' set_project() set_domain() with settings(show('user')):#, hide('warnings', 'running', 'stdout', 'stderr')): if not exists('/home/%(user)s/.virtualenvs/%(projet)s' % env): # if confirm('Pas de virtualenv "%(projet)s", faut-il le créer ?' % env, default=False): run('mkvirtualenv --system-site-packages %(projet)s' % env) run('source .bash_profile') with prefix('workon %(projet)s' % env): run('pip install git+git://github.com/credis/django-coop.git') print(green('Django et django-coop installé.')) if not exists('projects/%s/' % (env.projet)): print(yellow('le projet %(projet)s n’existe pas encore' % env)) if confirm('Créer un projet django nommé "%(projet)s" ?' % env, default=False): with cd('projects/'): with prefix('workon %(projet)s' % env): run('coop-admin.py startproject %(projet)s --domain %(domain)s' % env) print(green('Projet Django-coop "%(projet)s" : Installé.' % env)) # coop-admin scripts creates the WSGI script so we won't call django_wsgi() with cd('projects/%(projet)s' % env): with prefix('workon %(projet)s' % env): run('chmod +x manage.py') run('chmod -R g+rw media') vrfy_supervisor_conf() else: print(yellow('Projet Django-coop nommé "%(projet)s" : déjà installé.' % env)) # TODO proposer de réinstaller vrfy_supervisor_conf()
def coop_set_project(): '''Créer un projet django dans son virtualenv''' with settings(show('user'), hide('warnings', 'running', 'stdout', 'stderr')): if not exists('/home/%(user)s/.virtualenvs/%(projet)s' % env): # if confirm('Pas de virtualenv "%(projet)s", faut-il le créer ?' % env, default=False): run('mkvirtualenv --no-site-packages %(projet)s' % env) run('source .bash_profile') with cd('%(base_install)s' % env): with prefix('workon %(projet)s' % env): run('chmod +x manage.py') run('mkdir media') run('chmod -R g+rw media') else: #with prefix('workon %(projet)s' % env): #run('pip install --timeout=240 -r %(base_install)s/requirements.txt' % env) print(yellow('Projet Django-coop nommé "%(projet)s" : déjà installé.' % env)) # TODO proposer de réinstaller with prefix('workon %(projet)s' % env): print(yellow('Récupération des dépendances python du projet coop-mes')) run('pip install --timeout=1024 --use-mirrors -r %(base_install)s/requirements.txt' % env) print(green('Récupération des dépendances python du projet coop-mes')) # Création du répertoire de logs if not exists('%(base_install)s/logs' % env): run('mkdir %(base_install)s/logs' % env)
def collect_static_files(): """ Run django `collectstatic` command. """ with env.cd(settings.PROJECT_PATH), prefix(COMMANDS['set_environment']), \ prefix(COMMANDS['activate_virtualenv']): env.run('python rnacentral/manage.py collectstatic --noinput')
def run_commands(): print("[{user}@{host}] FROM {stage} STAGE".format(user=env.user, host=env.host, stage=STAGE.name.upper())) for cmd in COMMANDS: if cmd.only_stages is None or STAGE.name in cmd.only_stages: print(TRACE) if cmd.title != cmd.assemble(): print("{title}:".format(title=cmd.title)) with settings(warn_only=True): if env.host == 'localhost': result = local(cmd.assemble()) else: if cmd.cd is not None: with cd(cmd.cd): if cmd.prefix is not None: with prefix(cmd.prefix): result = run(cmd.assemble()) else: result = run(cmd.assemble()) else: if cmd.prefix is not None: with prefix(cmd.prefix): result = run(cmd.assemble()) else: result = run(cmd.assemble()) if result.failed and not confirm("{cmd:s} FAILED. Continue anyway? ".format(cmd=cmd.title)): abort("Aborting at user request.") if env.host != 'localhost': if env.host_string != env.all_hosts[-1] and not confirm("Continue to next host? "): abort("Aborting at user request.") else: print(DTRACE) else: print(DTRACE)
def switch(**kwargs): setup(**kwargs) print("switching %(layer)s to %(projectdir)s" % env) # follow current symlink, stop old one if env.layer == 'prd': with cd('current'): with prefix('. venv/bin/activate'): run('supervisorctl shutdown') # (re)start new one with cd('%(projectdir)s' % env): with prefix('. venv/bin/activate'): run('python manage.py migrate --noinput') if exists('%(projectdir)s/var/run/supervisord.sock' % env): run('supervisorctl reload') else: run('supervisord') run('rm -f var/stopped') # link current to new if env.layer == 'prd': run('rm -f current ; ln -s %(projectdir)s current' % env) # reload apache run('ln -fs %(projectdir)s/etc/%(webserver)s.conf %(homedir)s/sites-enabled/%(sitename)s' % env) run('sudo /etc/init.d/%(webserver)s reload' % env)
def deploy_dev_web(): local("virtualenv --no-site-packages web_proj/") with prefix(". web_proj/bin/activate"): local("git clone git://github.com/abztrakt/spacescout_web.git web_proj/spacescout_web") local("pip install -r web_proj/spacescout_web/requirements.txt") local("cp configs/dev/web_local_settings.py web_proj/web_proj/local_settings.py") local("cp web_proj/web_proj/sample.wsgi.py web_proj/web_proj/wsgi.py") _replace_local_settings_for("web_proj") with prefix("cd web_proj/"): local("python manage.py syncdb") if local("which curl", capture=True) != '' and not 'darwin' in local('uname', capture=True).lower(): with prefix("cd web_proj/bin/"): local("wget https://raw.github.com/chuwy/nodeenv/master/nodeenv.py") install_node_js = confirm("I am about to install node.js for you. It may take a long time, and it is possible to install it yourself. Okay to proceed?") if install_node_js: with prefix(". web_proj/bin/activate"): with prefix("python web_proj/bin/nodeenv.py -p"): local("npm install -g less") else: print('Skipping node.js install. You must install it yourself for the web app to work') else: if local("which curl", capture=True) == '': no_nodeenv_reason = " don't have curl installed " elif 'darwin' in local("uname", capture=True).lower(): no_nodeenv_reason = ' are on a Mac ' else: no_nodeenv_reason = ' are special ' print("You" + no_nodeenv_reason + "so I can't install nodeenv. You'll have to install node.js yourself.")
def deploy(state="unstable",app="web_api"): stable = state == "stable" branch = "master" if stable else "dev" environment = "server-" + ("stable" if stable else "unstable") message = "Deploying branch %s to %s" % (branch, environment) print "======================================================" print ("== %s ==" % message.ljust(42)) print "======================================================" code_dir = "/home/armadillo/%s" % environment with cd(code_dir): with prefix('WORKON_HOME=$HOME/.virtualenvs'): with prefix('source /usr/local/bin/virtualenvwrapper.sh'): with prefix('workon %s' % environment): print "Updating remote code" run("git pull origin %s" % branch) print "Migrating database" run("python manage.py migrate %s" % app) print "Running tests" run("python manage.py test") print "Restarting web server" run("touch armadillo_reuse/wsgi.py") print "======================================================" print "== All done! ==" print "======================================================"
def update(): u"""Function defining all steps required to properly update application.""" # Django app refresh: with contextlib.nested( cd('/var/www/volontuloapp_org/volontulo'), prefix('workon volontulo') ): run('git checkout master') run('git pull') run('pip install -r requirements.txt') # Gulp frontend refresh: with contextlib.nested( cd('/var/www/volontuloapp_org/volontulo/volontulo') ): run('npm install .') run('./node_modules/gulp/bin/gulp.js build') # Django site refresh: with contextlib.nested( cd('/var/www/volontuloapp_org'), prefix('workon volontulo') ): run('python manage.py migrate --traceback') run('service apache2 restart')
def run(task, sudo=None, shell=True, pty=True, combine_stderr=True): ''' Runs an invoke task in a remote environment. Pass the task as a string WITH argument parameters. If sudo is desired, pass either a string username, or True to respect the sudo conventions outlined in `cotton.helpers.remote()`. ''' command = ' '.join([ 'invoke', task, ]) with fab.prefix("umask 0002"): with fab.prefix(env.activate_virtualenv): with fab.cd(env.current_path): if isinstance(sudo, basestring): return fab.sudo( command, shell, pty, combine_stderr, user=sudo ) elif sudo: return helpers.remote( command, shell=shell, pty=pty, combine_stderr=combine_stderr ) else: return fab.run(command, shell, pty, combine_stderr)
def bundle_install(): with prefix('export PATH=/opt/www/.rbenv/bin:$PATH'): with prefix('RBENV_ROOT=/opt/www/.rbenv'): with prefix('which rbenv'): with prefix('eval "$(rbenv init -)"'): noopable(sudo)('gem install bundler') noopable(sudo)('bundle install --binstubs')
def compress_static_files(): """ Run django compressor. """ with env.cd(settings.PROJECT_PATH), prefix(COMMANDS['set_environment']), \ prefix(COMMANDS['activate_virtualenv']): env.run('python rnacentral/manage.py compress')
def switch(**kwargs): setup(**kwargs) print ("switching %(layer)s to %(projectdir)s" % env) # follow current symlink, stop old one if env.layer == "prd": with cd("current"): with prefix(". venv/bin/activate"): run("supervisorctl shutdown") # (re)start new one with cd("%(projectdir)s" % env): with prefix(". venv/bin/activate"): run("python manage.py migrate --noinput") if exists("%(projectdir)s/var/run/supervisord.sock" % env): run("supervisorctl reload") else: run("supervisord") run("rm -f var/stopped") # link current to new if env.layer == "prd": run("rm -f current ; ln -s %(projectdir)s current" % env) # reload apache run("ln -fs %(projectdir)s/etc/%(webserver)s.conf %(homedir)s/sites-enabled/%(sitename)s" % env) run("sudo systemctl reload httpd" % env)
def install_django_requirements(): """ Run pip install. """ with env.cd(settings.PROJECT_PATH), prefix(COMMANDS['set_environment']), \ prefix(COMMANDS['activate_virtualenv']): env.run('pip install --upgrade -r rnacentral/requirements.txt')
def release(): """Performs a full release""" with cd(getcwd()): with msg("Creating env"): run("mkvirtualenv test") with msg("Building"): with prefix("workon test"): run("fab develop") with msg("Running tests"): with prefix("workon test"): run("fab test") with msg("Building docs"): with prefix("workon test"): run("pip install -r docs/requirements.txt") run("fab docs") version = run("python setup.py --version") if "dev" in version: abort("Detected Development Version!") print("Release version: {0:s}".format(version)) if prompt("Is this ok?", default="Y", validate=r"^[YyNn]?$") in "yY": run("git tag {0:s}".format(version)) run("python setup.py egg_info sdist bdist_egg bdist_wheel register upload") run("python setup.py build_sphinx upload_sphinx") with msg("Destroying env"): run("rmvirtualenv test")
def build_docs(): with prefix("source /usr/local/bin/virtualenvwrapper.sh"),\ prefix("workon direnaj"): with cd(env.drenaj['code_dir']+"/docs"): run("mkdir -p modules") run("python generate_modules.py -s rst -d modules/ ../direnaj/direnaj_api/") run("rm modules/modules.rst") run("make html")
def build_static(): require('venv_activate') with lcd_git_root(): with lcd('project'): with prefix('source %s' % env.venv_activate): with prefix('PYTHONPATH+=":.."'): local('python manage.py collectstatic --settings=settings_build --noinput') local('python manage.py compress --settings=settings_build')
def run(self, command, settings=None, virtualenv="wtds"): if settings is None: settings = get_settings_module() command = "./manage.py {} --settings={}".format(command, settings) with cd(get_project_root() + "/wtds"): with prefix("source /etc/bash_completion.d/virtualenvwrapper"): with prefix("workon {}".format(virtualenv)): run(command)
def start_supervisor(): """ Start supervisord and memcached on production machine. """ with env.cd(settings.PROJECT_PATH), prefix(COMMANDS['set_environment']), \ prefix(COMMANDS['activate_virtualenv']): env.run('supervisord -c supervisor/supervisor.conf') env.run('supervisorctl -c supervisor/supervisor.conf start memcached')
def restart_all(key_file_name="../ec2.pem"): env.key_filename = key_file_name with prefix(". /usr/share/virtualenvwrapper/virtualenvwrapper.sh"): with prefix("workon {}".format(virtual_env_name)): run("supervisorctl -c etc/test.conf restart gunicorn") run("supervisorctl -c etc/test.conf restart celery") run("supervisorctl -c etc/test.conf restart gloss") run("supervisorctl -c etc/test.conf restart gloss_flask")
def virtual_env_setup(name): with prefix("source %s" % VIRTUAL_ENV_WRAPPER): with settings(warn_only=True): virtual_envs = local("workon", capture=True).splitlines() if name in virtual_envs: raise Exception("virtual env %s already exists" % name) with prefix("source %s" % VIRTUAL_ENV_WRAPPER): local("mkvirtualenv --no-site-packages %s" % name)
def virtualenv(): """ Context manager to run commands under an activated virtualenv """ # with prefix(env.activate): with prefix('WORKON_HOME=%s' % env.venvs_root): with prefix('source /usr/local/bin/virtualenvwrapper.sh'): with prefix('workon %s' % env.venv_name): yield
def pre_venv(): with prefix(env.source_virtualenvwrapper): with settings(abort_exception=FabricException): try: local('workon {}'.format(VENV_NAME)) except FabricException: local('mkvirtualenv {}'.format(VENV_NAME)) with prefix('workon {}'.format(VENV_NAME)): local('pip install -r req.txt')
def deploy_dev_docs(): local("virtualenv --no-site-packages docs_proj/") with prefix(". docs_proj/bin/activate"): local("[[ -e docs_proj/spacescout_docs ]] || git clone git://github.com/sbutler/spacescout_docs.git docs_proj/spacescout_docs") local("pip install -r docs_proj/spacescout_docs/requirements.txt") local("cp configs/dev/docs_local_settings.py docs_proj/docs_proj/local_settings.py") _replace_local_settings_for("docs_proj") with prefix("cd docs_proj/"): local("python manage.py syncdb")
def manage(command): """manage:<command>. Just like 'python manage.py <command>'""" python_bin = os.path.join(env.config.ApiServer.document_root, "env", "bin", "python") with prefix('export LC_ALL=en_US.UTF-8'): with prefix('export LANG=en_US.UTF-8'): with cd(env.config.ApiServer.document_root): return run("%s manage.py %s" % (python_bin, command))
def install(self, package): really = whatsreal() for eggproxy in self.eggproxies: with settings(prefix(self.prefix), warn_only=True): res = really.sudo('pip install --index=%s %s' % (eggproxy, package)) if type(res) is not str and res.succeeded: return with settings(prefix(self.prefix)): really.sudo('pip install %s' % package)
def run_playbook(): with cd('/home/user-ansible/ansible2.7.10/local/bin'): with prefix('. ../bin/activate'): run('ansible-playbook -i /home/user-ansible/.ansible/inventaire.ini --user user-ansible --become --ask-become-pass /home/user-ansible/.ansible/install-roles.yml')
def venv(): with cd('%(root)s%(project_name)s' % env), prefix(env.activate): yield
def migrate(): """ Migrates database to the latest south migration """ with cd(env.server_root_dir): with prefix('. .env/bin/activate'): run('python manage.py migrate --no-initial-data')
def run_prod_migrations(): with prefix('source %(virtualenv_dir)s/bin/activate' % env): with cd(env.project_code_dir): run("python manage.py migrate %(prod_settings)s" % env)
def create_superuser(): with prefix('source %(virtualenv_dir)s/bin/activate' % env): with cd(env.project_code_dir): run("python manage.py createsuperuser %(prod_settings)s" % env)
def collect_static_files(): with prefix('source %(virtualenv_dir)s/bin/activate' % env): with cd(env.project_code_dir): run("python manage.py collectstatic %(prod_settings)s" % env)
def source_virtualenv(): with prefix('source ' + os.path.join(VENV_DIR, 'bin/activate')): yield
def manage(command=""): with prefix( 'source {0}venv/bin/activate && export DATABASE_URL={1}'.format( PROJECT_DIR, DATABASE_URL)): with cd(DJANGO_DIR): run('python manage.py {0}'.format(command))
def install_requirements(): with prefix('source {}/venv/bin/activate'.format(PROJECT_DIR)): run('pip install -r {}'.format( os.path.join(PROJECT_DIR, 'requirements.txt')))
def start_upload(): with cd('/home/wakefield/dokun'), prefix(env.activate): run('gunicorn -c gunicorn.py app:app') restart_nginx()
def reinstall_requirement(which): require('srvr', 'path', 'within_virtualenv', provided_by=env.servers) with cd(env.path), prefix(env.within_virtualenv): run('pip uninstall {0} && pip install --no-deps {0}'.format(which))
def restart_upload(): with cd('/home/wakefield/dokun'), prefix(env.activate): sudo('sudo kill -HUP `cat /tmp/dokun.pid`')
def taskB(): with prefix("su hsc"): run("cd /root && ls")
def install_project_python_packages(): with prefix('source %(virtualenv_dir)s/bin/activate' % env): with cd(env.project_code_dir): run("pip install -r requirements.txt")
def touch_wsgi(): require('srvr', 'path', 'within_virtualenv', provided_by=env.servers) with cd(os.path.join(env.path, PROJECT_NAME)), \ prefix(env.within_virtualenv): run('touch wsgi.py')
def build_interface(): """ have grunt perform a deployment build for us """ with cd(CONFIG['interface_dir']), \ shell_env(PHANTOMJS_BIN='/usr/local/bin/phantomjs'), \ prefix('source {0}/bin/activate'.format(CONFIG['virt_env'])): run('grunt --force')
def install_supervisor(): with prefix('source %(virtualenv_dir)s/bin/activate' % env): run("pip install supervisor --pre") run("sudo cp -f %(deploy_dir)s/supervisorstart.conf /etc/init/" % env)
def install_python_env(): with cd(env.destination): sudo('virtualenv .ve') put('requirements.pip', '/tmp') with prefix('source .ve/bin/activate'): sudo('pip install -r /tmp/requirements.pip')
def _write_alert(level, msg): authenticate() with fab.prefix("umask 0002"): with open(env['alert_file'], "w") as fout: fout.write(DELIM.join([level, msg]))
def start (): with cd(DIR): with shell_env(PATH='/home/aspen/.nvm/versions/node/v6.10.3/bin:$PATH'): with prefix(VENV): run('pm2 start backend.js > start.log')
def virtualenv(): with cd(DESTDIR): with prefix(env.activate): yield
def lvirtualenv(name): INPUT_PATH = os.path.join(cwd, name) with lcd(INPUT_PATH): with prefix('source venv/bin/activate'): yield
def update_index(): require('srvr', 'path', 'within_virtualenv', provided_by=env.servers) with cd(env.path), prefix(env.within_virtualenv): run('./manage.py update_index')
def virtualenv(): #with cd("/var/www/wanglibao"): with prefix("source %s/bin/activate" % env.deploy_virt_path): yield
def virtualenv(user): activate_cmd = 'source ~%s/bin/activate' % user with nested(cd('~%s/' % user), prefix(activate_cmd)): yield
def install(): """ Installs gunicorn. """ with cd(env.server_root_dir): with prefix('. .env/bin/activate'): run('pip install gunicorn')
def virtualenv(): with cd(deploy_dir): with prefix(activate): yield
def virtualenv(path): activate = os.path.normpath(os.path.join(path, "bin", "activate")) if not os.path.exists(activate): raise OSError("Cannot activate virtualenv %s" % path) with prefix('. %s' % activate): yield
def start(): with cd(DIR): with shell_env( PATH='/home/tanweer/.nvm/versions/node/v6.10.3/bin:$PATH'): with prefix(VENV): run('pm2 start todo.js > start.log')
def migrate(app=None): require('srvr', 'path', 'within_virtualenv', provided_by=env.servers) with cd(env.path), prefix(env.within_virtualenv): run('./manage.py migrate {}'.format(app if app else ''))