本文整理汇总了Python中pants.subsystem.subsystem.Subsystem.reset方法的典型用法代码示例。如果您正苦于以下问题:Python Subsystem.reset方法的具体用法?Python Subsystem.reset怎么用?Python Subsystem.reset使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pants.subsystem.subsystem.Subsystem
的用法示例。
在下文中一共展示了Subsystem.reset方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: subsystem_instance
# 需要导入模块: from pants.subsystem.subsystem import Subsystem [as 别名]
# 或者: from pants.subsystem.subsystem.Subsystem import reset [as 别名]
def subsystem_instance(subsystem_type, scope=None, **options):
"""Creates a Subsystem instance for test.
:API: public
:param type subsystem_type: The subclass of :class:`pants.subsystem.subsystem.Subsystem`
to create.
:param string scope: An optional scope to create the subsystem in; defaults to global.
:param **options: Keyword args representing option values explicitly set via the command line.
"""
if not issubclass(subsystem_type, Subsystem):
raise TypeError('The given `subsystem_type` was not a subclass of `Subsystem`: {}'
.format(subsystem_type))
optionables = Subsystem.closure([subsystem_type])
updated_options = dict(Subsystem._options.items()) if Subsystem._options else {}
if options:
updated_options.update(options)
Subsystem._options = create_options_for_optionables(optionables, options=updated_options)
try:
if scope is None:
yield subsystem_type.global_instance()
else:
class ScopedOptionable(Optionable):
options_scope = scope
options_scope_category = ScopeInfo.SUBSYSTEM
yield subsystem_type.scoped_instance(ScopedOptionable)
finally:
Subsystem.reset()
示例2: context
# 需要导入模块: from pants.subsystem.subsystem import Subsystem [as 别名]
# 或者: from pants.subsystem.subsystem.Subsystem import reset [as 别名]
def context(self, for_task_types=None, for_subsystems=None, options=None,
target_roots=None, console_outstream=None, workspace=None,
**kwargs):
"""
:API: public
:param dict **kwargs: keyword arguments passed in to `create_options_for_optionables`.
"""
# Many tests use source root functionality via the SourceRootConfig.global_instance().
# (typically accessed via Target.target_base), so we always set it up, for convenience.
optionables = {SourceRootConfig}
extra_scopes = set()
for_subsystems = for_subsystems or ()
for subsystem in for_subsystems:
if subsystem.options_scope is None:
raise TaskError('You must set a scope on your subsystem type before using it in tests.')
optionables.add(subsystem)
for_task_types = for_task_types or ()
for task_type in for_task_types:
scope = task_type.options_scope
if scope is None:
raise TaskError('You must set a scope on your task type before using it in tests.')
optionables.add(task_type)
# If task is expected to inherit goal-level options, register those directly on the task,
# by subclassing the goal options registrar and settings its scope to the task scope.
if issubclass(task_type, GoalOptionsMixin):
subclass_name = b'test_{}_{}_{}'.format(
task_type.__name__, task_type.goal_options_registrar_cls.options_scope,
task_type.options_scope)
optionables.add(type(subclass_name, (task_type.goal_options_registrar_cls, ),
{b'options_scope': task_type.options_scope}))
extra_scopes.update([si.scope for si in task_type.known_scope_infos()])
optionables.update(Subsystem.closure(
set([dep.subsystem_cls for dep in task_type.subsystem_dependencies_iter()]) |
self._build_configuration.subsystems()))
# Now default the option values and override with any caller-specified values.
# TODO(benjy): Get rid of the options arg, and require tests to call set_options.
options = options.copy() if options else {}
for s, opts in self.options.items():
scoped_opts = options.setdefault(s, {})
scoped_opts.update(opts)
fake_options = create_options_for_optionables(
optionables, extra_scopes=extra_scopes, options=options, **kwargs)
Subsystem.reset(reset_options=True)
Subsystem.set_options(fake_options)
context = create_context_from_options(fake_options,
target_roots=target_roots,
build_graph=self.build_graph,
build_file_parser=self.build_file_parser,
address_mapper=self.address_mapper,
console_outstream=console_outstream,
workspace=workspace)
return context
示例3: tearDown
# 需要导入模块: from pants.subsystem.subsystem import Subsystem [as 别名]
# 或者: from pants.subsystem.subsystem.Subsystem import reset [as 别名]
def tearDown(self):
"""
:API: public
"""
super(BaseTest, self).tearDown()
BuildFile.clear_cache()
Subsystem.reset()
示例4: setUp
# 需要导入模块: from pants.subsystem.subsystem import Subsystem [as 别名]
# 或者: from pants.subsystem.subsystem.Subsystem import reset [as 别名]
def setUp(self):
super(BaseTest, self).setUp()
Goal.clear()
Subsystem.reset()
self.real_build_root = BuildRoot().path
self.build_root = os.path.realpath(mkdtemp(suffix='_BUILD_ROOT'))
self.addCleanup(safe_rmtree, self.build_root)
self.pants_workdir = os.path.join(self.build_root, '.pants.d')
safe_mkdir(self.pants_workdir)
self.options = defaultdict(dict) # scope -> key-value mapping.
self.options[''] = {
'pants_workdir': self.pants_workdir,
'pants_supportdir': os.path.join(self.build_root, 'build-support'),
'pants_distdir': os.path.join(self.build_root, 'dist'),
'pants_configdir': os.path.join(self.build_root, 'config'),
'cache_key_gen_version': '0-test',
}
BuildRoot().path = self.build_root
self.addCleanup(BuildRoot().reset)
# We need a pants.ini, even if empty. get_buildroot() uses its presence.
self.create_file('pants.ini')
self._build_configuration = BuildConfiguration()
self._build_configuration.register_aliases(self.alias_groups)
self.build_file_parser = BuildFileParser(self._build_configuration, self.build_root)
self.address_mapper = BuildFileAddressMapper(self.build_file_parser, FilesystemBuildFile)
self.build_graph = BuildGraph(address_mapper=self.address_mapper)
示例5: mk_cache
# 需要导入模块: from pants.subsystem.subsystem import Subsystem [as 别名]
# 或者: from pants.subsystem.subsystem.Subsystem import reset [as 别名]
def mk_cache(spec):
Subsystem.reset()
self.set_options_for_scope(CacheSetup.subscope(DummyTask.options_scope),
read_from=spec, compression=1)
self.context(for_task_types=[DummyTask]) # Force option initialization.
cache_factory = CacheSetup.create_cache_factory_for_task(DummyTask)
return cache_factory.get_read_cache()
示例6: test_uninitialized_scoped_instance
# 需要导入模块: from pants.subsystem.subsystem import Subsystem [as 别名]
# 或者: from pants.subsystem.subsystem.Subsystem import reset [as 别名]
def test_uninitialized_scoped_instance(self):
Subsystem.reset()
class UninitializedOptional(Optionable):
options_scope = 'optional'
optional = UninitializedOptional()
with self.assertRaisesRegexp(Subsystem.UninitializedSubsystemError,
r'UninitializedSubsystem.*uninitialized-scope'):
UninitializedSubsystem.scoped_instance(optional)
示例7: context
# 需要导入模块: from pants.subsystem.subsystem import Subsystem [as 别名]
# 或者: from pants.subsystem.subsystem.Subsystem import reset [as 别名]
def context(self, for_task_types=None, options=None, passthru_args=None, target_roots=None,
console_outstream=None, workspace=None, for_subsystems=None):
"""
:API: public
"""
# Many tests use source root functionality via the SourceRootConfig.global_instance()
# (typically accessed via Target.target_base), so we always set it up, for convenience.
optionables = {SourceRootConfig}
extra_scopes = set()
for_subsystems = for_subsystems or ()
for subsystem in for_subsystems:
if subsystem.options_scope is None:
raise TaskError('You must set a scope on your subsystem type before using it in tests.')
optionables.add(subsystem)
for_task_types = for_task_types or ()
for task_type in for_task_types:
scope = task_type.options_scope
if scope is None:
raise TaskError('You must set a scope on your task type before using it in tests.')
optionables.add(task_type)
extra_scopes.update([si.scope for si in task_type.known_scope_infos()])
optionables.update(Subsystem.closure(
set([dep.subsystem_cls for dep in task_type.subsystem_dependencies_iter()]) |
self._build_configuration.subsystems()))
# Now default the option values and override with any caller-specified values.
# TODO(benjy): Get rid of the options arg, and require tests to call set_options.
options = options.copy() if options else {}
for s, opts in self.options.items():
scoped_opts = options.setdefault(s, {})
scoped_opts.update(opts)
options = create_options_for_optionables(optionables,
extra_scopes=extra_scopes,
options=options)
Subsystem.reset(reset_options=True)
Subsystem.set_options(options)
context = create_context(options=options,
passthru_args=passthru_args,
target_roots=target_roots,
build_graph=self.build_graph,
build_file_parser=self.build_file_parser,
address_mapper=self.address_mapper,
console_outstream=console_outstream,
workspace=workspace)
return context
示例8: clean_global_runtime_state
# 需要导入模块: from pants.subsystem.subsystem import Subsystem [as 别名]
# 或者: from pants.subsystem.subsystem.Subsystem import reset [as 别名]
def clean_global_runtime_state(reset_subsystem=False):
"""Resets the global runtime state of a pants runtime for cleaner forking.
:param bool reset_subsystem: Whether or not to clean Subsystem global state.
"""
if reset_subsystem:
# Reset subsystem state.
Subsystem.reset()
# Reset Goals and Tasks.
Goal.clear()
# Reset backend/plugins state.
OptionsInitializer.reset()
示例9: fake_distribution_locator
# 需要导入模块: from pants.subsystem.subsystem import Subsystem [as 别名]
# 或者: from pants.subsystem.subsystem.Subsystem import reset [as 别名]
def fake_distribution_locator(*versions):
"""Sets up a fake distribution locator with fake distributions.
Creates one distribution for each java version passed as an argument, and yields a list of
paths to the java homes for each distribution.
"""
with fake_distributions(versions) as paths:
path_options = {
DistributionLocator.options_scope: {
'paths': {
os_name: paths,
}
}
}
Subsystem.reset()
init_subsystem(DistributionLocator, options=path_options)
yield paths
示例10: setUp
# 需要导入模块: from pants.subsystem.subsystem import Subsystem [as 别名]
# 或者: from pants.subsystem.subsystem.Subsystem import reset [as 别名]
def setUp(self):
"""
:API: public
"""
super(BaseTest, self).setUp()
Goal.clear()
Subsystem.reset()
self.real_build_root = BuildRoot().path
self.build_root = os.path.realpath(mkdtemp(suffix='_BUILD_ROOT'))
self.subprocess_dir = os.path.join(self.build_root, '.pids')
self.addCleanup(safe_rmtree, self.build_root)
self.pants_workdir = os.path.join(self.build_root, '.pants.d')
safe_mkdir(self.pants_workdir)
self.options = defaultdict(dict) # scope -> key-value mapping.
self.options[''] = {
'pants_workdir': self.pants_workdir,
'pants_supportdir': os.path.join(self.build_root, 'build-support'),
'pants_distdir': os.path.join(self.build_root, 'dist'),
'pants_configdir': os.path.join(self.build_root, 'config'),
'pants_subprocessdir': self.subprocess_dir,
'cache_key_gen_version': '0-test',
}
self.options['cache'] = {
'read_from': [],
'write_to': [],
}
BuildRoot().path = self.build_root
self.addCleanup(BuildRoot().reset)
self._build_configuration = BuildConfiguration()
self._build_configuration.register_aliases(self.alias_groups)
self.build_file_parser = BuildFileParser(self._build_configuration, self.build_root)
self.project_tree = FileSystemProjectTree(self.build_root)
self.address_mapper = BuildFileAddressMapper(self.build_file_parser, self.project_tree,
build_ignore_patterns=self.build_ignore_patterns)
self.build_graph = MutableBuildGraph(address_mapper=self.address_mapper)
示例11: create_graph_from_specs
# 需要导入模块: from pants.subsystem.subsystem import Subsystem [as 别名]
# 或者: from pants.subsystem.subsystem.Subsystem import reset [as 别名]
def create_graph_from_specs(self, graph_helper, specs):
Subsystem.reset()
target_roots = self.create_target_roots(specs)
graph = graph_helper.create_build_graph(target_roots)[0]
return graph, target_roots
示例12: _create_interpreter_cache
# 需要导入模块: from pants.subsystem.subsystem import Subsystem [as 别名]
# 或者: from pants.subsystem.subsystem.Subsystem import reset [as 别名]
def _create_interpreter_cache(self, setup_options=None):
Subsystem.reset(reset_options=True)
self.context(for_subsystems=[PythonInterpreterCache], options={
'python-setup': setup_options,
})
return PythonInterpreterCache.global_instance()
示例13: test_uninitialized_global
# 需要导入模块: from pants.subsystem.subsystem import Subsystem [as 别名]
# 或者: from pants.subsystem.subsystem.Subsystem import reset [as 别名]
def test_uninitialized_global(self):
Subsystem.reset()
with self.assertRaisesRegexp(Subsystem.UninitializedSubsystemError,
r'UninitializedSubsystem.*uninitialized-scope'):
UninitializedSubsystem.global_instance()
示例14: _jar_dependency_management
# 需要导入模块: from pants.subsystem.subsystem import Subsystem [as 别名]
# 或者: from pants.subsystem.subsystem.Subsystem import reset [as 别名]
def _jar_dependency_management(self, **flags):
Subsystem.reset()
options = {
JarDependencyManagement.options_scope: flags,
}
return global_subsystem_instance(JarDependencyManagement, options=options)
示例15: tearDown
# 需要导入模块: from pants.subsystem.subsystem import Subsystem [as 别名]
# 或者: from pants.subsystem.subsystem.Subsystem import reset [as 别名]
def tearDown(self):
SourceRoot.reset()
FilesystemBuildFile.clear_cache()
Subsystem.reset()