def install_db_patches(): with prefix(env.activate): with prefix(env.proj_pythonpath): with show('stdout'): print green("Installing db_patches") src = os.path.join(env.proj_dir, 'src', 'install_db_patches.py') run('python %s update' % src)
def package_update(): """ Update the environment using the package manager """ with prefix('source '+env.homedir+'/.bashrc'): with prefix(env.activate): with prefix('workon %s' % env.venv): with cd('%s/APM/System/dvt/Tools/fortytwo/setup' % env.accurev.accurev_home): sudoenv('pip install --requirement %s/APM/System/dvt/Tools/fortytwo/setup/fortytwo_pip_reqts.txt' % env.accurev.accurev_home)
def deploy_static_files(): sudo('mkdir -p /var/www/bongo/static/') with cd(GIT_TOP_LEVEL): with prefix('export HOME=/home/bongo'): with prefix('source /usr/local/bin/virtualenvwrapper.sh'): with prefix('workon bongo'): sudo('./manage.py collectstatic -v0 --noinput', 'bongo')
def clear_databases(): """ Clear out all databases. This is very destructive, only useful for testing! """ require('hosts', provided_by=['dev', 'staging', 'production']) ans = prompt('This will completely wipe out the database. Are you sure (YES/no)?') if ans != 'YES': print yellow('Glad you were just kidding.') return ans = prompt(yellow('%s' % env.hosts[0]) + ' database will be wiped. Are you sure (YES/no)?') if ans != 'YES': print "Didn't think so." return run('supervisorctl stop all') print yellow('Recreate WEB database') run('dropdb ocl_web') run('createdb -O deploy ocl_web') # setup DB with prefix('source /opt/virtualenvs/ocl_web/bin/activate'): with prefix('export DJANGO_CONFIGURATION="Production"'): with prefix('export DJANGO_SECRET_KEY="blah"'): print yellow('creating WEB database...') run('/opt/deploy/ocl_web/ocl_web/manage.py syncdb --noinput --migrate') print yellow('Recreate API database') run('echo -e "use ocl \n db.dropDatabase();" | mongo') create_api_database()
def _install_requirements(self): # needed for private repos, local keys get forwarded env.forward_agent = True env.user = config['USER'] env.remote_home = "/home/" + config['USER'] virtualenv_dir = '%s/.virtualenvs/%s' % (env.remote_home, env.project_name) info("DJANGO: install python modules in virtualenv %s" % virtualenv_dir) # from requirements.txt with prefix('. %s/bin/activate' % virtualenv_dir): with cd("%s/code/%s" % (env.remote_home, env.project_name)): cmd = "pip install " \ "--download-cache=/var/cache/pip " \ "-r requirements.txt" debug("PIP: " + cmd) out = self.execute(run, cmd) for host, value in out.iteritems(): debug(value, host=host) # from class variable if hasattr(self.__class__, "python_packages"): for package in self.__class__.python_packages.split(" "): with prefix('. %s/.virtualenvs/%s/bin/activate' % (env.remote_home, env.project_name)): with cd("%s/code/%s" % (env.remote_home, env.project_name)): out = self.execute(run, "pip install --download-cache=/var/cache/pip %s" % (package)) for host, value in out.iteritems(): debug(value, host=host)
def get_platform(self): # Be sure we don't get stuck in a virtualenv for free. with prefix('deactivate >/dev/null 2>&1 || true'): out = run("python -c 'import lsb_release; " "print lsb_release.get_lsb_information()'", quiet=not DEBUG, combine_stderr=False) try: self.lsb = SimpleObject(from_dict=ast.literal_eval(out)) self.is_osx = False except SyntaxError: self.lsb = None self.is_osx = True # Be sure we don't get stuck in a virtualenv for free. with prefix('deactivate >/dev/null 2>&1 || true'): out = run("python -c 'import platform; " "print platform.mac_ver()'", quiet=not DEBUG, combine_stderr=False) try: self.mac = SimpleObject(from_dict=dict(zip( ('release', 'version', 'machine'), ast.literal_eval(out)))) except SyntaxError: # something went very wrong, # none of the detection methods worked. raise RuntimeError( 'cannot determine platform of {0}'.format(self.host_string))
def _update_virtualenv(source_folder): with prefix('export WORKON_HOME=$HOME/.virtualenvs'): with prefix('export PROJECT_HOME=$HOME/sites'): with prefix('export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3'): with prefix('source /usr/local/bin/virtualenvwrapper.sh'): with prefix('workon tdd'): run('pip install -r %s/requirements.txt' % (source_folder,))
def rebuild_index(): """ Rebuild search index """ with prefix("source /opt/virtualenvs/ocl_api/bin/activate"): with prefix('export DJANGO_CONFIGURATION="Production"'): sudo('/etc/init.d/jetty restart') sleep(5) run("/opt/deploy/ocl_api/ocl/manage.py rebuild_index")
def bash_profile(): """ Fixes stuff that non-interactive shells don't do automatically. """ with prefix('export HOME={}'.format(project_home())), \ prefix('source {}/.bash_profile'.format(project_home())): yield
def push_code(): require('hosts') require('code_root') import time env.release = time.strftime('%Y%m%d%H%M%S') tar_file = '%s.tar.gz' % (env.release,) local('git archive --format=tar master | gzip > %s' % (tar_file,)) put(tar_file, '%s/packages/' % env.code_root) run('mkdir -p %s/releases/%s/pywars' % (env.code_root, env.release)) run('cd %s/releases && tar zxf ../packages/%s.tar.gz -C %s/releases/%s/pywars' % (env.code_root, env.release, env.code_root, env.release)) with prefix('source %s/bin/activate' % (env.code_root,)): run("cd %s/releases/%s/pywars; pip install -r requirements.txt" % (env.code_root, env.release)) run('cd %s/releases/%s/pywars; pip install mysql-python') run('cd %s/releases/%s/pywars; python manage.py bower install' % (env.code_root, env.release)) run("cd %s/releases/%s/pywars; python manage.py collectstatic --noinput" % (env.code_root, env.release)) local('rm -fr %s' % (env.release,)) local('rm %s' % (tar_file,)) symlink_current_release() with settings(warn_only=True): # copy the local_settings for deployment run("cp /home/%s/local_settings.py %s/releases/%s/pywars/battleground/" % (env.user, env.code_root, env.release)) with prefix('source %s/bin/activate' % (env.code_root,)): run("cd %s/releases/%s/pywars; python manage.py migrate" % (env.code_root, env.release))
def conf(mode=None): """Switch Refinery configurations on Vagrant VM""" if (mode is None) or (env.hosts != ['[email protected]:2222']): abort("usage: fab vm conf:<mode>") modes = ['dev', 'djdt', 'gdev', 'prod'] if mode not in modes: abort("Mode must be one of {}".format(modes)) puts("Switching Refinery running on Vagrant VM to '{}' mode".format(mode)) env.shell_before = "export DJANGO_SETTINGS_MODULE=config.settings.*" env.shell_after = \ "export DJANGO_SETTINGS_MODULE=config.settings.{}".format(mode) env.apache_before = "SetEnv DJANGO_SETTINGS_MODULE config.settings.*" env.apache_after = \ "SetEnv DJANGO_SETTINGS_MODULE config.settings.{}".format(mode) # stop supervisord and Apache with prefix("workon {refinery_virtualenv_name}".format(**env)): run("supervisorctl shutdown") sudo("/usr/sbin/service apache2 stop") # update DJANGO_SETTINGS_MODULE sed('/home/vagrant/.profile', before=env.shell_before, after=env.shell_after, backup='') sed('/etc/apache2/sites-available/001-refinery.conf', before=env.apache_before, after=env.apache_after, use_sudo=True, backup='') # update static files with cd(env.refinery_ui_dir): run("grunt make") with prefix("workon {refinery_virtualenv_name}".format(**env)): run("{refinery_app_dir}/manage.py collectstatic --clear --noinput" .format(**env)) # start supervisord and Apache with prefix("workon {refinery_virtualenv_name}".format(**env)): run("supervisord") sudo("/usr/sbin/service apache2 start")
def ring(): """ Bootstrap Scality RING (environment variable `SCAL_PASS` must be exported). The environment variable `SCAL_PASS` is expected to hold username:password for fetching scality packages. """ install_env = { 'SUP_ADMIN_LOGIN': '******', 'SUP_ADMIN_PASS': '******', 'INTERNAL_MGMT_LOGIN': '******', 'INTERNAL_MGMT_PASS': '******', 'HOST_IP': env.host, 'SCAL_PASS': os.environ['SCAL_PASS'], } export_vars = ('{0:s}={1:s}'.format(k, v) for k, v in install_env.items()) export_cmd = 'export {0:s}'.format(' '.join(export_vars)) utils.apt_get(['git-core']) run('git clone https://github.com/scality/openstack-ci-scripts.git') # Hide aborts to not leak any repository passwords to console on failure. with cd('openstack-ci-scripts/jenkins'), prefix(export_cmd): with prefix('source ring-install.sh'), settings(hide('aborts')): run('add_source') run('install_base_scality_node', pty=False) # avoid setup screen run('install_supervisor') run('install_ringsh') run('build_ring') run('install_sproxyd') run('test_sproxyd')
def config(): global repo_path _printOut('Creating repo on: '+str(env.hosts)) with cd('/sites/'): sudo('hg clone ssh://[email protected]/rccomunicacao/{{PROJECT_NAME}}', user='******') with cd(repo_path): sudo('virtualenv --distribute env', user='******') with prefix('source env/bin/activate'): print('Installing environment') sudo('pip install -r requirements.txt', user='******') sudo('cp {{PROJECT_ID}}/local_settings_template.py {{PROJECT_ID}}/local_settings.py', user='******') database_name = prompt('Name of MySQL database to be created: ', default='{{PROJECT_ID}}') sudo('mysql -u root -p -e "create database %s"'%database_name, user='******') print('Now starting the configure of the local_settings.py module') config_local_settings() put('{{PROJECT_ID}}/server_local_settings.py', '{{PROJECT_ID}}/local_settings.py', use_sudo=True) sudo('chown www-data:www-data {{PROJECT_ID}}/local_settings.py') with prefix('source env/bin/activate'): sudo('python manage.py syncdb', user='******') print('Configure wsgi bridge file') config_wsgi_file() sudo('mkdir apache', user='******') put('apache_wsgi.wsgi', 'apache/django.wsgi', use_sudo=True) sudo('chown www-data:www-data apache/django.wsgi') sudo('/etc/init.d/apache2 reload')
def django(path_=path('web')): return nested( cd(path_), prefix('export DJANGO_SETTINGS_MODULE=goma.settings.' + env.environment), prefix('source ' + path('secret', 'env')), prefix('source ' + path('venv', 'goma', 'bin', 'activate')), )
def bootstrap(cloud_config_file_name): """Edit the test client props file (under resources) according to your client machine, prepare your cloud config file, put it under resources and pass it as cloud_config_file_name""" run('sudo apt-get update') run('sudo apt-get -y install python-pip') run('sudo apt-get -y install git') run('sudo pip install virtualenv') run('virtualenv ' + env_name) with prefix('source ' + env_name + '/bin/activate'): run('pip install --process-dependency https://github.com/CloudifySource/cosmo-cli/archive/develop.zip') run('sudo apt-get -y install python-dev') run('pip install https://github.com/CloudifySource/cloudify-openstack/archive/develop.zip') run('mkdir ' + work_dir_name) with prefix('source ../' + env_name + '/bin/activate'): with cd(work_dir_name): run('cfy init openstack') run('mv cloudify-config.yaml cloudify-config.yaml.backup') put('../resources/' + cloud_config_file_name, work_dir_name) with cd(work_dir_name): run('mv ' + cloud_config_file_name + ' cloudify-config.yaml') with prefix('source ../' + env_name + '/bin/activate'): with cd(work_dir_name): run('cfy bootstrap -a -v')
def _update_database(source_folder): with prefix('export WORKON_HOME=$HOME/.virtualenvs'): with prefix('export PROJECT_HOME=$HOME/sites'): with prefix('export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3'): with prefix('source /usr/local/bin/virtualenvwrapper.sh'): with prefix('workon tdd'): run('cd %s && python3 manage.py migrate --noinput' % (source_folder,))
def fix_solr(): """ Fix solr work in progress """ with cd('/var/tmp'): print blue('pulling new code...') sudo('/etc/init.d/jetty stop') sleep(5) # run('rm -rf /opt/deploy/solr/collection1') print blue('copying new code...') # run('mkdir -p /opt/deploy/solr/collection1') # run("cp -r oclapi/solr/collection1/conf /opt/deploy/solr/collection1") with cd("/opt/deploy/ocl_api/ocl"): # there is no need for this, settings.py.eploy is actually wrong? # run("cp settings.py.deploy settings.py") with prefix('source /opt/virtualenvs/ocl_api/bin/activate'): with prefix('export DJANGO_CONFIGURATION="Production"'): with prefix('export DJANGO_SECRET_KEY="blah"'): # this is really slow because it pull down django-norel run('./manage.py build_solr_schema > ' + '/opt/deploy/solr/collection1/conf/schema.xml') sleep(5) sudo('/etc/init.d/jetty start')
def remove(project_name, db_password=""): """ Remove an existing project on your computer. WARNING: This script will not back up your source code before deletion. Usage: remove:<project_name> remove:<project_name>,<db_password> """ # check for the database if not testdb(db_password): return with prefix("source ~/%s" % env.bash_profile): # check to see if the virtual env has been fully removed, not removed because of compiled stuff bash_local("rmvirtualenv %s" % project_name) workon_home = os.getenv('WORKON_HOME') if exists("%s/%s" % (workon_home, project_name)): bash_local("sudo rm -rf %s/%s" % (workon_home, project_name)) # remove the source code directory if exists("%s/%s/.git" % (project_name, project_name)): question = prompt("Do you want to remove the local copy of `%s` (Y/[N])?" % project_name,validate="^[YyNn]?$") if not (question == 'y' or question == 'Y'): return bash_local("rm -rf %s/%s/.git" % (project_name,project_name)) bash_local("rm -r %s" % project_name) elif exists("%s/.git" % project_name): question = prompt("Do you want to remove the local copy of `%s` (Y/[N])?" % project_name,validate="^[YyNn]?$") if not (question == 'y' or question == 'Y'): return bash_local("rm -rf %s/.git" % project_name) bash_local("rm -r %s" % project_name) elif exists("%s" % project_name): question = prompt("Do you want to remove the only copy of `%s` from your computer (Y/[N])?" % project_name,validate="^[YyNn]?$") if not (question == 'y' or question == 'Y'): return bash_local("rm -r %s" % project_name) # don't remove the database but tell the user if env.database == "mysql": with prefix('export PATH="$PATH:/usr/local/mysql/bin/"'): with settings(warn_only=True): if len(db_password): cmd = "mysql -u root --password=%s -e 'use %s'" % (db_password,project_name) else: cmd = "mysql -u root -e 'use %s'" % project_name output = bash_local(cmd) # don't actually remove the database for now if output.succeeded: print yellow("Your database still exists. You should remove it manually by calling\n fab removedb:%s,<db_password>" % project_name) else: print yellow("To remove the project's database:\n fab removedb:%s,<db_password>" % project_name)
def appserver_start(): """ Start the app server. Kill any instances of the appserver first. """ appserver_stop() with prefix('source '+env.homedir+'/.bashrc'): with prefix(env.activate): with prefix('workon %s' % env.venv): with cd('%s/APM/System/dvt/Tools/fortytwo' % env.accurev.accurev_home): sudoenv('gunicorn sandbox.wsgi:application -c %s/gunicorn_%s.conf.py' % (env.confdir, env.venv))
def collectstatic(): """ Collect the static files to the webserver's static directory """ with prefix('source '+env.homedir+'/.bashrc'): with prefix(env.activate): with prefix('workon %s' % env.venv): with cd('%s/APM/System/dvt/Tools/fortytwo/sandbox' % env.accurev.accurev_home): sudoenv('python ./manage.py collectstatic --noinput --clear --verbosity=0')
def inner(*args, **kwargs): if venv_wrap: with prefix('source /usr/local/bin/virtualenvwrapper.sh && workon {0}'.format(project_name)): return func(*args, **kwargs) if path is not None: with prefix('source {0}'.format(activate)): return func(*args, **kwargs) else: return func(*args, **kwargs)
def test_nested_prefix(): """ prefix context managers can be created outside of the with block and nested """ cm1 = prefix('1') cm2 = prefix('2') with cm1: with cm2: eq_(env.command_prefixes, ['1', '2'])
def install(self): for package in self.packages: print(green('Installing %s via pip' % package)) with prepare_venv(): with prefix(self.workon_cmd): if self.additionalcmd: with prefix(self.additionalcmd): run('pip install %s' % package) else: run('pip install %s' % package)
def requirements(): """ :: Update Python dependencies on remote host. """ require('project', provided_by=('staging', 'production')) with prefix("export PROJECT_HOME=%(projserver)s" %env): with prefix("export WORKON_HOME=%(envserver)s" %env): with prefix("source /usr/local/bin/virtualenvwrapper.sh"): run("workon %(project)s; pip install -r %(requirements)s; deactivate" % env)
def load_site_name(): """ Set the global site object value in the web server, used in outbound emails. """ with cd('/opt/deploy/ocl_web'): with prefix('source /opt/virtualenvs/ocl_web/bin/activate'): with prefix('export DJANGO_CONFIGURATION="Production"'): with prefix('export DJANGO_SECRET_KEY="blah"'): print yellow('setting site name...') run('ocl_web/manage.py loaddata ocl_web/config/sites.%s.json' % env.site_spec)
def virtualenv(): """ :: Setup virtualenv on remote host. """ require('project', provided_by=('staging', 'production')) with prefix("export PROJECT_HOME=%(projserver)s" %env): with prefix("export WORKON_HOME=%(envserver)s" %env): with prefix("source /usr/local/bin/virtualenvwrapper.sh"): run("mkproject %(project)s" % env)
def del_app(): """ :: Delete project """ require('project', provided_by=('staging', 'production')) with cd(env.projserver): with prefix("export PROJECT_HOME=%(projserver)s" %env): with prefix("export WORKON_HOME=%(envserver)s" %env): with prefix("source /usr/local/bin/virtualenvwrapper.sh"): run('rm -rf %(project)s; rmvirtualenv %(project)s' %env)
def deploy(): require('deployment_location', used_for=USED_FOR_MSG) if hasattr(env, 'brand_path'): with cd(env.brand_path), prefix('source %(sandbox_activate)s' % env): run('git pull --rebase') with cd(env.project_root), prefix('source %(sandbox_activate)s' % env): run('git pull --rebase') run('pip install -r requirements-dep.txt') run('python manage.py alembic upgrade head') run('supervisorctl -c %(supervisord_conf)s restart all' % env)
def install(self): print(green('Installing %s packages' % self.repo_name)) for package in self.packages: print(green('Installing %s package: %s' % (self.repo_name, package))) with prefix('export PATH=%s/bin:$PATH' % self.anaconda_path): with prefix(self.workon_cmd): with prefix("cd " + self.repo_path): with prefix("cd " + package): run('python setup.py develop') print(green('%s Installation successfull' % self.repo_name))
def deploy(): build_assets() local('git push') with cd(env.directory): run("git stash") run("git pull") with prefix(env.activate): with prefix(env.additional_env): run("pip install -r requirements.txt") run("python manage.py db upgrade") run("touch django_wsgi.py")
def umask(value='002'): return prefix('umask {value}'.format(value=value))
def init(): """Initialize the website""" with prefix(env.workon): run("./biostar.sh init")
def stats(): code_dir = '/home/b402/beta402' with cd(code_dir), prefix('source ve/bin/activate'): run('./manage.py stats')
def light_deploy(): code_dir = '/home/b402/beta402' with cd(code_dir), prefix('source ve/bin/activate'): run('sudo supervisorctl stop b402-gunicorn') run("git pull") run('sudo supervisorctl start b402-gunicorn')
def mac_setup_bdist_mpkg(): with cd(mac_tmp): run("git clone https://github.com/rgommers/bdist_mpkg.git") with cd("bdist_mpkg"): with prefix(mac_prefix): run("python setup.py install --prefix=../usr")
def init_biostar(): with prefix(env.workon): run("./biostar.sh index")
def pull(): """Perform a pull on remote""" with prefix(env.workon): run("git pull")
def _init_virtualenv(): """Creates initial virtualenv""" run('virtualenv -p %(python)s --no-site-packages %(env_path)s' % env) with prefix('source %(env_path)s/bin/activate' % env): run('easy_install pip')
def _update_requirements(): """Updates dependencies defined in the requirements file""" with prefix('source %(env_path)s/bin/activate' % env): run('pip install -U -r %(project_repo_path)s/requirements.pip' % env) run('chmod -R go=u,go-w %(env_path)s' % env)
def syncdb(): """Runs `syncdb` to create the DB schema""" require('environment', provided_by=[ubuntu, fedora]) with cd('%(project_repo_path)s' % env): with prefix('source %(env_path)s/bin/activate' % env): run('python manage.py syncdb')
def install_protkgem(env): """This method installs Ira Cooke's ProtK framework for the galaxy user. By default this will install ProtK from rubygems server, but if env.protk_version is set to <version>@<url> (e.g. 1.1.5@https://bitbucket.org/iracooke/protk-working) the gem will be cloned with hg and installed from source. """ _prep_galaxy(env) default_version = "1.2.0" version_and_revision = env.get("protk_version", default_version) install_from_source = version_and_revision.find("@") > 0 # e.g. protk_version = 1.1.5@https://bitbucket.org/iracooke/protk-working if install_from_source: (version, revision) = version_and_revision.split("@") url = _get_bitbucket_download_url( revision, "https://bitbucket.org/iracooke/protk") else: version = version_and_revision ruby_version = "1.9.3" force_rvm_install = False with prefix("HOME=~%s" % env.galaxy_user): def rvm_exec(env, cmd="", rvm_cmd="use"): prefix = ". $HOME/.rvm/scripts/rvm; rvm %s %s; " % (rvm_cmd, ruby_version) env.safe_sudo("%s %s" % (prefix, cmd), user=env.galaxy_user) if not exists("$HOME/.rvm") or force_rvm_install: env.safe_sudo( "curl -L get.rvm.io | bash -s stable; source ~%s/.rvm/scripts/rvm" % (env.galaxy_user), user=env.galaxy_user) rvm_exec(env, rvm_cmd="install") if not install_from_source: # Typical rubygem install rvm_exec(env, "gem install --no-ri --no-rdoc protk -v %s" % version) else: with cd("~%s" % env.galaxy_user): env.safe_sudo( "rm -rf protk_source; hg clone '%s' protk_source" % url, user=env.galaxy_user) rvm_exec( env, "cd protk_source; gem build protk.gemspec; gem install protk" ) protk_properties = {} ## ProtK can set these up itself, should make that an option. protk_properties["tpp_root"] = os.path.join(env.galaxy_tools_dir, "transproteomic_pipeline", "default") protk_properties[ 'openms_root'] = "/usr" # os.path.join(env.galaxy_tools_dir, "openms", "default", "bin") ### Assumes omssa, blast, and transproteomic_pipeline CBL galaxy installs. protk_properties['omssa_root'] = os.path.join(env.galaxy_tools_dir, "omssa", "default", "bin") protk_properties['blast_root'] = os.path.join(env.galaxy_tools_dir, "blast+", "default") protk_properties['pwiz_root'] = os.path.join( env.galaxy_tools_dir, "transproteomic_pipeline", "default", "bin") # Other properties: log_file, blast_root env.safe_sudo("mkdir -p \"$HOME/.protk\"", user=env.galaxy_user) env.safe_sudo("mkdir -p \"$HOME/.protk/Databases\"", user=env.galaxy_user) _write_to_file(yaml.dump(protk_properties), "/home/%s/.protk/config.yml" % env.galaxy_user, 0755) rvm_exec(env, "protk_setup.rb galaxyenv") install_dir = os.path.join(env.galaxy_tools_dir, "protkgem", version) env.safe_sudo("mkdir -p '%s'" % install_dir) _chown_galaxy(env, install_dir) env.safe_sudo('ln -s -f "$HOME/.protk/galaxy/env.sh" "%s/env.sh"' % install_dir, user=env.galaxy_user) with cd(install_dir): with cd(".."): env.safe_sudo("ln -s -f '%s' default" % version)
def run_python(*args, **kwargs): activate_virtual_env = \ "source {venv}/bin/activate".format( venv=env.py_virtual_env) with prefix(activate_virtual_env): run(*args, **kwargs)
def run_in_ve(command): """Execute the command inside the virtualenv.""" with prefix('. %s' % env.activate_path): env.doit(command)
def migrate(): """Migrate from main""" with prefix(env.workon): run("python manage.py migrate")
def virtualenv(): with cd(env.proj_root): with prefix('source venv/bin/activate'): yield
def index(): """Index the content""" with prefix(env.workon): run("./biostar.sh index")
def install_package(package_name, active_file_path, version): with prefix('source {}'.format(active_file_path)): pip('typeidea', version)
def pyenv_env(version): cmd_dir = os.path.join(env.pyenv_dir, 'versions', 'indico-build-{0}'.format(version), 'bin') with prefix('PATH={0}:$PATH'.format(cmd_dir)): yield
def test(): """Run test""" with prefix(env.workon): run("./biostar.sh test")
def pip(): """Reinstall requirments""" with prefix(env.workon): run("pip install -r conf/requirements/base.txt")
def collect_static(): with prefix('source ' + ACTIVATE_SCRIPT): run(PYTHON_EXECUTABLE + ' manage.py collectstatic --no-input')
def virtualenv(): with cd(env.DJANGO_PATH): activate = "source %s" % env.VIRTUALENV_ACTIVATE with prefix(activate): yield
def freeze_results(*args): with cd(env.project_path): with prefix('workon %s' % env.virtualenv_name): run('python manage.py freeze_results ' + ' '.join(args))
def compile_translations(): with prefix('workon %s' % env.virtualenv_name): with cd(env.project_path): run('cd trojsten && python ../manage.py compilemessages')
def install_requirements(environment): if environment == "local": with cd("/vagrant/"): with prefix("source /home/vagrant/envs/{0}/bin/activate".format(env.project_name)): run("pip install -r requirements.txt")
def migrate(): with prefix('source ' + ACTIVATE_SCRIPT): run(PYTHON_EXECUTABLE + ' manage.py migrate')
def run_command(name, argv): args = " ".join(argv[1:]) with cd("~/working/%s" % (name)): with prefix("source setupenv.sh"): run("%s" % (args))
def virtualenv(): if hasattr(env, 'virtualenv'): with prefix('source {virtualenv}/bin/activate'.format(**env)): yield else: yield
def virtualenv(virt=config.virtualenv_name): with cd(env.path): with prefix("source {}/virt/{}/bin/activate".format(env.path, virt)): yield
def manage(*args): with cd(env.project_path): with prefix('workon %s' % env.virtualenv_name): run('python manage.py ' + ' '.join(args))