mirror of
https://github.com/jumpserver/jumpserver.git
synced 2025-07-17 16:31:28 +00:00
fix: 修复playbook部分不可执行问题
This commit is contained in:
parent
23fce9e426
commit
44f029774d
@ -40,11 +40,16 @@ class Playbook(JMSOrgBaseModel):
|
|||||||
result = []
|
result = []
|
||||||
for root, dirs, files in os.walk(self.work_dir):
|
for root, dirs, files in os.walk(self.work_dir):
|
||||||
for f in files:
|
for f in files:
|
||||||
|
try:
|
||||||
if str(f).endswith('.yml') or str(f).endswith('.yaml'):
|
if str(f).endswith('.yml') or str(f).endswith('.yaml'):
|
||||||
lines = self.search_keywords(os.path.join(root, f))
|
lines = self.search_keywords(os.path.join(root, f))
|
||||||
if len(lines) > 0:
|
if len(lines) > 0:
|
||||||
for line in lines:
|
for line in lines:
|
||||||
result.append({'file': f, 'line': line[0], 'keyword': line[1]})
|
result.append({'file': f, 'line': line[0], 'keyword': line[1]})
|
||||||
|
# 遇到无法读取的文件,跳过
|
||||||
|
except UnicodeEncodeError:
|
||||||
|
continue
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
Loading…
Reference in New Issue
Block a user