本文整理汇总了Python中scripts.core.base.Paths.temp_file方法的典型用法代码示例。如果您正苦于以下问题:Python Paths.temp_file方法的具体用法?Python Paths.temp_file怎么用?Python Paths.temp_file使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类scripts.core.base.Paths
的用法示例。
在下文中一共展示了Paths.temp_file方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from scripts.core.base import Paths [as 别名]
# 或者: from scripts.core.base.Paths import temp_file [as 别名]
def __init__(self, o, config):
o = ConfigBase.merge(DEFAULTS, deepcopy(o))
self.file = o.get('file', None)
self.proc = int(o.get('proc', None))
self.time_limit = float(o.get('time_limit', None))
self.memory_limit = float(o.get('memory_limit', None))
self.tags = set(o.get('tags', None))
self.check_rules = o.get('check_rules', None)
self.config = config
if self.config:
self.file = Paths.join(self.config.root, self.file)
self.without_ext = Paths.basename(Paths.without_ext(self.file))
self.shortname = '{name}.{proc}'.format(name=self.without_ext, proc=self.proc)
self.fs = ConfigCaseFiles(
root=self.config.root,
ref_output=Paths.join(self.config.root, 'ref_output', self.without_ext),
output=Paths.join(
self.config.root,
'test_results',
self.shortname
))
else:
# create temp folder where files will be
tmp_folder = Paths.temp_file(o.get('tmp') + '-{date}-{time}-{rnd}')
Paths.ensure_path(tmp_folder, is_file=False)
self.fs = ConfigCaseFiles(
root=tmp_folder,
ref_output=tmp_folder,
output=tmp_folder
)
示例2: run_local_mode_one
# 需要导入模块: from scripts.core.base import Paths [as 别名]
# 或者: from scripts.core.base.Paths import temp_file [as 别名]
def run_local_mode_one(self, proc):
"""
Method runs single job with specified number of CPU
:param proc:
"""
if int(proc) == 0:
command = self.rest[1:]
else:
command = [self.rest[0], '-np', proc] + self.rest[1:]
n_lines = 0 if self.arg_options.batch else 10
pypy = PyPy(BinExecutor(command))
# set limits
pypy.limit_monitor.time_limit = self.time_limit
pypy.limit_monitor.memory_limit = self.memory_limit
# catch output to variable
# in batched mode we will keep the files
# otherwise we will keep logs only on error
log_file = Paths.temp_file('exec-parallel-{date}-{time}-{rnd}.log')
pypy.executor.output = OutputMode.variable_output()
pypy.full_output = log_file
# save output to file
pypy.output_monitor.log_file = log_file
# start and wait for exit
pypy.start()
pypy.join()
return pypy
示例3: _run
# 需要导入模块: from scripts.core.base import Paths [as 别名]
# 或者: from scripts.core.base.Paths import temp_file [as 别名]
def _run(self):
"""
Run method for this module
"""
# prepare executor
progress = not self.arg_options.batch
executor = BinExecutor(self.rest)
pypy = PyPy(executor, progress=progress)
n_lines = 0 if self.arg_options.batch else 10
# set up streams
log_file = Paths.temp_file('exec-limit-{date}-{time}-{rnd}.log')
pypy.executor.output = OutputMode.variable_output()
pypy.full_output = log_file
# set limits
pypy.limit_monitor.time_limit = self.arg_options.time_limit
pypy.limit_monitor.memory_limit = self.arg_options.memory_limit
# save output to file
pypy.output_monitor.log_file = log_file
# start process
pypy.start()
pypy.join()
return pypy
示例4: run_local_mode_one
# 需要导入模块: from scripts.core.base import Paths [as 别名]
# 或者: from scripts.core.base.Paths import temp_file [as 别名]
def run_local_mode_one(proc, time_limit, memory_limit):
if proc == 0:
command = arg_rest[1:]
else:
command = [arg_rest[0], '-np', proc] + arg_rest[1:]
n_lines = 0 if arg_options.batch else 10
pypy = PyPy(BinExecutor(command))
# set limits
pypy.limit_monitor.time_limit = time_limit
pypy.limit_monitor.memory_limit = memory_limit
pypy.progress = not arg_options.batch
pypy.info_monitor.deactivate()
pypy.error_monitor.deactivate()
# catch output to variable
# in batch mode we will keep the files
# otherwise we will keep logs only on error
log_file = Paths.temp_file('exec-parallel-{date}-{time}-{rnd}.log')
pypy.executor.output = OutputMode.variable_output()
pypy.full_output = log_file
# start and wait for exit
pypy.start()
pypy.join()
# add result to global json result
GlobalResult.add(pypy)
# in batch mode or on error
if not pypy.with_success() or arg_options.batch:
content = pypy.executor.output.read()
IO.write(log_file, content)
Printer.close()
Printer.out(format_n_lines(content, indent=' ', n_lines=-n_lines))
Printer.open()
return pypy
示例5: do_work
# 需要导入模块: from scripts.core.base import Paths [as 别名]
# 或者: from scripts.core.base.Paths import temp_file [as 别名]
def do_work(parser, args=None):
"""
:type args: list
:type parser: utils.argparser.ArgParser
"""
# parse arguments
options, others, rest = parser.parse(args)
# check commands
if not rest:
parser.exit_usage('No command specified!', exit_code=1)
# check limits (at least one limit must be set)
if (options.time_limit, options.memory_limit) == (None, None):
parser.exit_usage('No limits specified!', exit_code=2)
# prepare executor
executor = BinExecutor(rest)
pypy = PyPy(executor, progress=not options.batch)
# set limits
pypy.error_monitor.message = None
pypy.limit_monitor.time_limit = options.time_limit
pypy.limit_monitor.memory_limit = options.memory_limit
# turn on output
if options.batch:
pypy.info_monitor.stdout_stderr = None
else:
pypy.info_monitor.stdout_stderr = Paths.temp_file('exec-limit.log')
# start process
Printer.separator()
pypy.start()
pypy.join()
return pypy.returncode
示例6: __init__
# 需要导入模块: from scripts.core.base import Paths [as 别名]
# 或者: from scripts.core.base.Paths import temp_file [as 别名]
def __init__(self, o, config):
o = ConfigBase.merge(yamlc.DEFAULTS, deepcopy(o))
self.file = o.get(yamlc.TAG_FILES, None)
self.proc = int(o.get(yamlc.TAG_PROC, None))
self.time_limit = float(o.get(yamlc.TAG_TIME_LIMIT, None))
self.memory_limit = float(o.get(yamlc.TAG_MEMORY_LIMIT, None))
self.tags = set(o.get(yamlc.TAG_TAGS, None))
self.check_rules = o.get(yamlc.TAG_CHECK_RULES, None)
self.config = config
if self.config:
self.file = Paths.join(self.config.root, Paths.basename(self.file))
self.without_ext = Paths.basename(Paths.without_ext(self.file))
self.shortname = '{name}.{proc}'.format(
name=self.without_ext, proc=self.proc)
self.fs = yamlc.ConfigCaseFiles(
root=self.config.root,
ref_output=Paths.join(
self.config.root, yamlc.REF_OUTPUT_DIR, self.without_ext),
output=Paths.join(
self.config.root,
yamlc.TEST_RESULTS,
self.shortname
))
else:
# create temp folder where files will be
tmp_folder = Paths.temp_file(o.get('tmp') + '-{date}-{time}-{rnd}')
Paths.ensure_path(tmp_folder, is_file=False)
self.fs = yamlc.ConfigCaseFiles(
root=tmp_folder,
ref_output=tmp_folder,
output=tmp_folder
)