本文整理汇总了Python中fabric.api.get方法的典型用法代码示例。如果您正苦于以下问题:Python api.get方法的具体用法?Python api.get怎么用?Python api.get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类fabric.api
的用法示例。
在下文中一共展示了api.get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setup_supervisor
# 需要导入模块: from fabric import api [as 别名]
# 或者: from fabric.api import get [as 别名]
def setup_supervisor():
# We use supervisord to keep Crestify running in the background
# Recover from crashes, and to start automatically on bootup
# Also, using more than 1 gunicorn worker resulted in socket not being released, so only 1 worker will be used
sudo('apt-get -y install supervisor')
sudo('mkdir /var/log/crestify/')
sudo(
'cd /home/crestify/crestify && ../crestifyenv/bin/honcho export -s /bin/sh -a crestify supervisord /etc/supervisor/conf.d')
fd = StringIO()
get('/etc/supervisor/conf.d/crestify.conf', fd)
content = fd.getvalue().splitlines()
for n, i in enumerate(content):
if i.startswith("environment="):
content[n] = i + ",PATH=/home/crestify/crestifyenv/bin:%(ENV_PATH)s"
if i.startswith("user="):
content[n] = "user=crestify"
if i.startswith("stopsignal="):
content[n] = "stopsignal=TERM" # Both Gunicorn and Celery use SIGTERM for graceful shutdown
content = StringIO("\n".join(content))
put(content, "/etc/supervisor/conf.d/crestify.conf", use_sudo=True)
sudo('supervisorctl reread')
sudo('supervisorctl update')
示例2: experiment1collect
# 需要导入模块: from fabric import api [as 别名]
# 或者: from fabric.api import get [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")
示例3: is_enabled
# 需要导入模块: from fabric import api [as 别名]
# 或者: from fabric.api import get [as 别名]
def is_enabled(revision_config=None):
is_compatible = True
is_enabled = common_module.config.get('flamegraph', False)
if revision_config:
if revision_config.get('product', 'cassandra') == 'dse':
logger.info('Flamegraph is not compatible with DSE yet')
is_compatible = False
jvm = revision_config.get('java_home', '')
try:
jvm = os.path.basename(jvm)
jvm = jvm[jvm.index('1'):]
if v.LooseVersion(jvm) < v.LooseVersion('1.8.0_60'):
logger.info('Flamegraph is not compatible with java <1.8.0_60')
is_compatible = False
except ValueError:
pass
return is_enabled and is_compatible
示例4: install_java
# 需要导入模块: from fabric import api [as 别名]
# 或者: from fabric.api import get [as 别名]
def install_java(packages=None):
# Try to get the os distribution:
dist = fab.run('lsb_release -is', quiet=True)
if dist.return_code != 0:
dist = fab.run('cat /etc/redhat-release', quiet=True)
if dist.startswith('CentOS'):
if not packages:
packages = ['java-1.7.0-openjdk.x86_64',
'java-1.7.0-openjdk-devel.x86_64']
cmd = 'yum -y install {package}'
elif dist.startswith('Ubuntu'):
if not packages:
packages = ['openjdk-7-jdk']
fab.run('apt-get update')
cmd = 'apt-get -y install {package}'
else:
raise RuntimeError('Unknown distribution: %s' % dist)
for package in packages:
fab.run(cmd.format(package=package))
示例5: _setup_gradle_authentication
# 需要导入模块: from fabric import api [as 别名]
# 或者: from fabric.api import get [as 别名]
def _setup_gradle_authentication(config):
dse_source_build_artifactory_username = config.get('dse_source_build_artifactory_username')
dse_source_build_artifactory_password = config.get('dse_source_build_artifactory_password')
dse_source_build_artifactory_url = config.get('dse_source_build_artifactory_url')
gradle_settings = """
allprojects {{
repositories {{
maven {{
url = "\\"{url}\\""
credentials {{
username '{username}'
password '{password}'
}}
}}
}}
}}
""".format(username=dse_source_build_artifactory_username, password=dse_source_build_artifactory_password,
url=dse_source_build_artifactory_url)
fab.local('rm -rf ~/.gradle')
fab.local('mkdir -p ~/.gradle/init.d')
fab.local('echo "{gradle_settings}" > ~/.gradle/init.d/nexus.gradle'.format(gradle_settings=gradle_settings))
示例6: _configure_spark_env
# 需要导入模块: from fabric import api [as 别名]
# 或者: from fabric.api import get [as 别名]
def _configure_spark_env(config):
# Place spark environment file on hosts:
spark_env = config.get('spark_env', '')
if isinstance(spark_env, list) or isinstance(spark_env, tuple):
spark_env = "\n".join(spark_env)
spark_env += "\n"
spark_env_script = "spark-{name}.sh".format(name=uuid.uuid1())
spark_env_file = StringIO(spark_env)
fab.run('mkdir -p ~/fab/scripts')
fab.put(spark_env_file, '~/fab/scripts/{spark_env_script}'.format(spark_env_script=spark_env_script))
fab.puts('spark-env is: {}'.format(spark_env))
if len(spark_env_script) > 0:
spark_env_path = os.path.join(get_dse_path(), 'resources', 'spark', 'conf', 'spark-env.sh')
fab.run('cat ~/fab/scripts/{spark_env_script} >> {spark_env_path}'.format(spark_env_script=spark_env_script,
spark_env_path=spark_env_path))
示例7: update_config
# 需要导入模块: from fabric import api [as 别名]
# 或者: from fabric.api import get [as 别名]
def update_config(self, content, path):
old_file = six.BytesIO()
if files.exists(path, use_sudo=self.sudo):
fab.get(remote_path=path, local_path=old_file, use_sudo=self.sudo)
old_content = old_file.getvalue()
need_update = content != old_content
if need_update:
fabricio.move_file(
path_from=path,
path_to=path + '.backup',
sudo=self.sudo,
ignore_errors=True,
)
fab.put(six.BytesIO(content), path, use_sudo=self.sudo, mode='0644')
fabricio.log('{path} updated'.format(path=path))
else:
fabricio.log('{path} not changed'.format(path=path))
return need_update
示例8: install_python_reqs
# 需要导入模块: from fabric import api [as 别名]
# 或者: from fabric.api import get [as 别名]
def install_python_reqs():
sudo('apt-get update --fix-missing')
# We need the Python headers (python-dev) for compiling some libraries
sudo('apt-get -y install python-virtualenv python-dev python-pip')
# Readability dependencies for lxml
sudo('apt-get -y install libxslt1-dev libxml2-dev libz-dev')
示例9: install_rabbitmq
# 需要导入模块: from fabric import api [as 别名]
# 或者: from fabric.api import get [as 别名]
def install_rabbitmq():
# RabbitMQ is our message queue
sudo('echo "deb http://www.rabbitmq.com/debian/ testing main" >> /etc/apt/sources.list')
sudo('apt-get -y install wget sudo')
sudo('apt-get -y install ca-certificates')
sudo('wget --quiet -O - https://www.rabbitmq.com/rabbitmq-release-signing-key.asc | sudo apt-key add -')
sudo('apt-get update --fix-missing')
sudo('apt-get -y install rabbitmq-server')
示例10: install_postgres
# 需要导入模块: from fabric import api [as 别名]
# 或者: from fabric.api import get [as 别名]
def install_postgres():
sudo('echo "deb http://apt.postgresql.org/pub/repos/apt/ trusty-pgdg main" >> /etc/apt/sources.list.d/pgdg.list')
sudo('wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | \
sudo apt-key add -')
sudo('apt-get update')
sudo('apt-get -y install postgresql-9.4 postgresql-server-dev-9.4 postgresql-contrib-9.4')
示例11: install_redis
# 需要导入模块: from fabric import api [as 别名]
# 或者: from fabric.api import get [as 别名]
def install_redis():
# Used for temporarily saving incoming tab saves
sudo('apt-get -y install redis-server')
示例12: install_phantomjs
# 需要导入模块: from fabric import api [as 别名]
# 或者: from fabric.api import get [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')
示例13: config_environment
# 需要导入模块: from fabric import api [as 别名]
# 或者: from fabric.api import get [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')
示例14: passcache
# 需要导入模块: from fabric import api [as 别名]
# 或者: from fabric.api import get [as 别名]
def passcache():
# Delete old folder and make a new one
sudo( 'rm -rf /home/ubuntu/projects/rscoin')
sudo("apt-get install -y sysbench")
with cd('/home/ubuntu/projects'):
sudo('pip install petlib --upgrade')
run("git clone https://github.com/gdanezis/rscoin.git")
示例15: get_flamegraph_directory
# 需要导入模块: from fabric import api [as 别名]
# 或者: from fabric.api import get [as 别名]
def get_flamegraph_directory():
return common_module.config.get('flamegraph_directory', '/tmp/flamegraph')