python类run()的实例源码

terraform.py 文件源码 项目:rancher-cluster 作者: sundeer 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def run_terraform(ctx, command, opts_list):
    # Add state file location option
    tf_state_file = '{0}/{1}'.format(ctx.terraform.dir, ctx.terraform.state)
    option = '-state={0}'.format(tf_state_file)
    opts_list.append(option)

    # Build terraform command
    opts = ' '.join(opts_list)
    tf_dir = ctx.terraform.dir
    terraform = 'terraform {0} {1} {2}'.format(command, opts, tf_dir)

    result = run(terraform, hide=False, warn=True)
    if result.ok:
        list(ctx)
    else:
        print("\n" + "-> " + result.command + "\n")
        print(result)
        raise exceptions.Failure(result)
tasks.py 文件源码 项目:python-deform 作者: deformio 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def deploy_docs():
    """
    Based on https://gist.github.com/domenic/ec8b0fc8ab45f39403dd
    """
    run('rm -rf ./site/')
    build_docs()
    with util.cd('./site/'):
        run('git init')
        run('echo ".*pyc" > .gitignore')
        run('git config user.name "Travis CI"')
        run('git config user.email "%s"' % os.environ['EMAIL'])
        run('git add .')
        run('git commit -m "Deploy to GitHub Pages"')
        run(
            'git push --force --quiet "https://{GH_TOKEN}@{GH_REF}" '
            'master:gh-pages > /dev/null 2>&1'.format(
                GH_TOKEN=os.environ['GH_TOKEN'],
                GH_REF=os.environ['GH_REF'],
            )
        )
django.py 文件源码 项目:python-boilerplate 作者: fabiommendes 项目源码 文件源码 阅读 30 收藏 0 点赞 0 评论 0
def gunicorn(ctx, bind='localhost:8000', workers=13, collectstatic=True):
    """
    Starts Gunicorn server. This is not an optimal deployment, since you should
    serve static files with a proxy such as nginx. However, Gunicorn is much
    more robust than the development server that comes bundled with Django.
    """

    if collectstatic:
        django_manage('collectstatic')
    ctx.run('gunicorn {project_root}.wsgi -b {bind} '
            '--workers {workers} '
            '--name {project}-server'.format(
        project_root=project_root(),
        bind=bind,
        workers=workers,
        project=get_option('options', 'pyname').replace('_', '-')
    ))
tasks.py 文件源码 项目:cli-bdd 作者: chibisov 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def deploy_docs():
    """
    Based on https://gist.github.com/domenic/ec8b0fc8ab45f39403dd
    """
    run('rm -rf ./site/')
    build_docs()
    with util.cd('./site/'):
        run('git init')
        run('echo ".*pyc" > .gitignore')
        run('git config user.name "Travis CI"')
        run('git config user.email "%s"' % os.environ['EMAIL'])
        run('git add .')
        run('git commit -m "Deploy to GitHub Pages"')
        run(
            'git push --force --quiet "https://{GH_TOKEN}@{GH_REF}" '
            'master:gh-pages > /dev/null 2>&1'.format(
                GH_TOKEN=os.environ['GH_TOKEN'],
                GH_REF=os.environ['GH_REF'],
            )
        )
tasks.py 文件源码 项目:django-make-app 作者: illagrenan 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def lint():
    run("flake8 django_make_app tests")
tasks.py 文件源码 项目:django-make-app 作者: illagrenan 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def test():
    run("py.test --verbose --showlocals tests/")
tasks.py 文件源码 项目:django-make-app 作者: illagrenan 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def test_all():
    run("tox")
tasks.py 文件源码 项目:django-make-app 作者: illagrenan 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def test_cov():
    run("py.test --verbose --showlocals --cov=django_make_app tests/")
tasks.py 文件源码 项目:django-make-app 作者: illagrenan 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def test_setuptools():
    run("python setup.py test")
tasks.py 文件源码 项目:django-make-app 作者: illagrenan 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def coverage():
    run("coverage run --source django_make_app setup.py test")
    run("coverage report -m")
    run("coverage html")
tasks.py 文件源码 项目:django-make-app 作者: illagrenan 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def install_requirements():
    run("pip install -r requirements.txt --upgrade --use-wheel")
tasks.py 文件源码 项目:django-make-app 作者: illagrenan 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def test_install():
    run("pip uninstall django_make_app --yes", warn=True)

    run("pip install --use-wheel --no-index --find-links dist django_make_app")
    run("pip uninstall django_make_app --yes")
tasks.py 文件源码 项目:django-make-app 作者: illagrenan 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def build():
    run("python setup.py check --verbose --strict --restructuredtext")

    run("python setup.py build")
    run("python setup.py sdist")
    run("python setup.py bdist_wheel")
tasks.py 文件源码 项目:django-make-app 作者: illagrenan 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def publish():
    run('python setup.py sdist upload -r pypi')
    run('python setup.py bdist_wheel upload -r pypi')
tasks.py 文件源码 项目:Daytse.bundle 作者: shvets 项目源码 文件源码 阅读 32 收藏 0 点赞 0 评论 0
def test(script):
    run("python " + script)
tasks.py 文件源码 项目:Daytse.bundle 作者: shvets 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def reset():
    run("rm -rf " + plex_home + "/Plug-in\ Support/Caches/com.plexapp.plugins." + plugin_name)
    run("rm -rf " + plex_home + "/Plug-in\ Support/Data/com.plexapp.plugins." + plugin_name)
    run("rm -rf " + plex_home + "/Plug-in\ Support/Preferences/com.plexapp.plugins." + plugin_name + ".xml")
    # run("rm -rf " + plugin_dir)

    print("Plugin was reset.")
tasks.py 文件源码 项目:Daytse.bundle 作者: shvets 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def copy(plugin_dir):
    run("mkdir -p " + plugin_dir + "/Contents/Code")
    run("mkdir -p " + plugin_dir + "/Contents/Libraries/Shared")

    run("cp -R Contents/* " + plugin_dir + "/Contents")
    run("cp -R Contents/Libraries/Shared/* " + plugin_dir + "/Contents/Libraries/Shared")

    print("Files were copied.")
tasks.py 文件源码 项目:Daytse.bundle 作者: shvets 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def reload():
    import urllib2

    with open(os.getenv("HOME") + "/Dropbox/.plex-token") as f:
        content = f.readlines()[0].strip()

    url = "http://127.0.0.1:32400/:/plugins/com.plexapp.system/restart?X-Plex-Token=" + content
    urllib2.urlopen(url).read()

    print("Server was restarted.")

    run("tail -f ~/Library/Logs/Plex\ Media\ Server/PMS\ Plugin\ Logs/com.plexapp.plugins." + plugin_name + ".log")
tasks.py 文件源码 项目:Daytse.bundle 作者: shvets 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def zip(archive):
    run("cd build && zip -r " + archive + " .")
tasks.py 文件源码 项目:Daytse.bundle 作者: shvets 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def clean():
    run("rm -rf build")
tasks.py 文件源码 项目:Daytse.bundle 作者: shvets 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def build():
    clean()

    run("mkdir -p build/" + bundle_name)

    copy('build/' + bundle_name)
    zip(archive)
tasks.py 文件源码 项目:Daytse.bundle 作者: shvets 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def plex_uninstall():
    run("rm -rf ~/Library/Application Support/Plex Media Server/")
    run("rm -rf ~/Library/Caches/PlexMediaServer/")
    run("rm -rf ~/Library/Preferences/com.plexapp.plexmediaserver.plist")
tasks.py 文件源码 项目:pinder 作者: dotwaffle 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def prepare(ctx):
    invoke.run('ansible-playbook playbook_prepare.yml')
tasks.py 文件源码 项目:pinder 作者: dotwaffle 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def deploy_rtr00(ctx):
    invoke.run('ansible-playbook playbook_configure.yml --limit rtr00')
tasks.py 文件源码 项目:pinder 作者: dotwaffle 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
def deploy_rtr01(ctx):
    invoke.run('ansible-playbook playbook_configure.yml --limit rtr01')
tasks.py 文件源码 项目:pinder 作者: dotwaffle 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def verify(ctx):
    invoke.run('ansible-playbook playbook_facts.yml')
tasks.py 文件源码 项目:pinder 作者: dotwaffle 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
def get_requests(ctx):
    results = invoke.run('../../pinder/manage.py cli --all')
tasks.py 文件源码 项目:strongjobs 作者: percipient 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def clean(ctx):
    """Remove created files and caches."""
    run("rm -rf CloudFormation.json")
    run("find . \( -name '__pycache__' -o -name '*.pyc' \) -print -delete")
tasks.py 文件源码 项目:python-deform 作者: deformio 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def build_docs():
    generate_api_reference()
    run('mkdocs build')
tasks.py 文件源码 项目:python-deform 作者: deformio 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def serve_docs():
    generate_api_reference()

    target_cmd = (
        'watchmedo shell-command -R -c '
        '"invoke generate-api-reference" pydeform docs'
    )
    p = threading.Thread(target=run, args=(target_cmd,))
    p.daemon = True
    p.start()

    run('mkdocs serve')


问题


面经


文章

微信
公众号

扫码关注公众号