首页 > 代码库 > python 提交SVN 写更新日志

python 提交SVN 写更新日志

SCENE = "mjdy_dyhry"DIRS = {"md5/scenes/" + SCENE,"data/tex/scenes/" + SCENE,"data/tex/share","data/mesh/scenes/" + SCENE,}import osWORKSPACE = "D:/workspace/muData/"#os.getcwd()+# execute command, and return the outputdef execCmd(cmd):    r = os.popen(cmd)    text = r.read()    r.close()    return text# write "data" to file-filenamedef 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 logtextimport reimport timedef 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/" + curtimewriteFile(logfile, loginfo)if(len(loginfo) > 8):    execCmd("loghistory\\" + curtime)