• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python api.run函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中refabric.api.run函数的典型用法代码示例。如果您正苦于以下问题:Python run函数的具体用法?Python run怎么用?Python run使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了run函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: install_solr

def install_solr():
    with sudo():
        version = blueprint.get('version')
        version_tuple = tuple(map(int, version.split('.')))

        archive = 'solr-{}.tgz'.format(version)
        if version_tuple < (4, 1, 0):
            archive = 'apache-{}'.format(archive)
        url = 'https://archive.apache.org/dist/lucene/solr/{}/{}'.format(version, archive)

        with cd('/tmp'):
            info('Download {} ({})', 'Solr', version)
            run('wget {}'.format(url))

            info('Extracting archive...')
            with silent():
                run('tar xzf {}'.format(archive))
                solr_version_dir = os.path.splitext(archive)[0]
                solr_version_path = os.path.join('/usr', 'share', solr_version_dir)
                debian.chmod(solr_version_dir, 755, 'solr', 'solr', recursive=True)
                if files.exists(solr_version_path):
                    info('Found same existing version, removing it...')
                    debian.rm(solr_version_path, recursive=True)
                debian.mv(solr_version_dir, '/usr/share/')
                debian.ln(solr_version_path, solr_home)
                debian.rm(archive)
开发者ID:Sportamore,项目名称:blues,代码行数:26,代码来源:solr.py


示例2: dump

def dump(schema=None, ignore_tables=''):
    """
    Dump and download a schema.

    :param schema: Specific shema to dump and download.
    :param ignore_tables: Tables to skip, separated by | (pipe)
    """
    if not schema:
        schemas = blueprint.get('schemas', {}).keys()
        for i, schema in enumerate(schemas, start=1):
            print("{i}. {schema}".format(i=i, schema=schema))
        valid_indices = '[1-{}]+'.format(len(schemas))
        schema_choice = prompt('Select schema to dump:', default='1', validate=valid_indices)
        schema = schemas[int(schema_choice)-1]

    now = datetime.now().strftime('%Y-%m-%d')
    output_file = '/tmp/{}_{}.backup.gz'.format(schema, now)
    filename = os.path.basename(output_file)

    info('Dumping schema {}...', schema)
    extra_args = []
    for table in ignore_tables.split('|'):
        extra_args.append('--ignore-table={}.{}'.format(schema, table))

    dump_cmd = 'mysqldump {} {} | gzip > {}'.format(schema, ' '.join(extra_args), output_file)

    run('sudo su root -c "{}"'.format(dump_cmd))
    info('Downloading dump...')
    local_file = '~/%s' % filename
    fabric.contrib.files.get(output_file, local_file)

    with sudo(), silent():
        debian.rm(output_file)

    info('New smoking hot dump at {}', local_file)
开发者ID:5monkeys,项目名称:blues,代码行数:35,代码来源:percona.py


示例3: update_modules

def update_modules(beat):
    changes = []

    # Get desired state
    desired_modules = set(blueprint.get('{}.modules'.format(beat), []))

    # Get current state
    with silent():
        module_files = run('find /etc/{}/modules.d -iname "*.yml"'.format(beat)).split()
        enabled_modules = {os.path.basename(module).split('.')[0] for module in module_files}

    # Disable extra services
    for extra in enabled_modules - desired_modules:
        info('Disabling {} module: {}', beat, extra)
        changes.append(extra)

        with silent(), sudo():
            run('{} modules disable {}'.format(beat, extra))

    # Enable services
    for missing in desired_modules - enabled_modules:
        info('Enabling {} module: {}', beat, missing)
        changes.append(missing)

        with silent(), sudo():
            run('{} modules enable {}'.format(beat, missing))

    return changes
开发者ID:Sportamore,项目名称:blues,代码行数:28,代码来源:beats.py


示例4: send_deploy_event

def send_deploy_event():

    newrelic_key = blueprint.get('newrelic_key', None)
    app_name = blueprint.get('app_name', None)

    if newrelic_key and app_name:
        url = 'https://api.newrelic.com/deployments.xml'
        headers = {'x-api-key': newrelic_key}
        with cd(python_path()):
            tag = run('git describe --tags')
            commit_hash = run('git rev-parse HEAD')

        deployer = git.get_local_commiter()

        payload = {
                'deployment[app_name]': app_name,
                # 'application_id': '1234567',
                'deployment[description]': tag,
                'deployment[revision]': commit_hash,
                # 'deployment[changelog]': changes,
                'deployment[user]': deployer,
            }

        response = requests.post(url, data=payload, headers=headers)
        info(response.text)
    else:
        info('No key found')

#http://gc-taylor.com/blog/2013/02/11/fabric-task-for-notifying-new-relic-code-deploy/#sthash.5AnhN3An.sfju
开发者ID:zalphi,项目名称:blues,代码行数:29,代码来源:newrelic.py


示例5: install

def install():
    with sudo():
        # Generate a root password and save it in root home
        root_conf_path = '/root/.my.cnf'
        if not fabric.contrib.files.exists(root_conf_path):
            root_pw = generate_password()
            blueprint.upload('root_my.cnf', '/root/.my.cnf', {'password': root_pw})
            debian.chmod('/root/.my.cnf', mode=600)
        else:
            # TODO: use fabric.operations.get instead of cat when up to date with upstream
            with silent():
                output = run('cat {}'.format(root_conf_path))
            fd = StringIO(output)
            config_parser = ConfigParser.RawConfigParser()
            config_parser.readfp(fd)
            root_pw = config_parser.get('client', 'password')

        # Install external PPA
        info('Adding apt key for {}', __name__)
        run("apt-key adv --keyserver keys.gnupg.net --recv-keys 1C4CBDCDCD2EFD2A")

        info('Adding apt repository for {}', __name__)
        debian.add_apt_repository('http://repo.percona.com/apt trusty main')
        debian.apt_get('update')

        # Percona/MySQL base dependencies
        dependencies = (
            'percona-server-server',
            'percona-server-client',
            'libmysqlclient-dev',
            'mysqltuner'
        )

        # Configure debconf to autoset root password on installation prompts
        server_package = dependencies[0]
        debian.debconf_communicate('PURGE', server_package)
        with silent():
            debian.debconf_set_selections(
                '{}/root_password password {}'.format(server_package, root_pw),
                '{}/root_password_again password {}'.format(server_package, root_pw)
            )

        # Install package
        info('Installing {}', __name__)
        debian.apt_get('install', *dependencies)
        debian.debconf_communicate('PURGE', server_package)

        # Auto-answer mysql_secure_installation prompts
        prompts = {
            'Enter current password for root (enter for none): ': root_pw,
            'Change the root password? [Y/n] ': 'n',
            'Remove anonymous users? [Y/n] ': 'Y',
            'Disallow root login remotely? [Y/n] ': 'Y',
            'Remove test database and access to it? [Y/n] ': 'Y',
            'Reload privilege tables now? [Y/n] ': 'Y'

        }
        # Run mysql_secure_installation to remove test-db and remote root login
        with settings(prompts=prompts):
            run('mysql_secure_installation')
开发者ID:5monkeys,项目名称:blues,代码行数:60,代码来源:percona.py


示例6: install

def install():
    with sudo():
        info('Install python dependencies')
        debian.apt_get('install', 'python-dev', 'python-setuptools')
        run('easy_install pip')
        run('touch {}'.format(pip_log_file))
        debian.chmod(pip_log_file, mode=777)
        pip('install', 'setuptools', '--upgrade')
开发者ID:gelbander,项目名称:blues,代码行数:8,代码来源:python.py


示例7: flush

def flush():
    """
    Delete all cached keys
    """
    info('Flushing Memcached...')
    with sudo(), silent():
        run('echo "flush_all" | /bin/netcat -q 2 127.0.0.1 11211')
    info('Down the drain!')
开发者ID:gelbander,项目名称:blues,代码行数:8,代码来源:memcached.py


示例8: pip_sync

def pip_sync(manifest, quiet=False):
    pip('install', 'pip-tools', quiet=quiet)

    options = ""
    if quiet:
        options += ' -q'

    run('pip-sync{} {}'.format(options, manifest), pty=False)
开发者ID:Sportamore,项目名称:blues,代码行数:8,代码来源:python.py


示例9: configure

def configure():
    """
    Configure newrelic server
    """

    with sudo():
        info('Adding license key to config')
        newrelic_key = blueprint.get('newrelic_key', None)
        run('nrsysmond-config --set license_key={}'.format(newrelic_key))
开发者ID:zalphi,项目名称:blues,代码行数:9,代码来源:newrelic.py


示例10: create_server_ssl_cert

def create_server_ssl_cert():
    with sudo():
        info('Generating SSL certificate...')
        debian.mkdir('/etc/pki/tls/certs')
        debian.mkdir('/etc/pki/tls/private')
        with cd('/etc/pki/tls'):
            key = 'private/logstash-forwarder.key'
            crt = 'certs/logstash-forwarder.crt'
            run('openssl req -x509 -batch -nodes -days 3650 -newkey rsa:2048 -keyout {} -out {}'.format(key, crt))
开发者ID:gelbander,项目名称:blues,代码行数:9,代码来源:logstash.py


示例11: ctl

def ctl(command=None):
    """
    Run rabbitmqctl with given command
    :param command: Control command to execute
    """
    if not command:
        abort('No command given, $ fab rabbitmq.ctl:stop_app')

    with sudo():
        run('rabbitmqctl {}'.format(command))
开发者ID:Sportamore,项目名称:blues,代码行数:10,代码来源:rabbitmq.py


示例12: reload

    def reload(self, vassals=None):
        """
        Touch reload specified vassals

        :param vassals: Vassals to reload
        """
        for vassal_ini in vassals or self.list_vassals():
            vassal_ini_path = os.path.join(self.get_config_path(), vassal_ini)
            with sudo(), silent():
                run('touch {}'.format(vassal_ini_path))
开发者ID:lericson,项目名称:blues,代码行数:10,代码来源:uwsgi.py


示例13: create

def create(path):
    options = ''

    if python.requested_version() >= (3,):
        options += ' -p /usr/bin/python3'

    if not files.exists(path):
        info('Creating virtualenv: {}', path)
        run('virtualenv{options} {}'.format(path, options=options))
    else:
        info('Virtualenv already exists: {}', path)
开发者ID:Sportamore,项目名称:blues,代码行数:11,代码来源:virtualenv.py


示例14: top

def top(vassal_name=None):
    """
    Launch uwsgitop for vassal stats socket

    :param vassal_name: The vassal to show stats for (Default: project setting)
    """
    # TODO: fix missing output
    with sudo(), hide_prefix():
        vassal = vassal_name or blueprint.get('project')
        stats_path = os.path.join(tmpfs_path, '{}-stats.sock'.format(vassal))
        run('uwsgitop {}'.format(stats_path))
开发者ID:lericson,项目名称:blues,代码行数:11,代码来源:uwsgi.py


示例15: fifo

def fifo(vassal_name, command):
    """
    Issue FIFO commands to a vassal.

    :param vassal_name: The vassal to command
    :param command: The FIFO command to issue

    See: http://uwsgi-docs.readthedocs.org/en/latest/MasterFIFO.html
    """
    fifo_file = '/run/uwsgi/fifo-{}'.format(vassal_name)
    with sudo(), silent():
        run('echo {} > {}'.format(command, fifo_file))
开发者ID:lericson,项目名称:blues,代码行数:12,代码来源:uwsgi.py


示例16: reload

def reload(vassal_path=None):
    """
    Reload uwsgi or reload specific vassal @ path, via touch.

    :param vassal_path: The absolute path to vassal ini to reload. If not given, the uwsgi service will reload
    """
    if not vassal_path:
        debian.service('uwsgi', 'reload', check_status=False)
    else:
        vassal_name = os.path.splitext(os.path.basename(vassal_path))[0]
        with sudo():
            info('Reloading {} uWSGI vassal', vassal_name)
            run('touch {}'.format(vassal_path))
开发者ID:Sportamore,项目名称:blues,代码行数:13,代码来源:uwsgi.py


示例17: install

def install():
    with sudo():
        info('Downloading kibana')
        version = blueprint.get('version', '3.1.2')
        tar_file = 'kibana-{}.tar.gz'.format(version)
        run('wget -P /tmp/ https://download.elasticsearch.org/kibana/kibana/{f}'.format(f=tar_file))

        # Extract and soft link kibana in web root
        web_root = '/srv/www/'
        debian.mkdir(web_root, mode=1775, owner='www-data', group='www-data')
        run('tar xzf /tmp/{f} -C {web_root}'.format(f=tar_file, web_root=web_root))
        src_root = os.path.join(web_root, 'kibana-{version}'.format(version=version))
        debian.chown(src_root, owner='www-data', group='www-data', recursive=True)
        debian.ln(src_root, '/srv/www/kibana')
开发者ID:5monkeys,项目名称:blues,代码行数:14,代码来源:kibana.py


示例18: install_testing

def install_testing():
    package_name = 'rabbitmq-server'
    debian.debconf_set_selections('%s rabbitmq-server/upgrade_previous note' % package_name)

    with sudo():
        info('Adding apt key for {}', package_name)
        run("apt-key adv --keyserver pgp.mit.edu --recv-keys 0x056E8E56")

        info('Adding apt repository for {}', package_name)
        debian.add_apt_repository('http://www.rabbitmq.com/debian/ testing main')
        debian.apt_get_update()

        info('Installing {}', package_name)
        debian.apt_get('install', package_name)
开发者ID:Sportamore,项目名称:blues,代码行数:14,代码来源:rabbitmq.py


示例19: install

def install():
    with sudo():

        info('Downloading wowza')
        version = blueprint.get('wowza_version', '4.1.2')
        binary = 'WowzaStreamingEngine-{}.deb.bin'.format(version)
        version_path = version.replace('.', '-')
        url = 'http://www.wowza.com/downloads/WowzaStreamingEngine-{}/{}'.format(version_path,
                                                                                 binary)
        run('wget -P /tmp/ {url}'.format(url=url))

        debian.chmod('/tmp/{}'.format(binary), '+x')
        info('Installing wowza')
        run('/tmp/{}'.format(binary))
开发者ID:5monkeys,项目名称:blues,代码行数:14,代码来源:wowza.py


示例20: create_server_ssl_cert

def create_server_ssl_cert():
    with sudo():
        info("Generating SSL certificate...")
        debian.mkdir("/etc/pki/tls/certs")
        debian.mkdir("/etc/pki/tls/private")
        with cd("/etc/pki/tls"):
            hostname = debian.hostname()
            key = "private/logstash-forwarder.key"
            crt = "certs/logstash-forwarder.crt"
            run(
                "openssl req -x509 -batch -nodes -days 3650 -newkey rsa:2048 "
                "-keyout {} "
                "-out {} "
                '-subj "/CN={}"'.format(key, crt, hostname)
            )
开发者ID:zalphi,项目名称:blues,代码行数:15,代码来源:logstash.py



注:本文中的refabric.api.run函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python context_managers.silent函数代码示例发布时间:2022-05-26
下一篇:
Python api.info函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap