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


Python Paths.base_dir方法代码示例

本文整理汇总了Python中scripts.core.base.Paths.base_dir方法的典型用法代码示例。如果您正苦于以下问题:Python Paths.base_dir方法的具体用法?Python Paths.base_dir怎么用?Python Paths.base_dir使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在scripts.core.base.Paths的用法示例。


在下文中一共展示了Paths.base_dir方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: do_work

# 需要导入模块: from scripts.core.base import Paths [as 别名]
# 或者: from scripts.core.base.Paths import base_dir [as 别名]
def do_work(parser, args=None, debug=False):
    """
    :type args: list
    :type parser: utils.argparser.ArgParser
    """

    # parse arguments
    global arg_options, arg_others, arg_rest, debug_mode
    arg_options, arg_others, arg_rest = parser.parse(args)
    debug_mode = debug

    # configure path
    Paths.format = PathFormat.ABSOLUTE
    Paths.base_dir('' if not arg_options.root else arg_options.root)

    # check commands
    if len(arg_rest) == 0:
        parser.exit_usage('no MPI executable provided', exit_code=1)

    if len(arg_rest) == 1:
        parser.exit_usage('no executable provided', exit_code=2)

    # turn on dynamic messages if batch is not set
    Printer.dynamic_output = not arg_options.batch

    # # run local or pbs mode
    if arg_options.queue:
        return run_pbs_mode(debug)
    else:
        return run_local_mode(debug)
开发者ID:andrew-c-esp,项目名称:Flow123d-python-utils,代码行数:32,代码来源:exec_parallel_module.py

示例2: do_work

# 需要导入模块: from scripts.core.base import Paths [as 别名]
# 或者: from scripts.core.base.Paths import base_dir [as 别名]
def do_work(parser, args=None, debug=False):
    """
    :type parser: utils.argparser.ArgParser
    """

    # parse arguments
    global arg_options, arg_others, arg_rest
    arg_options, arg_others, arg_rest = parser.parse(args)
    Paths.format = PathFormat.ABSOLUTE
    Paths.base_dir('' if not arg_options.root else arg_options.root)

    # configure printer
    Printer.batch_output = arg_options.batch
    Printer.dynamic_output = not arg_options.batch

    # we need flow123d, mpiexec and ndiff to exists in LOCAL mode
    if not arg_options.queue and not Paths.test_paths('flow123d', 'mpiexec', 'ndiff'):
        Printer.err('Missing obligatory files! Exiting')
        GlobalResult.error = "missing obligatory files"
        sys.exit(1)

    # test yaml args
    if not arg_others:
        parser.exit_usage('Error: No yaml files or folder given')
        GlobalResult.error = "no yaml files or folder given"
        sys.exit(2)

    all_yamls = list()
    for path in arg_others:
        if not Paths.exists(path):
            Printer.err('Error! given path does not exists, ignoring path "{}"', path)
            GlobalResult.error = "path does not exist"
            sys.exit(3)

        if Paths.is_dir(path):
            all_yamls.extend(Paths.walk(path, filters=[
                PathFilters.filter_type_is_file(),
                PathFilters.filter_ext('.yaml'),
                PathFilters.filter_not(PathFilters.filter_name('config.yaml'))
            ]))
        else:
            all_yamls.append(path)

    Printer.out("Found {} .yaml file/s", len(all_yamls))
    if not all_yamls:
        Printer.wrn('Warning! No yaml files found in locations: \n  {}', '\n  '.join(arg_others))
        GlobalResult.error = "no yaml files or folders given"
        sys.exit(3)

    configs = read_configs(all_yamls)
    configs.update(
        proc=arg_options.cpu,
        time_limit=arg_options.time_limit,
        memory_limit=arg_options.memory_limit,
    )

    if arg_options.queue:
        Printer.out('Running in PBS mode')
        return run_pbs_mode(configs, debug)
    else:
        Printer.out('Running in LOCAL mode')
        return run_local_mode(configs, debug)
开发者ID:andrew-c-esp,项目名称:Flow123d-python-utils,代码行数:64,代码来源:runtest_module.py

示例3: check_modules

# 需要导入模块: from scripts.core.base import Paths [as 别名]
# 或者: from scripts.core.base.Paths import base_dir [as 别名]
parser.add('-m', '--limit-memory', type=float, name='memory_limit', placeholder='<memory>', docs=[
    'Optional memory limit per node in MB',
    'For precision use float value'
])
parser.add('', '--root', hidden=True, type=str, name='root', placeholder='<ROOT>', docs=[
    'Path to base dir of flow123d'
])
parser.add('', '--json', hidden=True, type=str, name='json', placeholder='<JSON>', docs=[
    'Output result to json file'
])
# ----------------------------------------------

if __name__ == '__main__':
    from utils.globals import check_modules

    required = ('psutil', 'yaml', 'shutil', 'importlib', 'platform')
    if not check_modules(*required):
        sys.exit(1)

    from scripts.core.execution import BinExecutor
    from scripts.runtest_module import do_work
    #
    # # for debug only set dir to where script should be
    Paths.base_dir(__file__)

    # run work
    BinExecutor.register_sigint()
    do_work(parser)
    if parser.simple_options.json:
        GlobalResult.to_json(parser.simple_options.json)
开发者ID:andrew-c-esp,项目名称:Flow123d-python-utils,代码行数:32,代码来源:runtest.py


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