Python開發Svn_Update指令碼

來源:互聯網
上載者:User

標籤:python開發svn_update指令碼

######## 指令碼需求 ######## 

運行系統:Windows

輸入:路徑 子路徑 使用者名稱 密碼

例子:python svn_update_list.py E:\svn\ data\code,data\asset,data\fight 使用者名稱 密碼

行為:依次在E:\svn\data\code、E:\svn\data\asset、E:\svn\data\fight執行svn update

成功返回成功結束碼和成功資訊、失敗返回失敗結束碼和失敗資訊


######## Script Demo ######## 

#!/usr/bin/env python#coding:utf-8import subprocess,os,sysparentPath = sys.argv[1]        #第一個參數根目錄,如d:\datasubPath = sys.argv[2]           #第二個參數子路徑,如minion1,minion2svnname = sys.argv[3]           #使用者名稱svnpw = sys.argv[4]             #密碼list = subPath.split(",")       #第二個參數以逗號分隔for line in list:               #輪詢第二個參數    path = parentPath + line    #如:d:\data\ + minion1,d:\data\ + minion2,    try:        os.chdir(path)          #切換到svn更新目錄    except Exception,e:        print "###### 1 %s The path does not exist,scripts exit ######" % path        print        print "###### The error message is as follows ######"        print e                sys.exit(1)    else:        print "###### 1 %s switch success ######" % path     #擷取錯誤輸出    mytask = subprocess.Popen(‘svn update --username %s --password %s‘ % (svnname, svnpw),shell=True,stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)       #讀出錯誤資訊並賦值給stdstr變數    stdstr= mytask.stdout.read()         #判斷有沒有輸出錯誤資訊    if ‘svn: E‘ in stdstr:        print "###### 2 %s update fail,scripts exit ######" % path         print        print "###### The error message is as follows ######"        print stdstr        sys.exit(1)    else:        print "###### 2 %s update success ######" % path          print "update finish";


######## Success Execution Demo ######## 

650) this.width=650;" src="http://s4.51cto.com/wyfs02/M02/8B/7B/wKioL1hPntHBEWOfAAAn9d_Rzo8190.png-wh_500x0-wm_3-wmp_4-s_1391012307.png" title="1.png" alt="wKioL1hPntHBEWOfAAAn9d_Rzo8190.png-wh_50" />


######## Error Execution Demo1,Path Error ######## 

650) this.width=650;" src="http://s3.51cto.com/wyfs02/M01/8B/7C/wKioL1hPqO6wO8sCAAAaPrerFjQ822.png-wh_500x0-wm_3-wmp_4-s_648392771.png" title="1.png" alt="wKioL1hPqO6wO8sCAAAaPrerFjQ822.png-wh_50" />


######## Error Execution Demo1,Password Error ######## 

650) this.width=650;" src="http://s1.51cto.com/wyfs02/M02/8B/80/wKiom1hPqinC6fYoAAArCf5AVDM806.png-wh_500x0-wm_3-wmp_4-s_4195262125.png" title="1.png" alt="wKiom1hPqinC6fYoAAArCf5AVDM806.png-wh_50" />


######## Error Execution Demo1,Error update directory ########

650) this.width=650;" src="http://s3.51cto.com/wyfs02/M02/8B/80/wKiom1hPqR3QTvrBAAAeOB1XlLQ191.png-wh_500x0-wm_3-wmp_4-s_3286494675.png" title="2.png" alt="wKiom1hPqR3QTvrBAAAeOB1XlLQ191.png-wh_50" />

本文出自 “wsyht90的部落格” 部落格,請務必保留此出處http://wsyht90.blog.51cto.com/9014030/1882309

Python開發Svn_Update指令碼

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.