python 提交SVN 写更新日志

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( r'Sending*', line, re.M|re.I):
            rs += line + "\n"
        elif re.match( r'Adding*', 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)

 

转载于:https://www.cnblogs.com/tary-hit/p/3822674.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值