码迷,mamicode.com
首页 > 编程语言 > 详细

python 提交SVN 写更新日志

时间:2014-07-05 19:55:48      阅读:278      评论:0      收藏:0      [点我收藏+]

标签:style   blog   color   os   cti   for   

SCENE = "mjdy_dyhry"

DIRS = {
"md5/scenes/" + SCENE,
"data/tex/scenes/" + SCENE,
"data/tex/share",
"data/mesh/scenes/" + SCENE,
}

import os

WORKSPACE = "D:/workspace/muData/"#os.getcwd()+

# execute command, and return the output
def execCmd(cmd):
    r = os.popen(cmd)
    text = r.read()
    r.close()
    return text
# write "data" to file-filename
def writeFile(filename, data):
    f = open(filename, "w")
    f.write(data)
    f.close()
    
def svnCommit(targetDir):
    cmd = "svn up \"%s\" --non-interactive -q"
    logtext = execCmd(cmd% targetDir) + "\n"
    cmd = "svn add \"%s\" --force"
    logtext += execCmd(cmd% targetDir) + "\n"
    cmd = "svn commit \"%s\" -m ‘Auto_Commit‘"
    logtext += execCmd(cmd% targetDir) + "\n"
    return logtext
    
def updateAll():
    logtext = ""
    for key in DIRS:
        logtext += svnCommit(WORKSPACE + key)
    print logtext
    return logtext

import re
import time

def filter(text):
    vec = text.split("\n")
    rs = ""
    for line in vec:
        print line
        if re.match( rSending*, line, re.M|re.I):
            rs += line + "\n"
        elif re.match( rAdding*, line, re.M|re.I):
            rs += line + "\n"
    return rs
    
info = updateAll()
loginfo = filter(info)
if not os.path.exists("loghistory"):
    os.mkdir("loghistory")

curtime = time.strftime("%Y-%m-%d-%H_%M_%S", time.localtime(time.time())) + ".txt"

logfile = "loghistory/" + curtime
writeFile(logfile, loginfo)
if(len(loginfo) > 8):
    execCmd("loghistory\\" + curtime)

 

python 提交SVN 写更新日志,布布扣,bubuko.com

python 提交SVN 写更新日志

标签:style   blog   color   os   cti   for   

原文地址:http://www.cnblogs.com/tary-hit/p/3822674.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!