2019-07-06

2019-07-06  本文已影响0人  夏国栋
解析yaml配置文件,找到相关文件,进行权限更改
from yaml import load,Loader
import os


MODULES = ['abc', 'bcd']

def chmod(file_path):
    os.system('/bin/chmod 664 %s' % file_path)

def chmod_link_file(file_name):
    with open(file_name) as f:
    r = load(f, Loader=Loader)
    for i in r['deploy']:
    if i['type'] == 'link':
        path = i['path']
        for fp in i['elements']:
        chmod(os.path.join(path, fp['src']))

def main():
    for module in MODULES:
    yaml_path = '/data/deploy/master/system/productlib/ads/'+module+'lib/env.'+module+'.system.default.yml'
    chmod_link_file(yaml_path)

if __name__ == '__main__':
    main()

上一篇下一篇

猜你喜欢

热点阅读