本文整理匯總了Python中fabric.api.run方法的典型用法代碼示例。如果您正苦於以下問題:Python api.run方法的具體用法?Python api.run怎麽用?Python api.run使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類fabric.api
的用法示例。
在下文中一共展示了api.run方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: engine_start
# 需要導入模塊: from fabric import api [as 別名]
# 或者: from fabric.api import run [as 別名]
def engine_start(http_host, http_port):
package = env.package
command = (
"workon {package}_env &&"
" (marvin engine-httpserver"
" -h {http_host}"
" -p {http_port}"
" -e {executor}"
" 1> /var/log/marvin/engines/{package}.out"
" 2> /var/log/marvin/engines/{package}.err"
" & echo $! > /var/run/marvin/engines/{package}.pid)"
).format(
package=package,
http_host=http_host,
http_port=http_port,
executor=env.marvin_engine_executor_path
)
with cd("/opt/marvin/engines/{package}/current".format(package=package)):
run(command, pty=False)
示例2: install
# 需要導入模塊: from fabric import api [as 別名]
# 或者: from fabric.api import run [as 別名]
def install(name):
with act_virtualenv(name):
run("pip install uwsgi")
run("pip install flask==0.12.4")
run("pip install flask-bootstrap")
run("pip install flask-script")
run("pip install flask-moment")
run("pip install pyminizip==0.2.1")
run("pip install flask_wtf")
run("pip install flask_sqlalchemy")
run("pip install sqlalchemy-migrate")
run("pip install flask-mail")
run("pip install flask-login")
run("pip install flask-ldap-login")
run("pip install python-ldap")
run("pip install python-daemon")
示例3: keys
# 需要導入模塊: from fabric import api [as 別名]
# 或者: from fabric.api import run [as 別名]
def keys():
if "rsdir" not in env:
secret = file("secret.key").read()
public = rscoin.Key(secret, public=False)
pid = b64encode(public.id())
env["rsdir"] = {"special": pid, "directory": []}
[_, host] = env.host_string.split("@")
with cd('/home/ubuntu/projects/rscoin'):
run('touch secret.key')
run('rm secret.key')
result = run('python derivekey.py --store')
[_, key] = result.strip().split()
kid = b64encode(rscoin.Key(b64decode(key)).id())
env["rsdir"]["directory"] += [ [kid, host, 8080] ]
from json import dumps
file("directory.conf", "w").write(dumps(env["rsdir"]))
示例4: experiment1collect
# 需要導入模塊: from fabric import api [as 別名]
# 或者: from fabric.api import run [as 別名]
def experiment1collect():
# run("ls experiment1/*")
with cd('/home/ubuntu/projects/rscoin/%s' % env.expname):
get('issue-times.txt', '%s/%s-issue-times.txt' % (env.expname, env.host))
with lcd(env.expname):
local("cat %s-issue-times.txt >> issue-times.txt" % env.host)
with cd('/home/ubuntu/projects/rscoin/%s' % env.expname):
get('r1-times.txt', '%s/%s-r1-times.txt' % (env.expname, env.host))
with lcd(env.expname):
local("cat %s-r1-times.txt >> r1-times.txt" % env.host)
with cd('/home/ubuntu/projects/rscoin/%s' % env.expname):
get('r2-times.txt', '%s/%s-r2-times.txt' % (env.expname, env.host))
with lcd(env.expname):
local("cat %s-r2-times.txt >> r2-times.txt" % env.host)
# local("python exp1plot.py experiment1")
示例5: _clone_code_from_local_path
# 需要導入模塊: from fabric import api [as 別名]
# 或者: from fabric.api import run [as 別名]
def _clone_code_from_local_path(from_path, to_path, run_as_sudo=True):
cmd_fn = sudo if run_as_sudo else run
git_local_submodule_config = [
'git config {} {}'.format(submodule_config.key, submodule_config.value)
for submodule_config in _get_local_submodule_urls(from_path)
]
git_remote_submodule_config = [
'git config {} {}'.format(submodule_config.key, submodule_config.value)
for submodule_config in _get_remote_submodule_urls(from_path)
]
with cd(from_path):
cmd_fn('git clone {}/.git {}'.format(
from_path,
to_path
))
with cd(to_path):
cmd_fn('git config receive.denyCurrentBranch updateInstead')
cmd_fn(' && '.join(git_local_submodule_config))
cmd_fn('git submodule update --init --recursive')
cmd_fn(' && '.join(git_remote_submodule_config))
示例6: bash
# 需要導入模塊: from fabric import api [as 別名]
# 或者: from fabric.api import run [as 別名]
def bash(script, nodes=None, user=None):
"""Run a bash script on a set of nodes
script - A bash script written as a string or list.
nodes - The set of nodes to run the command on. If None, all nodes of
the cluster will be used.
user - The user to run the command as. If None, the default user specified
in the cluster configuration
"""
if type(script) in (list, tuple):
script = "\n".join(script)
if nodes is None:
nodes = common.fab.env.hosts
if user is None:
user = common.fab.env.user
with common.fab.settings(user=user, hosts=nodes):
return execute(common.bash, script)
示例7: get_spark_cassandra_stress_command
# 需要導入模塊: from fabric import api [as 別名]
# 或者: from fabric.api import run [as 別名]
def get_spark_cassandra_stress_command(script, node, master, stress_node=None):
dse_bin = os.path.join(dse.get_dse_path(), 'bin')
# see conversation on https://github.com/datastax/cstar_perf/pull/226 for why we pass SPARK_MASTER
# tl;dr on DSE 4.7.x the dse script tries to call dsetool on the spark-cassandra-stress node
# if SPARK_MASTER env var is not set and this results in a connection error trace as
# we do not start DSE on the spark-cassandra-stress node
spark_cassandra_stress_cmd_prefix = 'cd {spark_cass_stress_path}; ' \
'PATH=$PATH:{dse_bin} ' \
'JAVA_HOME={JAVA_HOME} ' \
'DSE_HOME={dse_home} ' \
'SPARK_MASTER={master} '.format(spark_cass_stress_path=get_spark_cassandra_stress_path(stress_node=stress_node),
dse_bin=dse_bin,
JAVA_HOME=JAVA_HOME,
dse_home=dse.get_dse_path(),
master=master)
spark_cass_connection_host_arg = ' --conf spark.cassandra.connection.host={node}'.format(node=node)
spark_cassandra_run_cmd = './run.sh dse {script} {master} {connection_host}'.format(script=script,
master=master,
connection_host=spark_cass_connection_host_arg)
cmd = spark_cassandra_stress_cmd_prefix + ' ' + spark_cassandra_run_cmd
return cmd
示例8: make_doc
# 需要導入模塊: from fabric import api [as 別名]
# 或者: from fabric.api import run [as 別名]
def make_doc():
with lcd('../docs'):
local('make html')
local('cp -rf _build/html/* /var/www/mendelmd_static/docs/')
#def backup():
# run(' mysqldump -u root -p mendelmd14 | gzip > db_backup/mendelmd151012.sql.gz ')
示例9: create_sample_data
# 需要導入模塊: from fabric import api [as 別名]
# 或者: from fabric.api import run [as 別名]
def create_sample_data():
#backup all users
# with cd('/projects/www/mendelmd14'):
#
# run('mysqldump -u root -p mendelmd14 auth_user account_account profiles_profile | gzip > db_backup/users.sql.gz')
# #get sample from individuals
# run('mysqldump -u root -p --where="individual_id < 16" mendelmd14 individuals_variant | gzip > db_backup/individual_variants_sample.sql.gz')
# run('mysqldump -u root -p --where="id < 16" mendelmd14 individuals_individual | gzip > db_backup/individuals_sample.sql.gz')
get('/projects/www/mendelmd14/db_backup/users.sql.gz', '/home/raony/sites/mendelmd14/db_backup/')
get('/projects/www/mendelmd14/db_backup/individual_variants_sample.sql.gz', '/home/raony/sites/mendelmd14/db_backup/')
get('/projects/www/mendelmd14/db_backup/individuals_sample.sql.gz', '/home/raony/sites/mendelmd14/db_backup/')
示例10: loaddata
# 需要導入模塊: from fabric import api [as 別名]
# 或者: from fabric.api import run [as 別名]
def loaddata():
#Load user and sample from individuals
local('gunzip < db_backup/users.sql.gz | mysql -u root -p mendelmd')
local('gunzip < db_backup/individual_variants_sample.sql.gz | mysql -u root -p mendelmd ')
local('gunzip < db_backup/individuals_sample.sql.gz | mysql -u root -p mendelmd ')
# run(' gunzip < db_backup/mendelmd151012.sql.gz | mysql -u root -p mendelmd14 ')
# local("""python manage.py loaddata db_backup/all_without_individuals.json.gz""")
示例11: deploy
# 需要導入模塊: from fabric import api [as 別名]
# 或者: from fabric.api import run [as 別名]
def deploy(message="changes (fabric)"):
local('git add .; git commit -m "%s";git push' % (message))
with cd('/projects/www/mendelmd'):
# run('git reset --hard HEAD')
run('git pull')
# run('source virtualenvwrapper.sh && workon genome_research && python manage.py syncdb --noinput')
run('sudo /etc/init.d/apache2 restart')
示例12: up
# 需要導入模塊: from fabric import api [as 別名]
# 或者: from fabric.api import run [as 別名]
def up(mode='-t'):
down()
local('docker run %s --name %s ' % (mode, CONTAINER_BASE) +
' -v news_data:/root/data -v news_test:/root/_posts ' +
IMAGE_BASE)
示例13: install_phantomjs
# 需要導入模塊: from fabric import api [as 別名]
# 或者: from fabric.api import run [as 別名]
def install_phantomjs():
# The PhantomJS headless browser
sudo('apt-get -y install fontconfig')
run('wget https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-2.1.1-linux-x86_64.tar.bz2')
run('tar xjf phantomjs-2.1.1-linux-x86_64.tar.bz2')
sudo('mv phantomjs-2.1.1-linux-x86_64/bin/phantomjs /usr/local/bin/phantomjs')
示例14: run_migrations
# 需要導入模塊: from fabric import api [as 別名]
# 或者: from fabric.api import run [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
示例15: _git_update
# 需要導入模塊: from fabric import api [as 別名]
# 或者: from fabric.api import run [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')