本文整理汇总了Python中st2common.content.utils.get_packs_base_paths函数的典型用法代码示例。如果您正苦于以下问题:Python get_packs_base_paths函数的具体用法?Python get_packs_base_paths怎么用?Python get_packs_base_paths使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_packs_base_paths函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_get_pack_base_paths
def test_get_pack_base_paths(self):
cfg.CONF.content.system_packs_base_path = ""
cfg.CONF.content.packs_base_paths = "/opt/path1"
result = get_packs_base_paths()
self.assertEqual(result, ["/opt/path1"])
# Multiple paths, no trailing colon
cfg.CONF.content.packs_base_paths = "/opt/path1:/opt/path2"
result = get_packs_base_paths()
self.assertEqual(result, ["/opt/path1", "/opt/path2"])
# Multiple paths, trailing colon
cfg.CONF.content.packs_base_paths = "/opt/path1:/opt/path2:"
result = get_packs_base_paths()
self.assertEqual(result, ["/opt/path1", "/opt/path2"])
# Multiple same paths
cfg.CONF.content.packs_base_paths = "/opt/path1:/opt/path2:/opt/path1:/opt/path2"
result = get_packs_base_paths()
self.assertEqual(result, ["/opt/path1", "/opt/path2"])
# Assert system path is always first
cfg.CONF.content.system_packs_base_path = "/opt/system"
cfg.CONF.content.packs_base_paths = "/opt/path2:/opt/path1"
result = get_packs_base_paths()
self.assertEqual(result, ["/opt/system", "/opt/path2", "/opt/path1"])
开发者ID:rlugojr,项目名称:st2,代码行数:26,代码来源:test_content_utils.py
示例2: test_get_pack_base_paths
def test_get_pack_base_paths(self):
cfg.CONF.content.system_packs_base_path = ''
cfg.CONF.content.packs_base_paths = '/opt/path1'
result = get_packs_base_paths()
self.assertEqual(result, ['/opt/path1'])
# Multiple paths, no trailing colon
cfg.CONF.content.packs_base_paths = '/opt/path1:/opt/path2'
result = get_packs_base_paths()
self.assertEqual(result, ['/opt/path1', '/opt/path2'])
# Multiple paths, trailing colon
cfg.CONF.content.packs_base_paths = '/opt/path1:/opt/path2:'
result = get_packs_base_paths()
self.assertEqual(result, ['/opt/path1', '/opt/path2'])
# Multiple same paths
cfg.CONF.content.packs_base_paths = '/opt/path1:/opt/path2:/opt/path1:/opt/path2'
result = get_packs_base_paths()
self.assertEqual(result, ['/opt/path1', '/opt/path2'])
# Assert system path is always first
cfg.CONF.content.system_packs_base_path = '/opt/system'
cfg.CONF.content.packs_base_paths = '/opt/path2:/opt/path1'
result = get_packs_base_paths()
self.assertEqual(result, ['/opt/system', '/opt/path2', '/opt/path1'])
开发者ID:AlexeyDeyneko,项目名称:st2,代码行数:26,代码来源:test_content_utils.py
示例3: test_register_pack_pack_stackstorm_version_and_future_parameters
def test_register_pack_pack_stackstorm_version_and_future_parameters(self):
# Verify DB is empty
pack_dbs = Pack.get_all()
self.assertEqual(len(pack_dbs), 0)
registrar = ResourceRegistrar(use_pack_cache=False)
registrar._pack_loader.get_packs = mock.Mock()
registrar._pack_loader.get_packs.return_value = {'dummy_pack_9': PACK_PATH_9}
packs_base_paths = content_utils.get_packs_base_paths()
registrar.register_packs(base_dirs=packs_base_paths)
# Dependencies, stackstorm_version and future values
pack_db = Pack.get_by_name('dummy_pack_9_deps')
self.assertEqual(pack_db.dependencies, ['core=0.2.0'])
self.assertEqual(pack_db.stackstorm_version, '>=1.6.0, <2.2.0')
self.assertEqual(pack_db.system, {'centos': {'foo': '>= 1.0'}})
self.assertEqual(pack_db.python_versions, ['2', '3'])
# Note: We only store parameters which are defined in the schema, all other custom user
# defined attributes are ignored
self.assertTrue(not hasattr(pack_db, 'future'))
self.assertTrue(not hasattr(pack_db, 'this'))
# Wrong characters in the required st2 version
expected_msg = "'wrongstackstormversion' does not match"
self.assertRaisesRegexp(ValidationError, expected_msg, registrar._register_pack_db,
pack_name=None, pack_dir=PACK_PATH_10)
开发者ID:nzlosh,项目名称:st2,代码行数:27,代码来源:test_resource_registrar.py
示例4: _register_packs
def _register_packs(self):
"""
Register all the packs inside the fixtures directory.
"""
registrar = ResourceRegistrar(use_pack_cache=False)
registrar.register_packs(base_dirs=get_packs_base_paths())
开发者ID:AlexeyDeyneko,项目名称:st2,代码行数:7,代码来源:base.py
示例5: test_register_configs_for_all_packs
def test_register_configs_for_all_packs(self):
# Verify DB is empty
pack_dbs = Pack.get_all()
config_dbs = Config.get_all()
self.assertEqual(len(pack_dbs), 0)
self.assertEqual(len(config_dbs), 0)
registrar = ConfigsRegistrar(use_pack_cache=False)
registrar._pack_loader.get_packs = mock.Mock()
registrar._pack_loader.get_packs.return_value = {'dummy_pack_1': PACK_1_PATH}
packs_base_paths = content_utils.get_packs_base_paths()
registrar.register_from_packs(base_dirs=packs_base_paths)
# Verify pack and schema have been registered
pack_dbs = Pack.get_all()
config_dbs = Config.get_all()
self.assertEqual(len(pack_dbs), 1)
self.assertEqual(len(config_dbs), 1)
config_db = config_dbs[0]
self.assertEqual(config_db.values['api_key'], '{{st2kv.user.api_key}}')
self.assertEqual(config_db.values['api_secret'], SUPER_SECRET_PARAMETER)
self.assertEqual(config_db.values['region'], 'us-west-1')
开发者ID:lyandut,项目名称:st2,代码行数:25,代码来源:test_configs_registrar.py
示例6: _get_api_models_from_disk
def _get_api_models_from_disk(artifact_type, pack_dir=None):
loader = ContentPackLoader()
artifacts = None
if pack_dir:
artifacts_dir = loader.get_content_from_pack(pack_dir, artifact_type)
pack_name = os.path.basename(os.path.normpath(pack_dir))
artifacts = {pack_name: artifacts_dir}
else:
packs_dirs = content_utils.get_packs_base_paths()
artifacts = loader.get_content(packs_dirs, artifact_type)
artifacts_dict = {}
for pack_name, pack_path in artifacts.items():
artifacts_paths = registrar.get_resources_from_pack(pack_path)
for artifact_path in artifacts_paths:
artifact = meta_loader.load(artifact_path)
if artifact_type == "sensors":
sensors_dir = os.path.dirname(artifact_path)
sensor_file_path = os.path.join(sensors_dir, artifact["entry_point"])
artifact["artifact_uri"] = "file://" + sensor_file_path
name = artifact.get("name", None) or artifact.get("class_name", None)
if not artifact.get("pack", None):
artifact["pack"] = pack_name
ref = ResourceReference.to_string_reference(name=name, pack=pack_name)
API_MODEL = API_MODELS_ARTIFACT_TYPES[artifact_type]
# Following conversions are required because we add some fields with
# default values in db model. If we don't do these conversions,
# we'll see a unnecessary diff for those fields.
artifact_api = API_MODEL(**artifact)
artifact_db = API_MODEL.to_model(artifact_api)
artifact_api = API_MODEL.from_model(artifact_db)
artifacts_dict[ref] = artifact_api
return artifacts_dict
开发者ID:azamsheriff,项目名称:st2,代码行数:35,代码来源:diff-db-disk.py
示例7: test_register_all_configs_with_config_schema_validation_validation_failure_1
def test_register_all_configs_with_config_schema_validation_validation_failure_1(self):
# Verify DB is empty
pack_dbs = Pack.get_all()
config_dbs = Config.get_all()
self.assertEqual(len(pack_dbs), 0)
self.assertEqual(len(config_dbs), 0)
registrar = ConfigsRegistrar(use_pack_cache=False, fail_on_failure=True,
validate_configs=True)
registrar._pack_loader.get_packs = mock.Mock()
registrar._pack_loader.get_packs.return_value = {'dummy_pack_6': PACK_6_PATH}
# Register ConfigSchema for pack
registrar._register_pack_db = mock.Mock()
registrar._register_pack(pack_name='dummy_pack_5', pack_dir=PACK_6_PATH)
packs_base_paths = content_utils.get_packs_base_paths()
if six.PY3:
expected_msg = ('Failed validating attribute "regions" in config for pack '
'"dummy_pack_6" (.*?): 1000 is not of type \'array\'')
else:
expected_msg = ('Failed validating attribute "regions" in config for pack '
'"dummy_pack_6" (.*?): 1000 is not of type u\'array\'')
self.assertRaisesRegexp(ValueError, expected_msg,
registrar.register_from_packs,
base_dirs=packs_base_paths)
开发者ID:lyandut,项目名称:st2,代码行数:28,代码来源:test_configs_registrar.py
示例8: collect_pack_content
def collect_pack_content(output_path):
"""
Copy pack contents to the output path.
:param output_path: Path where pack contents will be copied to.
:type output_path: ``str``
"""
LOG.debug('Including content')
packs_base_paths = get_packs_base_paths()
for index, packs_base_path in enumerate(packs_base_paths, 1):
dst = os.path.join(output_path, 'dir-%s' % index)
try:
shutil.copytree(src=packs_base_path, dst=dst)
except IOError:
continue
base_pack_dirs = get_dirs_in_path(file_path=output_path)
for base_pack_dir in base_pack_dirs:
pack_dirs = get_dirs_in_path(file_path=base_pack_dir)
for pack_dir in pack_dirs:
process_content_pack_dir(pack_dir=pack_dir)
开发者ID:lyandut,项目名称:st2,代码行数:25,代码来源:submit_debug_info.py
示例9: test_register_packs
def test_register_packs(self):
# Verify DB is empty
pack_dbs = Pack.get_all()
config_schema_dbs = ConfigSchema.get_all()
self.assertEqual(len(pack_dbs), 0)
self.assertEqual(len(config_schema_dbs), 0)
registrar = ResourceRegistrar(use_pack_cache=False)
registrar._pack_loader.get_packs = mock.Mock()
registrar._pack_loader.get_packs.return_value = {'dummy_pack_1': PACK_PATH_1}
packs_base_paths = content_utils.get_packs_base_paths()
registrar.register_packs(base_dirs=packs_base_paths)
# Verify pack and schema have been registered
pack_dbs = Pack.get_all()
config_schema_dbs = ConfigSchema.get_all()
self.assertEqual(len(pack_dbs), 1)
self.assertEqual(len(config_schema_dbs), 1)
self.assertEqual(pack_dbs[0].name, 'dummy_pack_1')
self.assertEqual(len(pack_dbs[0].contributors), 2)
self.assertEqual(pack_dbs[0].contributors[0], 'John Doe1 <[email protected]>')
self.assertEqual(pack_dbs[0].contributors[1], 'John Doe2 <[email protected]>')
self.assertTrue('api_key' in config_schema_dbs[0].attributes)
self.assertTrue('api_secret' in config_schema_dbs[0].attributes)
开发者ID:Pulsant,项目名称:st2,代码行数:27,代码来源:test_resource_registrar.py
示例10: test_register_configs_for_all_packs
def test_register_configs_for_all_packs(self):
# Verify DB is empty
pack_dbs = Pack.get_all()
config_dbs = Config.get_all()
self.assertEqual(len(pack_dbs), 0)
self.assertEqual(len(config_dbs), 0)
registrar = ConfigsRegistrar(use_pack_cache=False)
registrar._pack_loader.get_packs = mock.Mock()
registrar._pack_loader.get_packs.return_value = {"dummy_pack_1": PACK_PATH}
packs_base_paths = content_utils.get_packs_base_paths()
registrar.register_configs_for_all_packs(base_dirs=packs_base_paths)
# Verify pack and schema have been registered
pack_dbs = Pack.get_all()
config_dbs = Config.get_all()
self.assertEqual(len(pack_dbs), 1)
self.assertEqual(len(config_dbs), 1)
config_db = config_dbs[0]
self.assertEqual(config_db.values["api_key"], "{{user.api_key}}")
self.assertEqual(config_db.values["api_secret"], "{{user.api_secret}}")
self.assertEqual(config_db.values["region"], "us-west-1")
开发者ID:costingalan,项目名称:st2,代码行数:25,代码来源:test_configs_registrar.py
示例11: test_register_pack_pack_ref
def test_register_pack_pack_ref(self):
# Verify DB is empty
pack_dbs = Pack.get_all()
self.assertEqual(len(pack_dbs), 0)
registrar = ResourceRegistrar(use_pack_cache=False)
registrar._pack_loader.get_packs = mock.Mock()
registrar._pack_loader.get_packs.return_value = {
'dummy_pack_1': PACK_PATH_1,
'dummy_pack_6': PACK_PATH_6
}
packs_base_paths = content_utils.get_packs_base_paths()
registrar.register_packs(base_dirs=packs_base_paths)
# Ref is provided
pack_db = Pack.get_by_name('dummy_pack_6')
self.assertEqual(pack_db.ref, 'dummy_pack_6_ref')
self.assertEqual(len(pack_db.contributors), 0)
# Ref is not provided, directory name should be used
pack_db = Pack.get_by_name('dummy_pack_1')
self.assertEqual(pack_db.ref, 'dummy_pack_1')
# "ref" is not provided, but "name" is
registrar._register_pack_db(pack_name=None, pack_dir=PACK_PATH_7)
pack_db = Pack.get_by_name('dummy_pack_7_name')
self.assertEqual(pack_db.ref, 'dummy_pack_7_name')
# "ref" is not provided and "name" contains invalid characters
expected_msg = 'contains invalid characters'
self.assertRaisesRegexp(ValueError, expected_msg, registrar._register_pack_db,
pack_name=None, pack_dir=PACK_PATH_8)
开发者ID:nzlosh,项目名称:st2,代码行数:34,代码来源:test_resource_registrar.py
示例12: _setup_pack_virtualenv
def _setup_pack_virtualenv(self, pack_name, update=False):
"""
Setup virtual environment for the provided pack.
:param pack_name: Pack name.
:type pack_name: ``str``
"""
# Prevent directory traversal by whitelisting allowed characters in the
# pack name
if not re.match(PACK_NAME_WHITELIST, pack_name):
raise ValueError('Invalid pack name "%s"' % (pack_name))
self.logger.debug('Setting up virtualenv for pack "%s"' % (pack_name))
virtualenv_path = os.path.join(self._base_virtualenvs_path, quote_unix(pack_name))
# Ensure pack directory exists in one of the search paths
pack_path = get_pack_directory(pack_name=pack_name)
if not pack_path:
packs_base_paths = get_packs_base_paths()
search_paths = ', '.join(packs_base_paths)
msg = 'Pack "%s" is not installed. Looked in: %s' % (pack_name, search_paths)
raise Exception(msg)
if not os.path.exists(self._base_virtualenvs_path):
os.makedirs(self._base_virtualenvs_path)
# If we don't want to update, or if the virtualenv doesn't exist, let's create it.
if not update or not os.path.exists(virtualenv_path):
# 0. Delete virtual environment if it exists
self._remove_virtualenv(virtualenv_path=virtualenv_path)
# 1. Create virtual environment
self.logger.debug('Creating virtualenv for pack "%s" in "%s"' %
(pack_name, virtualenv_path))
self._create_virtualenv(virtualenv_path=virtualenv_path)
# 2. Install base requirements which are common to all the packs
self.logger.debug('Installing base requirements')
for requirement in BASE_PACK_REQUIREMENTS:
self._install_requirement(virtualenv_path=virtualenv_path,
requirement=requirement)
# 3. Install pack-specific requirements
requirements_file_path = os.path.join(pack_path, 'requirements.txt')
has_requirements = os.path.isfile(requirements_file_path)
if has_requirements:
self.logger.debug('Installing pack specific requirements from "%s"' %
(requirements_file_path))
self._install_requirements(virtualenv_path, requirements_file_path)
else:
self.logger.debug('No pack specific requirements found')
self.logger.debug('Virtualenv for pack "%s" successfully %s in "%s"' %
(pack_name,
'updated' if update else 'created',
virtualenv_path))
开发者ID:automotola,项目名称:st2,代码行数:59,代码来源:setup_virtualenv.py
示例13: run
def run(self, pack):
"""
:param pack: Installed Pack Name to get info about
:type pack: ``str``
"""
packs_base_paths = get_packs_base_paths()
pack_path = None
metadata_file = None
for packs_base_path in packs_base_paths:
pack_path = os.path.join(packs_base_path, pack)
pack_yaml_path = os.path.join(pack_path, MANIFEST_FILE_NAME)
if os.path.isfile(pack_yaml_path):
metadata_file = pack_yaml_path
break
# Pack doesn't exist, finish execution normally with empty metadata
if not os.path.isdir(pack_path):
return {
'pack': None,
'git_status': None
}
if not metadata_file:
error = ('Pack "%s" doesn\'t contain pack.yaml file.' % (pack))
raise Exception(error)
try:
details = self._parse_yaml_file(metadata_file)
except Exception as e:
error = ('Pack "%s" doesn\'t contain a valid pack.yaml file: %s' % (pack, str(e)))
raise Exception(error)
try:
repo = Repo(pack_path)
git_status = "Status:\n%s\n\nRemotes:\n%s" % (
repo.git.status().split('\n')[0],
"\n".join([remote.url for remote in repo.remotes])
)
ahead_behind = repo.git.rev_list(
'--left-right', '--count', 'HEAD...origin/master'
).split()
# Dear god.
if ahead_behind != [u'0', u'0']:
git_status += "\n\n"
git_status += "%s commits ahead " if ahead_behind[0] != u'0' else ""
git_status += "and " if u'0' not in ahead_behind else ""
git_status += "%s commits behind " if ahead_behind[1] != u'0' else ""
git_status += "origin/master."
except InvalidGitRepositoryError:
git_status = None
return {
'pack': details,
'git_status': git_status
}
开发者ID:Plexxi,项目名称:st2,代码行数:58,代码来源:get_installed.py
示例14: test_register_pack_invalid_config_schema_invalid_attribute
def test_register_pack_invalid_config_schema_invalid_attribute(self):
registrar = ResourceRegistrar(use_pack_cache=False, fail_on_failure=True)
registrar._pack_loader.get_packs = mock.Mock()
registrar._pack_loader.get_packs.return_value = {'dummy_pack_18': PACK_PATH_18}
packs_base_paths = content_utils.get_packs_base_paths()
expected_msg = r'Additional properties are not allowed \(\'invalid\' was unexpected\)'
self.assertRaisesRegexp(ValueError, expected_msg, registrar.register_packs,
base_dirs=packs_base_paths)
开发者ID:nzlosh,项目名称:st2,代码行数:9,代码来源:test_resource_registrar.py
示例15: test_register_pack_invalid_python_versions_attribute
def test_register_pack_invalid_python_versions_attribute(self):
registrar = ResourceRegistrar(use_pack_cache=False, fail_on_failure=True)
registrar._pack_loader.get_packs = mock.Mock()
registrar._pack_loader.get_packs.return_value = {'dummy_pack_21': PACK_PATH_21}
packs_base_paths = content_utils.get_packs_base_paths()
expected_msg = r"'4' is not one of \['2', '3'\]"
self.assertRaisesRegexp(ValueError, expected_msg, registrar.register_packs,
base_dirs=packs_base_paths)
开发者ID:nzlosh,项目名称:st2,代码行数:9,代码来源:test_resource_registrar.py
示例16: test_register_pack_empty_and_invalid_config_schema
def test_register_pack_empty_and_invalid_config_schema(self):
registrar = ResourceRegistrar(use_pack_cache=False, fail_on_failure=True)
registrar._pack_loader.get_packs = mock.Mock()
registrar._pack_loader.get_packs.return_value = {'dummy_pack_17': PACK_PATH_17}
packs_base_paths = content_utils.get_packs_base_paths()
expected_msg = 'Config schema ".*?dummy_pack_17/config.schema.yaml" is empty and invalid.'
self.assertRaisesRegexp(ValueError, expected_msg, registrar.register_packs,
base_dirs=packs_base_paths)
开发者ID:nzlosh,项目名称:st2,代码行数:9,代码来源:test_resource_registrar.py
示例17: test_get_pack_base_paths
def test_get_pack_base_paths(self):
cfg.CONF.content.system_packs_base_path = ''
cfg.CONF.content.packs_base_paths = '/opt/path1'
result = get_packs_base_paths()
self.assertEqual(result, ['/opt/path1'])
# Multiple paths, no trailing colon
cfg.CONF.content.packs_base_paths = '/opt/path1:/opt/path2'
result = get_packs_base_paths()
self.assertEqual(result, ['/opt/path1', '/opt/path2'])
# Multiple paths, trailing colon
cfg.CONF.content.packs_base_paths = '/opt/path1:/opt/path2:'
result = get_packs_base_paths()
self.assertEqual(result, ['/opt/path1', '/opt/path2'])
# Multiple same paths
cfg.CONF.content.packs_base_paths = '/opt/path1:/opt/path2:/opt/path1:/opt/path2'
result = get_packs_base_paths()
self.assertEqual(result, ['/opt/path1', '/opt/path2'])
# Assert system path is always first
cfg.CONF.content.system_packs_base_path = '/opt/system'
cfg.CONF.content.packs_base_paths = '/opt/path2:/opt/path1'
result = get_packs_base_paths()
self.assertEqual(result, ['/opt/system', '/opt/path2', '/opt/path1'])
# More scenarios
orig_path = cfg.CONF.content.system_packs_base_path
cfg.CONF.content.system_packs_base_path = '/tests/packs'
names = [
'test_pack_1',
'test_pack_2',
'ma_pack'
]
for name in names:
actual = get_pack_base_path(pack_name=name)
expected = os.path.join(cfg.CONF.content.system_packs_base_path,
name)
self.assertEqual(actual, expected)
cfg.CONF.content.system_packs_base_path = orig_path
开发者ID:nzlosh,项目名称:st2,代码行数:44,代码来源:test_content_utils.py
示例18: post
def post(self, pack_register_request):
if pack_register_request and hasattr(pack_register_request, 'types'):
types = pack_register_request.types
if 'all' in types:
types = PackRegisterController.CONTENT_TYPES
else:
types = PackRegisterController.CONTENT_TYPES
if pack_register_request and hasattr(pack_register_request, 'packs'):
packs = list(set(pack_register_request.packs))
else:
packs = None
result = defaultdict(int)
# Register depended resources (actions depend on runners, rules depend on rule types, etc)
if ('runner' in types or 'runners' in types) or ('action' in types or 'actions' in types):
result['runners'] = runners_registrar.register_runners(experimental=True)
if ('rule_type' in types or 'rule_types' in types) or \
('rule' in types or 'rules' in types):
result['rule_types'] = rule_types_registrar.register_rule_types()
if ('policy_type' in types or 'policy_types' in types) or \
('policy' in types or 'policies' in types):
result['policy_types'] = policies_registrar.register_policy_types(st2common)
use_pack_cache = False
fail_on_failure = getattr(pack_register_request, 'fail_on_failure', True)
for type, (Registrar, name) in six.iteritems(ENTITIES):
if type in types or name in types:
registrar = Registrar(use_pack_cache=use_pack_cache,
use_runners_cache=True,
fail_on_failure=fail_on_failure)
if packs:
for pack in packs:
pack_path = content_utils.get_pack_base_path(pack)
try:
registered_count = registrar.register_from_pack(pack_dir=pack_path)
result[name] += registered_count
except ValueError as e:
# Throw more user-friendly exception if requsted pack doesn't exist
if re.match('Directory ".*?" doesn\'t exist', six.text_type(e)):
msg = 'Pack "%s" not found on disk: %s' % (pack, six.text_type(e))
raise ValueError(msg)
raise e
else:
packs_base_paths = content_utils.get_packs_base_paths()
registered_count = registrar.register_from_packs(base_dirs=packs_base_paths)
result[name] += registered_count
return result
开发者ID:nzlosh,项目名称:st2,代码行数:53,代码来源:packs.py
示例19: validate_action
def validate_action(action_api):
runner_db = _get_runner_model(action_api)
# Check if pack is valid.
if not _is_valid_pack(action_api.pack):
packs_base_paths = get_packs_base_paths()
packs_base_paths = ','.join(packs_base_paths)
msg = ('Content pack "%s" is not found or doesn\'t contain actions directory. '
'Searched in: %s' %
(action_api.pack, packs_base_paths))
raise ValueValidationException(msg)
# Check if parameters defined are valid.
_validate_parameters(action_api.parameters, runner_db.runner_parameters)
开发者ID:BlazeMediaGroup,项目名称:st2,代码行数:14,代码来源:action.py
示例20: test_register_pack_old_style_non_semver_version_is_normalized_to_valid_version
def test_register_pack_old_style_non_semver_version_is_normalized_to_valid_version(self):
# Verify DB is empty
pack_dbs = Pack.get_all()
self.assertEqual(len(pack_dbs), 0)
registrar = ResourceRegistrar(use_pack_cache=False)
registrar._pack_loader.get_packs = mock.Mock()
registrar._pack_loader.get_packs.return_value = {'dummy_pack_11': PACK_PATH_11}
packs_base_paths = content_utils.get_packs_base_paths()
registrar.register_packs(base_dirs=packs_base_paths)
# Non-semver valid version 0.2 should be normalize to 0.2.0
pack_db = Pack.get_by_name('dummy_pack_11')
self.assertEqual(pack_db.version, '0.2.0')
开发者ID:peak6,项目名称:st2,代码行数:14,代码来源:test_resource_registrar.py
注:本文中的st2common.content.utils.get_packs_base_paths函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论