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


Python api.lcd方法代碼示例

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


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

示例1: nonbower

# 需要導入模塊: from fabric import api [as 別名]
# 或者: from fabric.api import lcd [as 別名]
def nonbower():
    if not os.path.exists(components_dir):
        components()
    
    with open("nonbower.json") as f:
        cfg = json.load(f)
    for name, repo in cfg.get('dependencies', {}).items():
        
        clone = "git clone"
        if '#' in repo:
            repo, tag = repo.split('#')
        else:
            tag = None
            clone += " --depth 1"
        
        with lcd(components_dir):
            
            local("{clone} {repo} {name}".format(**locals()))
            
            if tag:
                with lcd(pjoin(components_dir, name)):
                    local("git checkout -b {0} tags/{0}".format(tag))
        
        # remove the git tree, so we don't get submodules
        shutil.rmtree(pjoin(components_dir, name, '.git')) 
開發者ID:ktraunmueller,項目名稱:Computable,代碼行數:27,代碼來源:fabfile.py

示例2: postprocess

# 需要導入模塊: from fabric import api [as 別名]
# 或者: from fabric.api import lcd [as 別名]
def postprocess():
    with lcd(pjoin(components_dir, "bootstrap")):
        local("npm install")
        local("make bootstrap-css")
        local("make bootstrap-js")
    
    # add bootsrap packages to the PATH
    # (less.js needs uglify, which bootstrap just installed above)
    bins = glob.glob(pjoin(components_dir, "bootstrap", "node_modules", "*", "bin"))
    os.environ['PATH'] = os.pathsep.join(bins + [os.environ['PATH']])
    
    # build less
    shutil.rmtree(pjoin(components_dir, "less.js", "dist"))
    with lcd(pjoin(components_dir, "less.js")):
        local("make min")
    
    # build highlight.js
    with lcd(pjoin(components_dir, "highlight.js")):
        local("python tools/build.py")
    
    for toignore in glob.glob(pjoin(here, "*", ".gitignore")):
        os.unlink(toignore) 
開發者ID:ktraunmueller,項目名稱:Computable,代碼行數:24,代碼來源:fabfile.py

示例3: experiment1collect

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

示例4: versions

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

示例5: bower

# 需要導入模塊: from fabric import api [as 別名]
# 或者: from fabric.api import lcd [as 別名]
def bower():
    """install components with bower"""
    with lcd(here):
        local('bower install') 
開發者ID:ktraunmueller,項目名稱:Computable,代碼行數:6,代碼來源:fabfile.py

示例6: _compile_less

# 需要導入模塊: from fabric import api [as 別名]
# 或者: from fabric.api import lcd [as 別名]
def _compile_less(source, target, minify=True, verbose=False):
    """Compile a less file by source and target relative to static_dir"""
    minify = _to_bool(minify)
    verbose = _to_bool(verbose)
    min_flag = '-x' if minify is True else ''
    ver_flag = '--verbose' if verbose is True else ''
    lessc = os.path.join('components', 'less.js', 'bin', 'lessc')
    with lcd(static_dir):
        local('{lessc} {min_flag} {ver_flag} {source} {target}'.format(**locals())) 
開發者ID:ktraunmueller,項目名稱:Computable,代碼行數:11,代碼來源:fabfile.py

示例7: get_config_branch

# 需要導入模塊: from fabric import api [as 別名]
# 或者: from fabric.api import lcd [as 別名]
def get_config_branch():
    with lcd('private'):
        output = local('git branch', capture=True)
        for line in output.splitlines():
            if line[:2] == '* ':
                return line[2:]
    return 'master' 
開發者ID:keakon,項目名稱:Doodle,代碼行數:9,代碼來源:fabfile.py

示例8: push_directory

# 需要導入模塊: from fabric import api [as 別名]
# 或者: from fabric.api import lcd [as 別名]
def push_directory(self):
        with tempfile.TemporaryDirectory() as tmpdir:
            archive = self.archive(rootdir=".", output_dir=tmpdir)
            remote.put(archive, "/tmp/rorolite-project.tgz")

            with lcd(tmpdir):
                self.generate_supervisor_config(rootdir=tmpdir)

                supervisor_archive = self.archive(tmpdir, base_dir=".rorolite", filename="rorolite-supervisor")
                remote.put(supervisor_archive, "/tmp/rorolite-supervisor.tgz")

            with remote.cd(self.deploy_root):
                remote.sudo("chown {} .".format(env.user))
                remote.run("tar xzf /tmp/rorolite-project.tgz")
                remote.run("tar xzf /tmp/rorolite-supervisor.tgz") 
開發者ID:rorodata,項目名稱:rorolite,代碼行數:17,代碼來源:deploy.py

示例9: update

# 需要導入模塊: from fabric import api [as 別名]
# 或者: from fabric.api import lcd [as 別名]
def update():
    # Run tests
    # local("py.test serapis/tests/")

    # Updates code in zip file with current Master without going to EC2 first.
    local('git archive --format=zip HEAD -o %s' % gitfile, capture=False)
    local('unzip -d git_tmp -o -u %s' % gitfile)
    with lcd('git_tmp'):
        local('zip -9r ../%s .' % lambdafile)
    local('zip -9 %s serapis/config/credentials.yaml' % lambdafile)

    for corpus in corpora:
        local('zip -9r {} {}'.format(lambdafile, corpus))
    local('rm -r git_tmp') 
開發者ID:wordnik,項目名稱:serapis,代碼行數:16,代碼來源:fabfile.py

示例10: cooja

# 需要導入模塊: from fabric import api [as 別名]
# 或者: from fabric.api import lcd [as 別名]
def cooja(name, with_malicious=True, **kwargs):
    """
    Start an experiment in Cooja with/without the malicious mote and updates the experiment if motes' positions
     were changed.

    :param name: experiment name
    :param with_malicious: use the simulation WITH the malicious mote or not
    :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)
    """
    sim_path = join(kwargs['path'], 'with{}-malicious'.format(['out', ''][with_malicious is True]))
    motes_before = get_motes_from_simulation(join(sim_path, 'simulation.csc'), as_dictionary=True)
    with hide(*HIDDEN_ALL):
        with lcd(sim_path):
            local("make cooja TASK={}".format(kwargs.get('task', "cooja")))
    motes_after = get_motes_from_simulation(join(sim_path, 'simulation.csc'), as_dictionary=True)
    # if there was a change, update the other simulation in this experiment
    if len(set(motes_before.items()) & set(motes_after.items())) > 0:
        other_sim_path = join(kwargs['path'], 'with{}-malicious'.format(['', 'out'][with_malicious is True]))
        set_motes_to_simulation(join(other_sim_path, 'simulation.csc'), motes_after)
    # if this experiment is part of a campaign, update this
    campaign = read_config(kwargs['path']).get('campaign')
    if campaign is not None:
        for experiment in get_experiments(campaign):
            if experiment in ['BASE', name]:
                continue
            exp_path = join(EXPERIMENT_FOLDER, experiment)
            set_motes_to_simulation(join(exp_path, 'with-malicious', 'simulation.csc'), motes_after)
            set_motes_to_simulation(join(exp_path, 'without-malicious', 'simulation.csc'), motes_after) 
開發者ID:dhondta,項目名稱:rpl-attacks,代碼行數:31,代碼來源:commands.py

示例11: test

# 需要導入模塊: from fabric import api [as 別名]
# 或者: from fabric.api import lcd [as 別名]
def test(**kwargs):
    """
    Run framework's tests.

    :param kwargs: simulation keyword arguments (see the documentation for more information)
    """
    with settings(warn_only=True):
        print(FRAMEWORK_FOLDER)
        with lcd(FRAMEWORK_FOLDER):
            local("python -m unittest -v tests") 
開發者ID:dhondta,項目名稱:rpl-attacks,代碼行數:12,代碼來源:commands.py

示例12: update

# 需要導入模塊: from fabric import api [as 別名]
# 或者: from fabric.api import lcd [as 別名]
def update(silent=False, **kwargs):
    """
    Update Contiki-OS and RPL Attacks Framework.

    :param silent: run command silently
    :param kwargs: simulation keyword arguments (see the documentation for more information)
    """
    updated = False
    for folder, repository in zip([CONTIKI_FOLDER, FRAMEWORK_FOLDER], ["Contiki-OS", "RPL Attacks Framework"]):
        with hide(*HIDDEN_ALL):
            with lcd(folder):
                if "Could not resolve proxy" in local('git fetch --all', capture=True):
                    logger.error("Update failed ; please check your proxy settings")
                    break
                uptodate = "branch is up-to-date" in local('git checkout master', capture=True).strip().split('\n')[-1]
                if not uptodate:
                    req_exists = exists("requirements.txt")
                    if req_exists:
                        req_md5 = hash_file("requirements.txt")
                    logger.warn("You are about to loose any custom change made to {} ;".format(repository))
                    if silent or std_input("Proceed anyway ? (yes|no) [default: no] ", 'yellow') == 'yes':
                        local('git submodule update --init')
                        local('git fetch --all')
                        local('git reset --hard origin/master')
                        local('git pull')
                        if req_exists and hash_file("requirements.txt") != req_md5:
                            local('pip install -r requirements.txt')
                        updated = True
            if repository == "RPL Attacks Framework":
                remove_files(folder, "Vagrantfile")
                remove_folder(join(folder, "provisioning"))
            logger.debug(" > {} {}".format(repository, ["updated", "already up-to-date"][uptodate]))
    if updated:
        setup(silent)
        if not silent:
            logger.warn("Restarting the framework...")
            restart(PIDFILE) 
開發者ID:dhondta,項目名稱:rpl-attacks,代碼行數:39,代碼來源:commands.py

示例13: build

# 需要導入模塊: from fabric import api [as 別名]
# 或者: from fabric.api import lcd [as 別名]
def build():
    with lcd("{}/client".format(PROJECT_LOCAL_DIR)):
        local("npm run build") 
開發者ID:laplace-vi,項目名稱:React-News-Board,代碼行數:5,代碼來源:fabfile.py

示例14: create_zip

# 需要導入模塊: from fabric import api [as 別名]
# 或者: from fabric.api import lcd [as 別名]
def create_zip():
    with lcd("pywren"):
        
        local("zip ../deploy.zip *.py") 
開發者ID:pywren,項目名稱:pywren,代碼行數:6,代碼來源:fabfile.py

示例15: __run

# 需要導入模塊: from fabric import api [as 別名]
# 或者: from fabric.api import lcd [as 別名]
def __run(name, **kwargs):
    """
    Run an experiment.

    :param name: experiment name
    :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)
    """
    set_logging(kwargs.get('loglevel'))
    path = kwargs['path']
    check_structure(path, remove=True)
    with settings(hide(*HIDDEN_ALL), warn_only=True):
        for sim in ["without", "with"]:
            sim_path = join(path, "{}-malicious".format(sim))
            data, results = join(sim_path, 'data'), join(sim_path, 'results')
            # the Makefile is at experiment's root ('path')
            logger.debug(" > Running simulation {} the malicious mote...".format(sim))
            task = kwargs.get('task', "run")
            with lcd(sim_path):
                output = local("make run TASK={}".format(task), capture=True)
            remove_files(sim_path, '.{}'.format(task))
            error, interrupt, error_buffer = False, False, []
            for line in output.split('\n'):
                if line.strip().startswith("FATAL") or line.strip().startswith("ERROR"):
                    error, interrupt = True, True
                elif line.strip().startswith("INFO"):
                    error = False
                    if len(error_buffer) > 0:
                        logger.error('Cooja error:\n' + '\n'.join(error_buffer))
                        error_buffer = []
                if error:
                    error_buffer.append(line)
            if interrupt:
                logger.warn("Cooja failed to execute ; 'run' interrupted (no parsing done)")
                raise Exception("Cooja failed to execute")
            # once the execution is over, gather the screenshots into a single GIF and keep the first and
            #  the last screenshots ; move these to the results folder
            logger.debug(" > Gathering screenshots in an animated GIF...")
            with lcd(data):
                local('convert -delay 10 -loop 0 network*.png wsn-{}-malicious.gif'.format(sim), capture=True)
            network_images = {int(fn.split('.')[0].split('_')[-1]): fn for fn in listdir(data)
                              if fn.startswith('network_')}
            move_files(data, results, 'wsn-{}-malicious.gif'.format(sim))
            if len(network_images) > 0:
                net_start_old = network_images[min(network_images.keys())]
                net_start, ext = splitext(net_start_old)
                net_start_new = 'wsn-{}-malicious_start{}'.format(sim, ext)
                net_end_old = network_images[max(network_images.keys())]
                net_end, ext = splitext(net_end_old)
                net_end_new = 'wsn-{}-malicious_end{}'.format(sim, ext)
                move_files(data, results, (net_start_old, net_start_new), (net_end_old, net_end_new))
                remove_files(data, *network_images.values())
            # then start the parsing functions to derive more results
            parsing_chain(sim_path, logger)
            move_files(sim_path, results, 'COOJA.log')
        # finally, generate the PDF report
        generate_report(path, REPORT_THEME)
    return "Both Cooja executions succeeded" 
開發者ID:dhondta,項目名稱:rpl-attacks,代碼行數:60,代碼來源:commands.py


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