当前位置: 首页>>代码示例>>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;未经允许,请勿转载。