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)