标签:NPU https 化运维 执行 自动 tps url 版本号 embed
1 # coding = utf-8 2 import os 3 if os.getuid()== 0: 4 pass 5 else: 6 print ‘当前用户不是root用户,请以root用户执行脚本‘ 7 sys.exit(1) 8 version = raw_input(‘请输入你想安装的Python版本(2.7/3.6)‘) 9 if version == ‘2.7‘: 10 url = ‘https://www.python.org/ftp/python/2.7.15/python-2.7.15.amd64-pdb.zip‘ 11 elif version == ‘3.6‘: 12 url = ‘https://www.python.org/ftp/python/3.6.5/python-3.6.5-embed-amd64.zip‘ 13 else: 14 print ‘你输入的版本号有误,请输入2.7或3.6‘ 15 sys.exit(1) 16 17 cmd = ‘wget ‘+url 18 res = os.system(cmd) 19 if res != 0: 20 print ‘下载源码失败,请检查网络‘ 21 sys.exit(1) 22 if version == ‘2.7‘: 23 package_name = ‘Python-2.7.15‘ 24 else : 25 package_name = ‘Python-3.6.5‘ 26 cmd = ‘tar xf ‘+package_name+‘.tgz‘ 27 res = os.system(cmd) 28 if res != 0: 29 os.system(‘rm ‘+package_name+‘.tgz‘) 30 print ‘解压源码包失败。请重新下载‘ 31 sys.exit(1) 32 cmd = ‘cd ‘+package_name+‘ && ./configure --prefix=/usr/local/python && make install‘ 33 res = os.system(cmd) 34 if res != 0: 35 print ‘编译Python源码失败,请检查是否缺少依赖库‘ 36 sys.exit(1)
标签:NPU https 化运维 执行 自动 tps url 版本号 embed
原文地址:https://www.cnblogs.com/leo2li/p/9067291.html