当前位置: 首页>>代码示例>>Python>>正文


Python env.host方法代码示例

本文整理汇总了Python中fabric.api.env.host方法的典型用法代码示例。如果您正苦于以下问题:Python env.host方法的具体用法?Python env.host怎么用?Python env.host使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在fabric.api.env的用法示例。


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

示例1: keys

# 需要导入模块: from fabric.api import env [as 别名]
# 或者: from fabric.api.env import host [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"])) 
开发者ID:gdanezis,项目名称:rscoin,代码行数:23,代码来源:fabfile.py

示例2: experiment1collect

# 需要导入模块: from fabric.api import env [as 别名]
# 或者: from fabric.api.env import host [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") 
开发者ID:gdanezis,项目名称:rscoin,代码行数:23,代码来源:fabfile.py

示例3: deployMultiClient

# 需要导入模块: from fabric.api import env [as 别名]
# 或者: from fabric.api.env import host [as 别名]
def deployMultiClient(num):
    local('rm -f testMap.csv')
    for i in range(int(num)):
        dirc = 'client%s' % i
        with cd(dirc):
            with cd('loopix'):
                run("git pull")
                run("git checkout %s" % BRANCH)
            with cd('loopix/loopix'):
                N = hexlify(os.urandom(8))
                providers = getProvidersNames()
                prvName = random.choice(providers)
                port = int(9999 - i)
                print "CLIENT: Client%s" % N
                run("python setup_client.py %d %s Client%s %s" % (port, str(env.host), N, prvName))
                get('publicClient.bin', 'publicClient-%d-%s.bin'%(port, env.host))
                with open('testMap.csv', 'a') as outfile:
                    csvW = csv.writer(outfile)
                    csvW.writerow(['Client%s'%N, dirc]) 
开发者ID:UCL-InfoSec,项目名称:loopix,代码行数:21,代码来源:fabfile.py

示例4: deploy

# 需要导入模块: from fabric.api import env [as 别名]
# 或者: from fabric.api.env import host [as 别名]
def deploy(clients):
    execute(deployMulti, clients)
#
# @roles("providers")
# def checkHost():
#     print env.host
#
#
# @runs_once
# def takeNamesDb():
#     database = "example.db"
#     db = sqlite3.connect(database)
#     c = db.cursor()
#     c.execute("SELECT * FROM Providers")
#     providers = c.fetchall()
#     for p in providers:
#         print p
#
# 
开发者ID:UCL-InfoSec,项目名称:loopix,代码行数:21,代码来源:fabfile.py

示例5: is_port_in_use

# 需要导入模块: from fabric.api import env [as 别名]
# 或者: from fabric.api.env import host [as 别名]
def is_port_in_use(host):
    _LOGGER.info("Checking if port used by Prestoserver is already in use..")
    try:
        portnum = lookup_port(host)
    except Exception:
        _LOGGER.info("Cannot find port from config.properties. "
                     "Skipping check for port already being used")
        return 0
    with settings(hide('warnings', 'stdout'), warn_only=True):
        output = run('netstat -ln |grep -E "\<%s\>" |grep LISTEN' % str(portnum))
    if output:
        _LOGGER.info("Presto server port already in use. Skipping "
                     "server start...")
        error('Server failed to start on %s. Port %s already in use'
              % (env.host, str(portnum)))
    return output 
开发者ID:prestodb,项目名称:presto-admin,代码行数:18,代码来源:server.py

示例6: get_ext_ip_of_node

# 需要导入模块: from fabric.api import env [as 别名]
# 或者: from fabric.api.env import host [as 别名]
def get_ext_ip_of_node(client):
    node_properties_file = os.path.join(constants.REMOTE_CONF_DIR,
                                        'node.properties')
    with settings(hide('stdout')):
        node_uuid = sudo('sed -n s/^node.id=//p ' + node_properties_file)
    external_ip_row = execute_external_ip_sql(client, node_uuid)
    external_ip = ''
    if len(external_ip_row) > 1:
        warn_more_than_one_ip = 'More than one external ip found for ' + env.host + \
                                '. There could be multiple nodes associated with the same node.id'
        _LOGGER.debug(warn_more_than_one_ip)
        warn(warn_more_than_one_ip)
        return external_ip
    for row in external_ip_row:
        if row:
            external_ip = row[0]
    if not external_ip:
        _LOGGER.debug('Cannot get external IP for ' + env.host)
        external_ip = 'Unknown'
    return external_ip 
开发者ID:prestodb,项目名称:presto-admin,代码行数:22,代码来源:server.py

示例7: announce_deploy

# 需要导入模块: from fabric.api import env [as 别名]
# 或者: from fabric.api.env import host [as 别名]
def announce_deploy(project, channel=None, username=None, icon_emoji=None, web_hook_url=None):
    """
    announce_deploy - a decorator to announces a new deploy of the specificed project start,
    who started it and when. Also sends a message when the deploy ends and how long it took.
    """

    def real_announce_deploy(func):
        @functools.wraps(func)
        def inner_decorator(*args, **kwargs):
            deploy_start = datetime.datetime.utcnow()
            # Get user's identity from a environment variable SLACK_IDENTITY, otherwise just get the default username
            deployment_handler = os.environ.get('SLACK_IDENTITY', getpass.getuser())
            # Send a message on deployment start...
            if env.host:
                start_message = "%s deployment started by %s on %s" % (project, deployment_handler, env.host)
            else:
                start_message = "%s deployment started by %s" % (project, deployment_handler)
            send_slack_message(start_message, channel=channel, username=username, icon_emoji=icon_emoji, web_hook_url=web_hook_url)
            return_value = func(*args, **kwargs)
            # ... and upon finish
            if env.host:
                end_message = "%s deployment ended by %s on %s. Took: %s" % (project, deployment_handler, env.host, str(datetime.datetime.utcnow() - deploy_start))
            else:
                end_message = "%s deployment ended by %s. Took: %s" % (project, deployment_handler, str(datetime.datetime.utcnow() - deploy_start))
            send_slack_message(end_message, channel=channel, username=username, icon_emoji=icon_emoji)
            return return_value
        return inner_decorator
    return real_announce_deploy 
开发者ID:erans,项目名称:fabric-slack-tools,代码行数:30,代码来源:__init__.py

示例8: elasticsearch

# 需要导入模块: from fabric.api import env [as 别名]
# 或者: from fabric.api.env import host [as 别名]
def elasticsearch():
    global ELASTICSEARCH_CHECKED
    if not ELASTICSEARCH_CHECKED:
        run("curl -XGET 'http://%s:9200/_cluster/health?pretty=true'" % env.host)
        ELASTICSEARCH_CHECKED = True
    run('service elasticsearch status') 
开发者ID:dimagi,项目名称:commcare-cloud,代码行数:8,代码来源:check_servers.py

示例9: sync_offline_from_control

# 需要导入模块: from fabric.api import env [as 别名]
# 或者: from fabric.api.env import host [as 别名]
def sync_offline_from_control():
    for host in _hosts_in_roles(ROLES_ALL_SRC, exclude_roles=ROLES_DEPLOY):
        run("rsync -rvz --exclude 'commcare-hq/*' {} {}".format(
            env.offline_code_dir,
            '{}@{}:{}'.format(env.user, host, env.offline_releases)
        )) 
开发者ID:dimagi,项目名称:commcare-cloud,代码行数:8,代码来源:release.py

示例10: update_code_offline

# 需要导入模块: from fabric.api import env [as 别名]
# 或者: from fabric.api.env import host [as 别名]
def update_code_offline():
    '''
    An online release usually clones from the previous release then tops
    off the new updates from the remote github. Since we can't access the remote
    Github, we do this:

        1. Clone the current release to the user's home directory
        2. Update that repo with any changes from the user's local copy of HQ (in offline-staging)
        3. Clone the user's home repo to the release that is being deployed (code_root)
    '''
    clone_current_release_to_home_directory()

    git_remote_url = 'ssh://{user}@{host}{code_dir}'.format(
        user=env.user,
        host=env.host,
        code_dir=os.path.join(env.offline_code_dir, 'commcare-hq')
    )

    local('cd {}/commcare-hq && git push {}/.git {}'.format(
        OFFLINE_STAGING_DIR,
        git_remote_url,
        env.deploy_metadata.deploy_ref,
    ))

    # Iterate through each submodule and push master
    local("cd {}/commcare-hq && git submodule foreach 'git push {}/$path/.git --all'".format(
        OFFLINE_STAGING_DIR,
        git_remote_url,
    ))

    clone_home_directory_to_release()
    with cd(env.code_root):
        sudo('git checkout `git rev-parse {}`'.format(env.deploy_metadata.deploy_ref))
        sudo('git reset --hard {}'.format(env.deploy_metadata.deploy_ref))
        sudo('git submodule update --init --recursive')
        # remove all untracked files, including submodules
        sudo("git clean -ffd")
        sudo('git remote set-url origin {}'.format(env.code_repo))
        sudo("find . -name '*.pyc' -delete") 
开发者ID:dimagi,项目名称:commcare-cloud,代码行数:41,代码来源:release.py

示例11: _decommission_host

# 需要导入模块: from fabric.api import env [as 别名]
# 或者: from fabric.api.env import host [as 别名]
def _decommission_host(host):
    files.comment(
        '/etc/nginx/sites-available/{}_commcare'.format(env.deploy_env),
        '^[ ]*server[ ]+{}'.format(host),
        use_sudo=True,
    )
    _check_and_reload_nginx() 
开发者ID:dimagi,项目名称:commcare-cloud,代码行数:9,代码来源:supervisor.py

示例12: decommissioned_host

# 需要导入模块: from fabric.api import env [as 别名]
# 或者: from fabric.api.env import host [as 别名]
def decommissioned_host(host):
    more_than_one_webworker = len(env.roledefs['django_app']) > 1

    if more_than_one_webworker:
        execute(_decommission_host, host)

    yield

    if more_than_one_webworker:
        execute(_recommission_host, host) 
开发者ID:dimagi,项目名称:commcare-cloud,代码行数:12,代码来源:supervisor.py

示例13: restart_webworkers

# 需要导入模块: from fabric.api import env [as 别名]
# 或者: from fabric.api.env import host [as 别名]
def restart_webworkers():
    with decommissioned_host(env.host):
        _services_restart() 
开发者ID:dimagi,项目名称:commcare-cloud,代码行数:5,代码来源:supervisor.py

示例14: run_notebook

# 需要导入模块: from fabric.api import env [as 别名]
# 或者: from fabric.api.env import host [as 别名]
def run_notebook(workdir=None, args=None, kwargs=None):
    args = args or []
    kwargs = kwargs or {}
    command = "jupyter notebook --ip {host} --allow-root".format(host=env.host).split() + list(args)
    return run_command(command, workdir=workdir) 
开发者ID:rorodata,项目名称:rorolite,代码行数:7,代码来源:fabfile.py

示例15: run_jupyterlab

# 需要导入模块: from fabric.api import env [as 别名]
# 或者: from fabric.api.env import host [as 别名]
def run_jupyterlab(workdir=None, args=None, kwargs=None):
    args = args or []
    kwargs = kwargs or {}
    command = "jupyter lab --ip {host} --allow-root".format(host=env.host).split() + list(args)
    return run_command(command, workdir=workdir) 
开发者ID:rorodata,项目名称:rorolite,代码行数:7,代码来源:fabfile.py


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