本文整理匯總了Python中invoke.Collection類的典型用法代碼示例。如果您正苦於以下問題:Python Collection類的具體用法?Python Collection怎麽用?Python Collection使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了Collection類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: explicit_namespace_works_correctly
def explicit_namespace_works_correctly(self):
# Regression-ish test re #288
ns = Collection.from_module(load('integration'))
expect(
'print_foo',
out='foo\n',
program=Program(namespace=ns),
)
示例2: _site
def _site(name, help_part):
_path = join("sites", name)
# TODO: turn part of from_module into .clone(), heh.
self = sys.modules[__name__]
coll = Collection.from_module(
self,
name=name,
config={"sphinx": {"source": _path, "target": join(_path, "_build")}},
)
coll.__doc__ = "Tasks for building {}".format(help_part)
coll["build"].__doc__ = "Build {}".format(help_part)
return coll
示例3: setup_from_tasks
def setup_from_tasks(
globals_dict, main_package=None,
settings_module_name=None, **kwargs):
"""
This is the function you must call from your :xfile:`tasks.py` file
in order to activate the tasks defined by atelier.
"""
if '__file__' not in globals_dict:
raise Exception(
"No '__file__' in %r. "
"First parameter to must be `globals()`" % globals_dict)
tasks_file = Path(globals_dict['__file__'])
if not tasks_file.exists():
raise Exception("No such file: %s" % tasks_file)
# print("20180428 setup_from_tasks() : {}".format(root_dir))
from atelier.invlib import tasks
from atelier.projects import get_project_from_tasks
prj = get_project_from_tasks(tasks_file.parent)
atelier.current_project = prj
if kwargs:
prj.config.update(kwargs)
if settings_module_name is not None:
os.environ['DJANGO_SETTINGS_MODULE'] = settings_module_name
from django.conf import settings
prj.config.update(
languages=[lng.name for lng in settings.SITE.languages])
if isinstance(main_package, six.string_types):
main_package = import_module(main_package)
if main_package:
prj.set_main_package(main_package)
self = Collection.from_module(tasks)
prj.set_namespace(self)
return self
示例4: exec
import pathlib
import sys
from invoke import Collection
from tasks.root import *
ns = Collection.from_module(sys.modules[__name__])
collections = [
'assets',
'analysis',
'deploy',
'dictionary',
'exports',
'fonts',
'jsdata',
'log',
'newrelic',
'search',
'test',
'textdata',
'tmp',
'travis',
]
for collection in collections:
exec('from tasks import {} as module'.format(collection))
ns.add_collection(module)
示例5: doctree
from invocations import docs
from invocations.testing import test
from invocations.packaging import vendorize, release
from invoke import task, run, Collection
@task
def doctree():
run("tree -Ca -I \".git|*.pyc|*.swp|dist|*.egg-info|_static|_build\" docs")
docs = Collection.from_module(docs)
docs.add_task(doctree, 'tree')
ns = Collection(test, vendorize, release, docs)
示例6: get_project_root
import os.path
from invoke import Collection
from app import create_app
from task import db as database, misc, pkg, assets
from task.db import get_project_root
_project_root = get_project_root(__file__)
_app = create_app(os.getenv('ENV') or 'default')
ns = Collection.from_module(misc)
ns.configure({'config': _app.config, 'project_root': _project_root})
ns.add_collection(Collection.from_module(database))
ns.add_collection(Collection.from_module(pkg))
ns.add_collection(Collection.from_module(assets))
示例7: Collection
import sys
from invoke import Collection
# -- TASK-LIBRARY:
from . import _tasklet_cleanup as clean
from . import test
from . import release
# -----------------------------------------------------------------------------
# TASKS:
# -----------------------------------------------------------------------------
# None
# -----------------------------------------------------------------------------
# TASK CONFIGURATION:
# -----------------------------------------------------------------------------
namespace = Collection()
namespace.add_task(clean.clean)
namespace.add_task(clean.clean_all)
namespace.add_collection(Collection.from_module(test))
namespace.add_collection(Collection.from_module(release))
# -- INJECT: clean configuration into this namespace
namespace.configure(clean.namespace.configuration())
if sys.platform.startswith("win"):
# -- OVERRIDE SETTINGS: For platform=win32, ... (Windows)
from ._compat_shutil import which
run_settings = dict(echo=True, pty=False, shell=which("cmd"))
namespace.configure({"run": run_settings})
示例8: site
from os.path import join
from invoke import Collection
from invocations import docs as _docs, testing
d = 'sites'
# Usage doc/API site (published as docs.paramiko.org)
path = join(d, 'docs')
docs = Collection.from_module(_docs, name='docs', config={
'sphinx.source': path,
'sphinx.target': join(path, '_build'),
})
# Main/about/changelog site ((www.)?paramiko.org)
path = join(d, 'www')
www = Collection.from_module(_docs, name='www', config={
'sphinx.source': path,
'sphinx.target': join(path, '_build'),
})
ns = Collection(testing.test, docs=docs, www=www)
示例9: print
# Copy MSVC runtime libraries into the dist folder
redist = r'%VS100COMNTOOLS%..\..\VC\redist\x86\Microsoft.VC100.CRT'
redist = os.path.expandvars(redist)
libs = glob.glob(os.path.join(redist, 'msvc?100.dll'))
if not libs:
print("Warning: Could not copy CRT libraries. Expect deployment problems.",
file=sys.stderr)
return
BUILDDIR = 'dist\\MapsEvolved-win32'
for lib in libs:
shutil.copy(lib, BUILDDIR)
zipname = shutil.make_archive(BUILDDIR, 'zip', BUILDDIR)
print("Successfully created Windows binary distribution.",
file=sys.stderr)
@ctask
def doxygen(ctx):
"""Generate documentation for pymaplib_cpp"""
try:
doxygen = mev_build_utils.find_executable('doxygen')
except ValueError:
logger.error("Could not find doxygen executable. Is it installed?")
sys.exit(2)
ctx.run([doxygen, 'Doxyfile'], cwd='docs')
ns = Collection(*[obj for obj in vars().values() if isinstance(obj, Task)])
ns.add_collection(Collection.from_module(tasks_thirdparty), 'third-party')
ns.add_collection(Collection.from_module(tasks_sip), 'sip')
ns.configure({'run': { 'runner': mev_build_utils.LightInvokeRunner }})
示例10: clean
@task
def clean(ctx):
"""Clean up release artifacts."""
if RELEASE_DIR.is_dir():
try:
shutil.rmtree(str(RELEASE_DIR))
except (OSError, shutil.Error) as e:
logging.warning("Error while cleaning release dir: %s", e)
else:
RELEASE_DIR.mkdir()
# Task setup
ns = Collection()
ns.add_task(all_, default=True)
ns.add_task(clean)
# Import every task from submodules directly into the root task namespace
# (without creating silly qualified names like `release.fpm.deb`
# instead of just `release.deb`).
submodules = [f.stem for f in Path(__file__).parent.glob('*.py')
if f.name != '__init__.py']
this_module = __import__('tasks.release', fromlist=submodules)
for mod_name in submodules:
module = getattr(this_module, mod_name)
collection = Collection.from_module(module)
for task_name in collection.task_names:
task = getattr(module, task_name)
ns.add_task(task)
示例11: main
def main():
program = Program(namespace=Collection.from_module(sys.modules[__name__]),
version='0.1.0')
program.run()
示例12: Collection
#!/usr/bin/env python3
"""Command line tasks to build and deploy the ACW Battle Data."""
from invoke import Collection
from . import data, misc
ns = Collection(misc.clean, misc.doc, misc.deploy, misc.check_tables)
ns.add_task(data.build, name='build', default=True)
ns.add_collection(Collection.from_module(data))
示例13: Collection
from invoke import Collection
from tasks import build, docker, lint, server, test
ns = Collection()
ns.add_collection(Collection.from_module(build))
ns.add_collection(Collection.from_module(docker))
ns.add_collection(Collection.from_module(lint))
ns.add_collection(Collection.from_module(server))
ns.add_collection(Collection.from_module(test))
示例14: task
from . import core as _core
from invoke import Collection as _Collection, task as _task
ns = _Collection.from_module(_core)
def task(*args, **kwargs):
if not kwargs and len(args) == 1 and callable(args[0]):
task = _task(args[0])
ns.add_task(task)
else:
def decorator(func):
task = _task(func)
ns.add_task(task)
return task
return decorator
示例15: in
from invoke import Collection
from . import main, copy, mp3, meta
namespace = Collection.from_module(main)
for mod in (copy, mp3, meta):
namespace.add_collection(mod)