fix: 修复playbook部分不可执行问题

pull/12138/head
Aaron3S 2023-11-15 15:20:02 +08:00 committed by Bryan
parent 23fce9e426
commit 44f029774d
1 changed files with 14 additions and 9 deletions

View File

@ -40,11 +40,16 @@ class Playbook(JMSOrgBaseModel):
result = []
for root, dirs, files in os.walk(self.work_dir):
for f in files:
try:
if str(f).endswith('.yml') or str(f).endswith('.yaml'):
lines = self.search_keywords(os.path.join(root, f))
if len(lines) > 0:
for line in lines:
result.append({'file': f, 'line': line[0], 'keyword': line[1]})
# 遇到无法读取的文件,跳过
except UnicodeEncodeError:
continue
return result
@staticmethod