本文整理汇总了Python中scripts.core.base.Paths.flow123d_root方法的典型用法代码示例。如果您正苦于以下问题:Python Paths.flow123d_root方法的具体用法?Python Paths.flow123d_root怎么用?Python Paths.flow123d_root使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类scripts.core.base.Paths
的用法示例。
在下文中一共展示了Paths.flow123d_root方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: list_tests
# 需要导入模块: from scripts.core.base import Paths [as 别名]
# 或者: from scripts.core.base.Paths import flow123d_root [as 别名]
def list_tests():
test_dir = Paths.join(Paths.flow123d_root(), 'tests')
tests = Paths.walk(test_dir, [
PathFilters.filter_type_is_file(),
PathFilters.filter_endswith('.yaml'),
PathFilters.filter_not(PathFilters.filter_name('config.yaml')),
])
result = dict()
for r in tests:
dirname = Paths.dirname(r)
basename = Paths.basename(r)
if Paths.dirname(dirname) != test_dir:
continue
if dirname not in result:
result[dirname] = list()
result[dirname].append(basename)
keys = sorted(result.keys())
for dirname in keys:
Printer.all.out(Paths.relpath(dirname, test_dir))
with Printer.all.with_level(1):
for basename in result[dirname]:
Printer.all.out('{: >4s} {: <40s} {}', '', basename, Paths.relpath(Paths.join(dirname, basename), test_dir))
Printer.all.newline()
示例2: get_pbs_module
# 需要导入模块: from scripts.core.base import Paths [as 别名]
# 或者: from scripts.core.base.Paths import flow123d_root [as 别名]
def get_pbs_module(hostname_hint=None):
"""
file host_table.yaml serves as lookup table when using python script in queue mode
each key is hostname and each value names a module which should be loaded
modules are located in /src/python/scripts/pbs/modules
If no matching key for current machine exists try to use pbs_<hostname>
where all dots(.) are replaced with underscores(_)
if hostname_hint is not set node name will be used
:rtype : scripts.pbs.modules.pbs_tarkil_cesnet_cz
"""
pbs_module_path = None
host_file = Paths.join(Paths.flow123d_root(), 'config', 'host_table.yaml')
host_file_exists = Paths.exists(host_file)
hostname = hostname_hint or platform.node()
from_host = False
# try to get name from json file
if host_file_exists:
with open(host_file, 'r') as fp:
hosts = yaml.load(fp)
pbs_module_path = hosts.get(hostname, None)
from_host = pbs_module_path is not None
if not pbs_module_path:
hostname = hostname.replace('.', '_')
pbs_module_path = 'pbs_{}'.format(hostname)
# construct full path for import
full_module_path = 'scripts.pbs.modules.{module_name}'.format(module_name=pbs_module_path)
# try to get pbs_module
try:
return importlib.import_module(full_module_path)
except ImportError:
Printer.all.err('Could not load module "{}" ({}) for hostname "{}"',
pbs_module_path, full_module_path, hostname)
with Printer.all.with_level(2):
if host_file_exists:
if from_host:
Printer.all.err('Value specified in host_table.yaml "{}" points to non-existing module', pbs_module_path)
else:
Printer.all.err('Config file host_table.yaml does not have entry for hostname "{}"', hostname)
else:
Printer.all.err('Config file host_table.yaml does not exists ({}) and auto module detection failed', host_file)
raise
示例3: parse_yaml
# 需要导入模块: from scripts.core.base import Paths [as 别名]
# 或者: from scripts.core.base.Paths import flow123d_root [as 别名]
def parse_yaml(self):
# register yaml parser tags
from scripts.artifacts.collector import Collector
from scripts.artifacts.command import Command
from scripts.artifacts.modules.mongodb import DatabaseMongo
from scripts.artifacts.modules.lscpu import CommandLSCPU
with open(self.yaml_file, "r") as fp:
yaml_data = fp.read()
yaml_data = strings.replace_placeholders(
yaml_data,
_format_="<{}>",
root=Paths.flow123d_root(),
time=System.time,
date=System.date,
datetime=System.datetime,
rnd8=System.rnd8,
rnd16=System.rnd16,
rnd32=System.rnd32,
rnd=System.rnd,
)
self.configuration = yaml.load(yaml_data) or {}