【python】 学习python后,写的第一个实用的python发布脚本

960阅读 1评论2015-03-19 ykyx00
分类:Python/Ruby


点击(此处)折叠或打开

  1. #!/usr/bin/python
  2. #coding:utf-8

  3. ### 导入模块
  4. import time
  5. import os
  6. import shutil

  7. #定义变量
  8. date = time.strftime("%m%d")
  9. src1 = "/root/"+date+"/WebContent"
  10. src2 = "/root/"+date+"/yiren.war"
  11. src3 = "/root/default-web.xml"
  12. src4 = "/root/domain.xml"
  13. comm1 = "\cp -rf " +src1 +" /opt/nginx/"
  14. comm2 = "asadmin -W /etc/gf.pass deploy "+src2
  15. dst = "/tmp"

  16. #print "today is:", date

  17. if os.path.exists(src1):
  18. # shutil.copy(src1, dst)
  19.     os.system(comm1)
  20.     print "statis is OK!"
  21. else:
  22.     print "static is not deploy!"
  23. if os.path.exists(src2):
  24.     os.system('asadmin -W /etc/gf.pass undeploy yiren')
  25.     os.system(comm2)
  26.     shutil.copy(src3, "/usr/local/glassfish3/glassfish/domains/yiren/config/")
  27.     shutil.copy(src4, "/usr/local/glassfish3/glassfish/domains/yiren/config/")
  28.     os.system('asadmin restart-domain')
  29.     print "deploy sucessfull"
  30. else:
  31.     print "nothing to do !"




上一篇:Chrome浏览器保存了我们哪些信息?
下一篇:python格式化字符串和转义字符

文章评论