本文整理汇总了Python中common.Common.list_files方法的典型用法代码示例。如果您正苦于以下问题:Python Common.list_files方法的具体用法?Python Common.list_files怎么用?Python Common.list_files使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类common.Common
的用法示例。
在下文中一共展示了Common.list_files方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: run
# 需要导入模块: from common import Common [as 别名]
# 或者: from common.Common import list_files [as 别名]
def run(self, config_path, input_path, output_path, status_path, status="", test=None, step_id='', step_depth=0):
temp_path = tempfile.mkdtemp(prefix='pipeline-')
tests_run = 0
tests_failed = 0
tests_skipped = 0
pipeline_context_name = os.path.basename(input_path)
padding = (self.location if len(self.steps) == 0 else self.steps[0][list(self.steps[0].keys())[0]]['location']).ljust(20+step_depth*2)
Common.message(padding+'-- Context is: '+pipeline_context_name)
current_input_path = None
current_output_path = None
current_status_path = None
current_status = ''
exit = False
position = 0
step_count = len([ step_object for step_object in self.steps if (list(step_object.keys())[0] != 'test' and list(step_object.keys())[0] != 'assert') ])
if step_count == 0:
current_status = status
current_input_path = input_path
current_output_path = output_path
current_status_path = status_path
if status != None:
Common.write_file(current_status_path+'/status.txt', status)
if os.path.isdir(current_input_path):
for item in os.listdir(current_input_path):
item_fullpath = os.path.join(current_input_path, item)
if os.path.isdir(item_fullpath):
shutil.copytree(item_fullpath, current_output_path+'/'+os.path.basename(item_fullpath))
else:
shutil.copy2(item_fullpath, current_output_path+'/'+os.path.basename(item_fullpath))
else:
shutil.copy2(current_input_path, current_output_path+'/'+os.path.basename(current_input_path))
for step_object in self.steps:
step_type = list(step_object.keys())[0]
step = step_object[step_type]
padding = step['location'].ljust(20+step_depth*2)
if exit or step_type == 'exit':
if step_type == 'exit':
Common.message(padding+'-- Exiting')
exit = True
break
current_status = status if not current_status_path else Common.first_line(current_status_path)
if step_type != 'test' and step_type != 'assert':
current_step_id = step_id+'/'+str(position)
Common.message(padding+'-- Running '+step_type+': '+(step_type if not 'name' in step else step['name']))
if position > 0:
current_input_path = current_output_path
else:
current_input_path = input_path
if position < step_count - 1:
current_output_path = temp_path+"/"+str(position)+"/output"
current_status_path = temp_path+"/"+str(position)+"/status"
os.makedirs(current_output_path)
os.makedirs(current_status_path)
else:
current_output_path = output_path
current_status_path = status_path
if step_type == 'image':
volumes = {}
if config_path:
volumes[config_path] = { 'bind': '/mnt/config', 'mode': 'ro' }
volumes[current_input_path] = { 'bind': '/mnt/input'+('/'+pipeline_context_name if not os.path.isdir(current_input_path) else ''), 'mode': 'ro' }
volumes[current_output_path] = { 'bind': '/mnt/output', 'mode': 'rw' }
volumes[current_status_path] = { 'bind': '/mnt/status', 'mode': 'rw' }
command = None if not 'command' in step else step['command']
Common.docker_run(step['id'], volumes, command=command)
elif step_type == 'choose':
for when in step['choices']:
when_key = list(when.keys())[0]
if (not 'test' in when[when_key]) or when[when_key]['test'] == current_status:
result = when[when_key]['pipeline'].run(config_path, file_or_dir, current_output_path, current_status_path, status=current_status, test=test, step_id=current_step_id, step_depth=step_depth+1)
exit = exit or result['exit']
tests_skipped += result['tests']['skipped']
tests_run += result['tests']['run']
tests_failed += result['tests']['failed']
break
elif step_type == 'foreach':
for file_or_dir in Common.list_files(current_input_path):
result = step['pipeline'].run(config_path, file_or_dir, current_output_path+'/'+os.path.basename(file_or_dir), current_status_path, status=current_status, test=test, step_id=current_step_id, step_depth=step_depth+1)
exit = exit or result['exit']
tests_skipped += result['tests']['skipped']
tests_run += result['tests']['run']
tests_failed += result['tests']['failed']
elif step_type == 'unfold':
prev_paths = []
#.........这里部分代码省略.........