當前位置: 首頁>>代碼示例>>Python>>正文


Python api.cd方法代碼示例

本文整理匯總了Python中fabric.api.cd方法的典型用法代碼示例。如果您正苦於以下問題:Python api.cd方法的具體用法?Python api.cd怎麽用?Python api.cd使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在fabric.api的用法示例。


在下文中一共展示了api.cd方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: update

# 需要導入模塊: from fabric import api [as 別名]
# 或者: from fabric.api import cd [as 別名]
def update():
    """Update the svn repo, then reinstall LNT."""
    with cd(LNT_PATH):
        with cd(LNT_PATH + "/docs/"):
            sudo('rm -rf _build')
        with cd(LNT_PATH + "/lnt/server/ui/static"):
            sudo('rm -rf docs')
            sudo('git checkout docs')

        sudo("git pull --rebase")
        run("git log -1 --pretty=%B")
        with cd(LNT_PATH + "/docs/"):
            sudo(in_venv("make"))
        sudo(IN_VENV + "python setup.py install --server")

    put(here + "/blacklist", "/tmp/blacklist")
    sudo("mv /tmp/blacklist /srv/lnt/install/blacklist")
    put(here + "/kill_zombies.py", "/tmp/kill_zombies.py")
    sudo("mv /tmp/kill_zombies.py /etc/cron.hourly/kill_zombies")
    sudo("chmod +x /etc/cron.hourly/kill_zombies")
    rotate_log()
    service_restart() 
開發者ID:llvm,項目名稱:llvm-zorg,代碼行數:24,代碼來源:fabfile.py

示例2: setup_supervisor

# 需要導入模塊: from fabric import api [as 別名]
# 或者: from fabric.api import cd [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') 
開發者ID:dhamaniasad,項目名稱:crestify,代碼行數:24,代碼來源:fabfile.py

示例3: engine_start

# 需要導入模塊: from fabric import api [as 別名]
# 或者: from fabric.api import cd [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) 
開發者ID:marvin-ai,項目名稱:marvin-python-toolbox,代碼行數:23,代碼來源:fabfile.py

示例4: keys

# 需要導入模塊: from fabric import api [as 別名]
# 或者: from fabric.api import cd [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

示例5: experiment1collect

# 需要導入模塊: from fabric import api [as 別名]
# 或者: from fabric.api import cd [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

示例6: build

# 需要導入模塊: from fabric import api [as 別名]
# 或者: from fabric.api import cd [as 別名]
def build(build_type='prod'):
    """
        Drops and recreates the databases for development, then initializes main
        This will raise an error if 127.0.0.1 is not in env.hosts to protect live databases
        Make sure complete migration scripts exist prior to running this
    :return:
    """
    restart_supervisor()
    prepare_build_or_deploy(build_type=build_type)
    start = datetime.datetime.now()
    recreate_db(build_type)
    with cd(get_django_setting(build_type, 'ROOT_PATH')):
        manage_py('syncdb --noinput', build_type)
        manage_py('migrate', build_type)
        manage_py('collectstatic --noinput', build_type)
        setup_tilestache_user()
    build_database(build_type=build_type)
    post_build_database()
    end = datetime.datetime.now()
    elapsed = end - start
    print elapsed
    npm_install() 
開發者ID:CalthorpeAnalytics,項目名稱:urbanfootprint,代碼行數:24,代碼來源:methods.py

示例7: build_database

# 需要導入模塊: from fabric import api [as 別名]
# 或者: from fabric.api import cd [as 別名]
def build_database(build_type='dev', **kwargs):
    """
    Calls footprint_init to load fixture datasets from into the app.

    :param kwargs: all the options for footprint init
    :return:
    """

    # TODO: unify dev+devbuild and prod+init and/or provide a way to
    # override this celery setting. In the mean time this is a hack to
    # make sure we use a build file with CELERY_ALWAYS_EAGER=False
    if build_type == 'dev':
        build_type = 'devbuild'
    elif build_type == 'prod':
        build_type = 'init'
    with cd(get_django_setting(build_type, 'ROOT_PATH')):
        args = ' '.join(["--{}={}".format(key, value) for key, value in kwargs.iteritems()])
        manage_py('footprint_init %s' % args, build_type) 
開發者ID:CalthorpeAnalytics,項目名稱:urbanfootprint,代碼行數:20,代碼來源:methods.py

示例8: setupServers

# 需要導入模塊: from fabric import api [as 別名]
# 或者: from fabric.api import cd [as 別名]
def setupServers():
    sudo('yes '' | add-apt-repository ppa:fkrull/deadsnakes-python2.7 -y')
    sudo('apt-get -y update')
    sudo('apt-get -y install python2.7')
    sudo('apt-get -y dist-upgrade')
    sudo('apt-get -y install python-pip python-dev build-essential')
    sudo('apt-get -y install libssl-dev libffi-dev git-all')
    sudo('yes | pip install --upgrade pip')
    sudo('yes | pip install --upgrade virtualenv')
    sudo('yes | pip install --upgrade petlib')
    sudo('yes | pip install twisted==16.6.0')
    sudo('yes | pip install numpy')
    sudo('yes | pip install service_identity')
    sudo('yes | pip install sphinxmix')
    sudo('apt-get -y install htop')
    #sudo('apt-get -y install tshark')
    if fabric.contrib.files.exists("loopix"):
        with cd("loopix"):
            run("git pull")
            run("git checkout %s" % BRANCH)
    else:
        run("git clone https://github.com/UCL-InfoSec/loopix.git") 
開發者ID:UCL-InfoSec,項目名稱:loopix,代碼行數:24,代碼來源:fabfile.py

示例9: deployMultiClient

# 需要導入模塊: from fabric import api [as 別名]
# 或者: from fabric.api import cd [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

示例10: rollback

# 需要導入模塊: from fabric import api [as 別名]
# 或者: from fabric.api import cd [as 別名]
def rollback():
    """
    Reverts project state to the last deploy.
    When a deploy is performed, the current state of the project is
    backed up. This includes the last commit checked out, the database,
    and all static files. Calling rollback will revert all of these to
    their state prior to the last deploy.
    """
    with project():
        with update_changed_requirements():
            update = "git checkout" if env.git else "hg up -C"
            run("%s `cat last.commit`" % update)
        with cd(join(static(), "..")):
            run("tar -xf %s" % join(env.proj_path, "last.tar"))
        restore("last.db")
    restart() 
開發者ID:keithadavidson,項目名稱:ansible-mezzanine,代碼行數:18,代碼來源:fabfile.py

示例11: delete_old_builds

# 需要導入模塊: from fabric import api [as 別名]
# 或者: from fabric.api import cd [as 別名]
def delete_old_builds(history):
    ''' Auto delete unnecessary build directories from the filesystem. '''
    build_path = get_release_dir()
    kept_builds = map(lambda x: get_build_name(x['id']), history['builds'])
    found_builds = fs.glob(build_path)
    to_be_deleted_builds = [x for x in found_builds if x not in kept_builds]
    deletion_count = len(to_be_deleted_builds)

    # Skip, if there are no builds to be deleted.
    if deletion_count == 0:
        return

    # Remove directories to be deleted.
    with cd(build_path):
        fs.rm_rf(to_be_deleted_builds)
        remote_info(
            'Deleted {} old build(s) from the remote'.format(deletion_count)
        ) 
開發者ID:kabirbaidhya,項目名稱:boss,代碼行數:20,代碼來源:buildman.py

示例12: all_run

# 需要導入模塊: from fabric import api [as 別名]
# 或者: from fabric.api import cd [as 別名]
def all_run(directory='distributed_rl', num_proc='4'):
    with cd(directory):
        with settings(warn_only=True):
            run("./run.sh %s" % num_proc) 
開發者ID:neka-nat,項目名稱:distributed_rl,代碼行數:6,代碼來源:fabfile.py

示例13: actor_run

# 需要導入模塊: from fabric import api [as 別名]
# 或者: from fabric.api import cd [as 別名]
def actor_run(directory='distributed_rl', num_proc='1', learner_host='localhost'):
    print('num_proc: %s' % num_proc)
    print('learner_host: %s' % learner_host)
    with cd(directory):
        with settings(warn_only=True):
            run("./run.sh %s config/actor.conf %s" % (num_proc, learner_host)) 
開發者ID:neka-nat,項目名稱:distributed_rl,代碼行數:8,代碼來源:fabfile.py

示例14: learner_run

# 需要導入模塊: from fabric import api [as 別名]
# 或者: from fabric.api import cd [as 別名]
def learner_run(directory='distributed_rl'):
    with cd(directory):
        with settings(warn_only=True):
            run("./run.sh 0 config/learner.conf localhost") 
開發者ID:neka-nat,項目名稱:distributed_rl,代碼行數:6,代碼來源:fabfile.py

示例15: deploy

# 需要導入模塊: from fabric import api [as 別名]
# 或者: from fabric.api import cd [as 別名]
def deploy(branch='master'):
    version_folder = '{rp}/{vf}'.format(rp=ROOT_PATH, vf=VERSION)
    run('mkdir -p {p}'.format(p=version_folder))  
    with cd(version_folder):
        # _create_new_dir() 
        _get_latest_source(branch)
        _update_virtualenv()
        _create_or_update_settings()
        _create_static_media_symlinks()
        _update_static_files()
        _update_database()
        _update_symlink()
        _restart_webserver() 
開發者ID:ecds,項目名稱:readux,代碼行數:15,代碼來源:fabfile.py


注:本文中的fabric.api.cd方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。