本文整理匯總了Python中fabric.api.prefix方法的典型用法代碼示例。如果您正苦於以下問題:Python api.prefix方法的具體用法?Python api.prefix怎麽用?Python api.prefix使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類fabric.api
的用法示例。
在下文中一共展示了api.prefix方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: log_deploy
# 需要導入模塊: from fabric import api [as 別名]
# 或者: from fabric.api import prefix [as 別名]
def log_deploy():
current_commit = run("git rev-parse --verify HEAD")
url = "https://github.com/ebmdatalab/openprescribing/compare/%s...%s" % (
env.previous_commit,
current_commit,
)
log_line = json.dumps(
{
"started_at": str(env.started_at),
"ended_at": str(datetime.utcnow()),
"changes_url": url,
}
)
run("echo '%s' >> deploy-log.json" % log_line)
with prefix("source .venv/bin/activate"):
run(
"python deploy/notify_deploy.py {revision} {url} {fab_env}".format(
revision=current_commit, url=url, fab_env=env.environment
)
)
示例2: call_management_command
# 需要導入模塊: from fabric import api [as 別名]
# 或者: from fabric.api import prefix [as 別名]
def call_management_command(command_name, environment, *args, **kwargs):
"""Invokes management command in environment.
Prints output of command.
"""
cmd = "python openprescribing/manage.py {}".format(command_name)
for arg in args:
cmd += " {}".format(shlex.quote(arg))
for k, v in kwargs.items():
cmd += " --{}={}".format(shlex.quote(k), shlex.quote(v))
setup_env_from_environment(environment)
with cd(env.path):
with prefix("source .venv/bin/activate"):
print(run(cmd))
示例3: virtualenv
# 需要導入模塊: from fabric import api [as 別名]
# 或者: from fabric.api import prefix [as 別名]
def virtualenv():
with cd(env.directory):
with prefix(env.activate):
yield
示例4: config_environment
# 需要導入模塊: from fabric import api [as 別名]
# 或者: from fabric.api import prefix [as 別名]
def config_environment():
sudo('apt-get -y install git screen')
sudo('adduser crestify --disabled-password --gecos GECOS')
sudo('locale-gen en_US.UTF-8')
with settings(sudo_user='crestify', shell='/bin/bash -c'):
with cd('/home/crestify'):
sudo('git clone https://github.com/crestify/crestify.git crestify')
sudo('virtualenv crestifyenv')
with prefix('source crestifyenv/bin/activate'):
sudo('pip install -r crestify/requirements.txt')
示例5: run_migrations
# 需要導入模塊: from fabric import api [as 別名]
# 或者: from fabric.api import prefix [as 別名]
def run_migrations():
with settings(sudo_user='crestify', shell='/bin/bash -c'):
with cd('/home/crestify/crestify'):
with prefix('source ../crestifyenv/bin/activate'):
sudo('honcho run python main.py db upgrade') # Run initial migrations
示例6: _git_update
# 需要導入模塊: from fabric import api [as 別名]
# 或者: from fabric.api import prefix [as 別名]
def _git_update():
with settings(sudo_user="crestify", shell='/bin/bash -c'):
with cd('/home/crestify/crestify'):
with prefix('source ../crestifyenv/bin/activate'):
with settings(sudo_user='crestify', shell='/bin/bash -c'):
sudo('git pull')
sudo('pip install -r requirements.txt')
sudo('honcho run python main.py db upgrade')
示例7: kobo_workon
# 需要導入模塊: from fabric import api [as 別名]
# 或者: from fabric.api import prefix [as 別名]
def kobo_workon(_virtualenv_name):
return prefix('kobo_workon %s' % _virtualenv_name)
示例8: deploy
# 需要導入模塊: from fabric import api [as 別名]
# 或者: from fabric.api import prefix [as 別名]
def deploy():
env.host_string = config.HOST_STRING
with cd('/var/www/test'):
with shell_env(MODE='PRODUCTION'):
run('git reset --hard HEAD')
run('git pull')
run('npm install')
run('gulp')
with prefix('source venv/bin/activate'):
run('pip install -r requirements.txt')
run('python manage.py db upgrade')
run('python manage.py build')
run('supervisorctl restart test')
示例9: act_virtualenv
# 需要導入模塊: from fabric import api [as 別名]
# 或者: from fabric.api import prefix [as 別名]
def act_virtualenv(name):
with prefix("source ./"+name+"/bin/activate"):
yield
示例10: updatestrings
# 需要導入模塊: from fabric import api [as 別名]
# 或者: from fabric.api import prefix [as 別名]
def updatestrings(runlocal=True, _inside_env=False):
command = "./manage.py compilemessages"
if not runlocal or runlocal == "False":
if _inside_env:
run(command)
else:
with prefix(f"workon {env.site}"):
run(command)
site_ctl(command="restart")
else:
local(command)
示例11: deploy
# 需要導入模塊: from fabric import api [as 別名]
# 或者: from fabric.api import prefix [as 別名]
def deploy(mode="full", remote="origin"):
require("site", provided_by=[staging, prod])
require("branch", provided_by=[staging, prod])
with prefix(f"workon {env.site}"):
checkout(remote, env.branch, False)
pull(remote, env.branch, False)
if mode == "full":
requirements()
updatestrings(False, _inside_env=True)
updatestatic()
migrate()
if mode != "html":
site_ctl(command="restart")
示例12: deploy
# 需要導入模塊: from fabric import api [as 別名]
# 或者: from fabric.api import prefix [as 別名]
def deploy():
env.host_string = config.HOST_STRING
with cd('/var/www/#{project}'):
with shell_env(MODE='PRODUCTION'):
run('git reset --hard HEAD')
run('git pull')
run('npm install')
run('gulp')
with prefix('source venv/bin/activate'):
run('pip install -r requirements.txt')
run('python manage.py db upgrade')
run('python manage.py build')
run('supervisorctl restart #{project}')
示例13: update
# 需要導入模塊: from fabric import api [as 別名]
# 或者: from fabric.api import prefix [as 別名]
def update():
u"""Function defining all steps required to properly update application."""
# Django app refresh:
with cd('/var/www/volontulo'):
run('git checkout -f {}'.format(env_vars[env.host_string]['git_branch']))
run('git pull')
with contextlib.nested(
prefix('workon volontulo'),
cd('/var/www/volontulo/backend'),
):
run('pip install --upgrade -r requirements/base.txt')
# Django site refresh:
with contextlib.nested(
cd('/var/www/volontulo/backend'),
prefix('workon volontulo')
):
run('python manage.py migrate --traceback')
# Angular assets refresh:
with contextlib.nested(
prefix('nvm use {}'.format(NODE_VERSION)),
cd('/var/www/volontulo/frontend'),
):
run('npm install .')
run('$(npm bin)/ng build --prod --env={}'.format(env.host_string))
run('$(npm bin)/ng build --prod --env={} --app 1 --output-hashing=false'.format(env.host_string))
run('./node_modules/.bin/webpack --config webpack.server.config.js --progress --colors')
run('systemctl restart uwsgi.service')
run('systemctl restart nginx')
run('systemctl restart pm2-www-data.service')
示例14: virtualenv
# 需要導入模塊: from fabric import api [as 別名]
# 或者: from fabric.api import prefix [as 別名]
def virtualenv():
"""
Runs commands within the project's virtualenv.
"""
with cd(env.venv_path):
with prefix("source %s/bin/activate" % env.venv_path):
yield
示例15: install_requirements
# 需要導入模塊: from fabric import api [as 別名]
# 或者: from fabric.api import prefix [as 別名]
def install_requirements():
with prefix('source {}/venv/bin/activate'.format(PROJECT_DIR)):
run('pip install -r {}'.format(
os.path.join(PROJECT_DIR, 'requirements.txt')
))