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


Python api.local方法代码示例

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


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

示例1: experiment1collect

# 需要导入模块: from fabric import api [as 别名]
# 或者: from fabric.api import local [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

示例2: drop_db_connections

# 需要导入模块: from fabric import api [as 别名]
# 或者: from fabric.api import local [as 别名]
def drop_db_connections(database_name):
    """
    looks up the db in local settings by its alias and drops any connections
    """

    drop_connections = """
        SELECT
            pg_terminate_backend(pid)
        FROM
            pg_stat_activity
        WHERE
            datname = '{db}'
        AND pid <> pg_backend_pid()
    """.format(db=database_name)

    psql(drop_connections) 
开发者ID:CalthorpeAnalytics,项目名称:urbanfootprint,代码行数:18,代码来源:methods.py

示例3: _setup_maven_authentication

# 需要导入模块: from fabric import api [as 别名]
# 或者: from fabric.api import local [as 别名]
def _setup_maven_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')

    maven_settings = "<settings><mirrors><mirror><id>artifactory</id><name>DataStax Maven repository</name>" \
                     "<url>{url}</url>" \
                     "<mirrorOf>central,java.net2,xerial,datanucleus,apache,datastax-public-snapshot,datastax-public-release,datastax-deps,datastax-release,datastax-snapshot</mirrorOf>" \
                     "</mirror></mirrors><servers><server><id>artifactory</id><username>{username}</username>" \
                     "<password>{password}</password></server></servers></settings>" \
        .format(username=dse_source_build_artifactory_username, password=dse_source_build_artifactory_password,
                url=dse_source_build_artifactory_url)

    fab.local('rm -rf ~/.m2/settings.xml')
    fab.local('mkdir -p ~/.m2')
    fab.local('echo "{maven_settings}" > ~/.m2/settings.xml'.format(maven_settings=maven_settings)) 
开发者ID:datastax,项目名称:cstar_perf,代码行数:18,代码来源:fab_dse.py

示例4: _setup_gradle_authentication

# 需要导入模块: from fabric import api [as 别名]
# 或者: from fabric.api import local [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)) 
开发者ID:datastax,项目名称:cstar_perf,代码行数:25,代码来源:fab_dse.py

示例5: deployMultiClient

# 需要导入模块: from fabric import api [as 别名]
# 或者: from fabric.api import local [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

示例6: build

# 需要导入模块: from fabric import api [as 别名]
# 或者: from fabric.api import local [as 别名]
def build(name, ask=True, **kwargs):
    """
    Build the malicious mote to its target hardware.

    :param name: experiment name (or absolute path to experiment)
    :param ask: ask confirmation
    :param path: expanded path of the experiment (dynamically filled in through 'command' decorator with 'expand')
    :param kwargs: simulation keyword arguments (see the documentation for more information)
    """
    def is_device_present():
        with settings(hide(*HIDDEN_ALL), warn_only=True):
            return local("if [ -c /dev/ttyUSB0 ]; then echo 'ok'; else echo 'nok'; fi", capture=True) == 'ok'

    console = kwargs.get('console')
    counter, interval = 0.0, 0.5
    while not is_device_present():
        sleep(interval)
        counter += interval
        if counter % 5 == 0:
            logger.warning("Waiting for mote to be detected...")
        elif counter >= 120:
            logger.error("Something failed with the mote ; check that it mounts to /dev/ttyUSB0")
            return
    remake(name, build=True, **kwargs) if console is None else console.do_remake(name, build=True, **kwargs)
    return "Mote built on /dev/ttyUSB0" 
开发者ID:dhondta,项目名称:rpl-attacks,代码行数:27,代码来源:commands.py

示例7: versions

# 需要导入模块: from fabric import api [as 别名]
# 或者: from fabric.api import local [as 别名]
def versions(**kwargs):
    """
    Check versions of Contiki-OS and RPL Attacks Framework.

    :param kwargs: simulation keyword arguments (see the documentation for more information)
    """
    with hide(*HIDDEN_ALL):
        with lcd(CONTIKI_FOLDER):
            cversion = local('git --git-dir .git describe --tags --always', capture=True)
        logger.warn("Contiki-OS: {}".format(cversion))
        with lcd(FRAMEWORK_FOLDER):
            cversion = local('git --git-dir .git describe --tags --always', capture=True)
        logger.warn("RPL Attacks Framework: {}".format(cversion))


# **************************************** MAGICAL COMMANDS *************************************** 
开发者ID:dhondta,项目名称:rpl-attacks,代码行数:18,代码来源:commands.py

示例8: __init__

# 需要导入模块: from fabric import api [as 别名]
# 或者: from fabric.api import local [as 别名]
def __init__(self, name, cwd=None):
        """Create a tmux session.

        Args:
            name (str): name of the new session
            cwd (str): initial directory of the session

        Options used:
            -d: do not attach to the new session
            -s: specify a name for the session
        """
        self.name = name

        with settings(hide('warnings'), warn_only=True):
            result = local("tmux new -d -s {}".format(name))  # start tmux session

        if result.failed:
            raise TmuxSessionExists()

        if cwd is None:
            cwd = os.getcwd()

        # move to current directory
        self.run("cd {}".format(cwd)) 
开发者ID:kelvinguu,项目名称:lang2program,代码行数:26,代码来源:io.py

示例9: modify_server_json

# 需要导入模块: from fabric import api [as 别名]
# 或者: from fabric.api import local [as 别名]
def modify_server_json():
    params=read_ini_file(sys.argv[1:])
    if not params:
        return None
    if not params.has_key('server_file'):
        return None
    server_file = params['server_file']

    timestamp = dt.now().strftime("%Y_%m_%d_%H_%M_%S")
    local( 'cp %s %s.org.%s' %(server_file, server_file, timestamp) )

    in_file = open( server_file, 'r' )
    in_data = in_file.read()
    server_dict = json.loads(in_data)

    update_roles_from_testbed_py(server_dict)

    out_file = open(server_file, 'w')
    out_data = json.dumps(server_dict, indent=4)
    out_file.write(out_data)
    out_file.close()

    return server_dict 
开发者ID:Juniper,项目名称:contrail-server-manager,代码行数:25,代码来源:create_smgr_db.py

示例10: get_vns_with_vns_id_from_db

# 需要导入模块: from fabric import api [as 别名]
# 或者: from fabric.api import local [as 别名]
def get_vns_with_vns_id_from_db():
    vns_id = get_user_vns_id()
    if not vns_id:
        params=read_ini_file(sys.argv[1:])
        vns_id = params['vns_id']

    vns_dict = {"vns": []}
 
    temp_dir= expanduser("~")

    file_name = '%s/vns.json' %(temp_dir)

    local('server-manager show --detail vns --vns_id %s \
                 > %s' %(vns_id, file_name) )

    in_file = open( file_name, 'r' )
    in_data = in_file.read()
    vns_dict = json.loads(in_data)

    return vns_dict 
开发者ID:Juniper,项目名称:contrail-server-manager,代码行数:22,代码来源:create_smgr_db.py

示例11: get_server_with_ip_from_db

# 需要导入模块: from fabric import api [as 别名]
# 或者: from fabric.api import local [as 别名]
def get_server_with_ip_from_db(ip=None):
    params=read_ini_file(sys.argv[1:])
  
    server_dict={}
    if not ip:
        print "Please provide an ip as input arg"
        return ip

    temp_dir= expanduser("~")

    file_name = '%s/server.json' %(temp_dir)

    local('server-manager show --detail server --ip %s \
                 > %s' %(ip, file_name) )


    in_file = open( file_name, 'r' )
    in_data = in_file.read()
    server_dict = json.loads(in_data)

    return server_dict 
开发者ID:Juniper,项目名称:contrail-server-manager,代码行数:23,代码来源:create_smgr_db.py

示例12: deploy

# 需要导入模块: from fabric import api [as 别名]
# 或者: from fabric.api import local [as 别名]
def deploy(target='dev', sha1=None):
    if sha1 is None:
        # get current working git sha1
        sha1 = local('git rev-parse HEAD', capture=True)
    # server code reset to current working sha1
    home_dir = '/home/pyconkr/{target}.pycon.kr/pyconkr-2016'.format(target=target)

    if target == 'dev':
        python_env = '/home/pyconkr/.pyenv/versions/pyconkr-2016-dev'
    else:
        python_env = '/home/pyconkr/.pyenv/versions/pyconkr-2016'

    with settings(cd(home_dir), shell_env(DJANGO_SETTINGS_MODULE='pyconkr.settings_prod')):
        sudo('git fetch --all -p', user='pyconkr')
        sudo('git reset --hard ' + sha1, user='pyconkr')
        sudo('bower install', user='pyconkr')
        sudo('%s/bin/pip install -r requirements.txt' % python_env, user='pyconkr')
        sudo('%s/bin/python manage.py compilemessages' % python_env, user='pyconkr')
        sudo('%s/bin/python manage.py migrate' % python_env, user='pyconkr')
        sudo('%s/bin/python manage.py collectstatic --noinput' % python_env, user='pyconkr')
        # worker reload
        run('echo r > /var/run/pyconkr-2016-%s.fifo' % target) 
开发者ID:pythonkr,项目名称:pyconapac-2016,代码行数:24,代码来源:fabfile.py

示例13: _get_vagrant_connection

# 需要导入模块: from fabric import api [as 别名]
# 或者: from fabric.api import local [as 别名]
def _get_vagrant_connection():
    local('vagrant up')
    result = local('vagrant ssh-config', capture=True)
    hostname = re.findall(r'HostName\s+([^\n]+)', result)[0]
    port = re.findall(r'Port\s+([^\n]+)', result)[0]
    env.hosts = ['%s:%s' % (hostname, port)]
    env.user = re.findall(r'User\s+([^\n]+)', result)[0]
    env.key_filename = re.findall(r'IdentityFile\s+([^\n]+)', result)[0].lstrip("\"").rstrip("\"") 
开发者ID:dhamaniasad,项目名称:crestify,代码行数:10,代码来源:fabfile.py

示例14: install_phantomjs

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

示例15: get_host_user_and_ssh_key_path

# 需要导入模块: from fabric import api [as 别名]
# 或者: from fabric.api import local [as 别名]
def get_host_user_and_ssh_key_path(instance_name, project, zone):
  """Return a tuple of (hostname, username and ssh_key_path)."""
  output = api.local(
      'gcloud compute ssh --project "%s" --zone "%s" %s --dry-run' %
      (project, zone, instance_name),
      capture=True)
  print(output)

  m = re.match('/usr/bin/ssh .*-i ([^ ]+)(?: -o [^ ]+)* ([^ ]+)@([^ ]+)',
               output)
  return (m.group(3), m.group(2), m.group(1)) 
开发者ID:google,项目名称:clusterfuzz,代码行数:13,代码来源:utils.py


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