jumpserver/apps/assets/resources/platform/__init__.py

31 lines
833 B
Python
Raw Normal View History

2022-08-29 02:49:53 +00:00
import os
import yaml
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
2022-08-29 07:50:25 +00:00
platform_ops_methods = None
2022-08-29 02:49:53 +00:00
def get_platform_methods():
methods = []
for root, dirs, files in os.walk(BASE_DIR, topdown=False):
for name in dirs:
path = os.path.join(root, name)
rel_path = path.replace(BASE_DIR, '.')
2022-08-30 02:07:03 +00:00
if len(rel_path.split('/')) != 3:
2022-08-29 02:49:53 +00:00
continue
manifest_path = os.path.join(path, 'manifest.yml')
if not os.path.exists(manifest_path):
continue
f = open(manifest_path, 'r')
try:
manifest = yaml.safe_load(f)
except yaml.YAMLError as e:
continue
methods.append(manifest)
return methods
2022-08-30 02:07:03 +00:00
if __name__ == '__main__':
print(get_platform_methods())