美文网首页
2019-07-06

2019-07-06

作者: 夏国栋 | 来源:发表于2019-07-06 22:14 被阅读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()
    
    

    相关文章

      网友评论

          本文标题:2019-07-06

          本文链接:https://www.haomeiwen.com/subject/ggnmhctx.html