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


Python invoke.run方法代碼示例

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


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

示例1: bro_server

# 需要導入模塊: import invoke [as 別名]
# 或者: from invoke import run [as 別名]
def bro_server(bro_file, interface="eth0", bro_path="/usr/local/bro/bin/bro"):
    u""" 跑bro服務進程 """
    # 獲取絕對路徑
    bro_file = path.realpath(bro_file)
    http_file = "/usr/local/bro/share/bro/base/protocols/http/main.bro"
    bro_scripts = ' '.join([bro_file, http_file])

    cmd = "sudo {bro_path} -C -b -i {interface} {bro_scripts}"
    cmd = cmd.format(bro_path=bro_path,
                     interface=interface,
                     bro_scripts=bro_scripts)

    msg = "the cmd is: %s" % cmd
    logging.info(msg)

    # change pwd to /tmp
    tmp_dir = path.join(path.dirname(path.realpath(__file__)), '../../tmp/')
    chdir(tmp_dir)

    result = run(cmd)
    logging.info(result.__dict__) 
開發者ID:threathunterX,項目名稱:sniffer,代碼行數:23,代碼來源:run_driver.py

示例2: create_env

# 需要導入模塊: import invoke [as 別名]
# 或者: from invoke import run [as 別名]
def create_env(name, requirements=False, self=False, force=False):
    """Create a new virtual environment"""
    path = os.path.join(BASE, "build", "envs", name)

    # Don't re-create the environment if force is False
    if os.path.exists(path):
        if force:
            shutil.rmtree(path)
        else:
            return path

    invoke.run("virtualenv -p %s %s" % (PYTHON, path))
    if requirements:
        invoke.run("%s/bin/pip install -r requirements-%s.txt" % (path, name))
    if self:
        invoke.run("%s/bin/pip install -e ." % path)

    return path 
開發者ID:python-botogram,項目名稱:botogram,代碼行數:20,代碼來源:tasks.py

示例3: i18n_extract

# 需要導入模塊: import invoke [as 別名]
# 或者: from invoke import run [as 別名]
def i18n_extract(ctx):
    """Extract all the messages from the source code"""
    env = create_env("build", requirements=True)

    base = os.path.join(BASE, "i18n")
    langs_dir = os.path.join(base, "langs")

    invoke.run("%s/bin/pybabel extract %s -o %s/%s.pot -w 79 "
               "--msgid-bugs-address \"%s\" --copyright-holder \"%s\" "
               "--project %s --version %s" %
               (env, PROJECT, base, PROJECT, ISSUES, COPYRIGHT, PROJECT,
                   VERSION))

    for lang in i18n_available():
        invoke.run("%s/bin/pybabel update -i %s/%s.pot -o %s/%s.po -l %s" %
                   (env, base, PROJECT, langs_dir, lang, lang)) 
開發者ID:python-botogram,項目名稱:botogram,代碼行數:18,代碼來源:tasks.py

示例4: i18n_new

# 需要導入模塊: import invoke [as 別名]
# 或者: from invoke import run [as 別名]
def i18n_new(ctx, lang):
    """Create a new language file"""
    env = create_env("build", requirements=True)

    base = os.path.join(BASE, "i18n")
    langs_dir = os.path.join(base, "langs")

    if lang in i18n_available():
        print("The language \"%s\" already exists" % lang)
        exit(1)

    invoke.run("%s/bin/pybabel init -i %s/%s.pot -o %s/%s.po -l %s" %
               (env, base, PROJECT, langs_dir, lang, lang))


#
# Build and installation
# 
開發者ID:python-botogram,項目名稱:botogram,代碼行數:20,代碼來源:tasks.py

示例5: git_disable_gpgsign

# 需要導入模塊: import invoke [as 別名]
# 或者: from invoke import run [as 別名]
def git_disable_gpgsign():
    """
    Disables git commit GPG signing temporarily.
    """
    try:
        result = run("git config --global --get commit.gpgSign", hide=True)
    # throws only on travis-ci. unknown reason
    except UnexpectedExit:

        class ResultNone:
            stdout = ""

        result = ResultNone()
    if result.stdout.strip() == "true":
        # turn off gpg signing commits
        try:
            run("git config --global --unset commit.gpgSign")
            yield
        # turn gpg signing back on
        except KeyboardInterrupt:
            run("git config --global --bool commit.gpgSign true")
        finally:
            run("git config --global --bool commit.gpgSign true")
    else:
        yield 
開發者ID:NathanUrwin,項目名稱:cookiecutter-git,代碼行數:27,代碼來源:post_gen_project.py

示例6: _get_cookiecutter_result

# 需要導入模塊: import invoke [as 別名]
# 或者: from invoke import run [as 別名]
def _get_cookiecutter_result():
        """
        Removes as much jinja2 templating from the hook as possible.
        """
        # http://flask.pocoo.org/docs/latest/templating/#standard-filters
        try:
            result = json.loads("""{{ cookiecutter | tojson() }}""")
        # current temp hack around for `pipenv run pytest -s`
        except json.JSONDecodeError:
            result = {}
            repo_dirpath = os.path.dirname(
                os.path.dirname(os.path.abspath(__file__))
            )
            json_filepath = os.path.join(repo_dirpath, "cookiecutter.json")
            with open(json_filepath) as f:
                for k, v in json.loads(f.read()).items():
                    result[k] = v
                    if isinstance(v, list):
                        result[k] = v[0]
        return result 
開發者ID:NathanUrwin,項目名稱:cookiecutter-git,代碼行數:22,代碼來源:post_gen_project.py

示例7: deploy_to_heroku

# 需要導入模塊: import invoke [as 別名]
# 或者: from invoke import run [as 別名]
def deploy_to_heroku(c, app_instance, local_branch='master',
                     remote_branch='master'):
    check_if_logged_in_to_heroku(c)
    print(
        'This will push your local "{local_branch}" branch to remote '
        '"{remote_branch}" branch.'.format(
            local_branch=local_branch,
            remote_branch=remote_branch
        )
    )
    deploy_prompt(c, app_instance)
    remote_name = setup_heroku_git_remote(c, app_instance)
    local('git push {remote} {local_branch}:{remote_branch}'.format(
        remote=remote_name,
        local_branch=local_branch,
        remote_branch=remote_branch,
    )) 
開發者ID:torchbox,項目名稱:wagtail-torchbox,代碼行數:19,代碼來源:fabfile.py

示例8: install_bro

# 需要導入模塊: import invoke [as 別名]
# 或者: from invoke import run [as 別名]
def install_bro():
    """安裝bro抓包工具"""
    print "only support ubuntu now."
    # 安裝libs
    run("sudo apt-get install cmake make gcc g++ flex bison"
        " libpcap-dev libssl-dev python-dev swig zlib1g-dev")

    # 下載解壓bro.並安裝
    run("wget -c https://www.bro.org/downloads/release/bro-2.4.1.tar.gz"
        " -O ~/Downloads/bro-2.4.1.tar.gz")
    run("cd ~/Downloads && tar xvaf bro-2.4.1.tar.gz")
    run("cd ~/Downloads/bro-2.4.1 && ./configure && make && sudo make install")
    print "remember to set bro to your path!" 
開發者ID:threathunterX,項目名稱:sniffer,代碼行數:15,代碼來源:tasks.py

示例9: install_broccoli_python

# 需要導入模塊: import invoke [as 別名]
# 或者: from invoke import run [as 別名]
def install_broccoli_python():
    """安裝bro client python綁定"""
    print "only support ubuntu now."
    # 下載解壓
    run("wget -O ~/Downloads/broccoli-python-0.59.tar.gz -c "
        "https://www.bro.org/downloads/release/broccoli-python-0.59.tar.gz")
    run("cd ~/Downloads && tar xvaf broccoli-python-0.59.tar.gz")

    # 安裝
    run("cd ~/Downloads/broccoli-python-0.59/"
        " && export PATH=/usr/local/bro/bin:${PATH} "
        " && export LD_LIBRARY_PATH=/usr/local/bro/lib:${LD_LIBRARY_PATH} "
        " && ./configure && make && python setup.py install")

    run('echo "export PATH=/usr/local/bro/bin:${PATH}" >> ~/.bashrc') 
開發者ID:threathunterX,項目名稱:sniffer,代碼行數:17,代碼來源:tasks.py

示例10: make_dev

# 需要導入模塊: import invoke [as 別名]
# 或者: from invoke import run [as 別名]
def make_dev():
    """ 自動完成開發環境部署 """
    run("sudo apt-get install redis-server")
    run("pip install -r requirements.txt")


# 管理invoke命名空間 
開發者ID:threathunterX,項目名稱:sniffer,代碼行數:9,代碼來源:tasks.py

示例11: rm_old_http_brp

# 需要導入模塊: import invoke [as 別名]
# 或者: from invoke import run [as 別名]
def rm_old_http_brp():
    u""" 刪除http.bro """
    if path.exists(DEFAULT_HTTP_BRO_DST):
        run("sudo rm {}".format(DEFAULT_HTTP_BRO_DST)) 
開發者ID:threathunterX,項目名稱:sniffer,代碼行數:6,代碼來源:run_driver.py

示例12: i18n_compile

# 需要導入模塊: import invoke [as 別名]
# 或者: from invoke import run [as 別名]
def i18n_compile(ctx):
    """Compile the translation files"""
    env = create_env("build", requirements=True)

    dest_dir = os.path.join(BASE, PROJECT, "i18n")
    orig_dir = os.path.join(BASE, "i18n", "langs")
    os.makedirs(dest_dir, exist_ok=True)

    for lang in i18n_available():
        invoke.run("%s/bin/pybabel compile -i %s/%s.po -o %s/%s.mo -l %s" %
                   (env, orig_dir, lang, dest_dir, lang, lang)) 
開發者ID:python-botogram,項目名稱:botogram,代碼行數:13,代碼來源:tasks.py

示例13: build

# 需要導入模塊: import invoke [as 別名]
# 或者: from invoke import run [as 別名]
def build(ctx):
    """Create a new build"""
    env = create_env("build", requirements=True)

    out = os.path.join(BASE, "build", "packages")
    if os.path.exists(out):
        remove_dir_content(out)

    for type in "sdist", "bdist_wheel":
        invoke.run("%s/bin/python setup.py %s -d %s" % (env, type, out)) 
開發者ID:python-botogram,項目名稱:botogram,代碼行數:12,代碼來源:tasks.py

示例14: test

# 需要導入模塊: import invoke [as 別名]
# 或者: from invoke import run [as 別名]
def test(ctx):
    """Run the test suite"""
    env = create_env("test", requirements=True, self=True)

    invoke.run("%s/bin/py.test tests" % env, pty=True)


#
# Linting
# 
開發者ID:python-botogram,項目名稱:botogram,代碼行數:12,代碼來源:tasks.py

示例15: lint

# 需要導入模塊: import invoke [as 別名]
# 或者: from invoke import run [as 別名]
def lint(ctx):
    """Lint the source code"""
    FLAKE8_OPTIONS = "--select=E,W,F,C9,N8"
    env = create_env("lint", requirements=True)

    invoke.run("%s/bin/flake8 %s %s" % (env, FLAKE8_OPTIONS, PROJECT))


#
# Documentation
# 
開發者ID:python-botogram,項目名稱:botogram,代碼行數:13,代碼來源:tasks.py


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