当前位置: 首页>>代码示例>>Python>>正文


Python Paths.flow123d_root方法代码示例

本文整理汇总了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()
开发者ID:jbrezmorf,项目名称:flow123d,代码行数:27,代码来源:runtest_module.py

示例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
开发者ID:jbrezmorf,项目名称:flow123d,代码行数:49,代码来源:common.py

示例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 {}
开发者ID:jbrezmorf,项目名称:flow123d,代码行数:25,代码来源:artifacts.py


注:本文中的scripts.core.base.Paths.flow123d_root方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。