# -*- coding:utf-8 -*-
import subprocess
import xml.dom.minidom
ST_MISSING = "missing"
ST_MODIFIED = "modified"
ST_UNVERSIONED = "unversioned"
cmds = {ST_MISSING :"svn del \"{}\"",ST_UNVERSIONED:"svn add \"{}\""}
def runCmd(command):
ret = subprocess.run(command,shell=True,stdout=subprocess.PIPE,stderr=subprocess.PIPE,timeout=1)
return ret
def svnCommit():
ret = runCmd("svn status --xml")
DOMTree = xml.dom.minidom.parseString(ret.stdout)
collection = DOMTree.documentElement
es = collection.getElementsByTagName("entry")
for entry in es:
statusNode = entry.getElementsByTagName("wc-status")[0]
filePath = entry.getAttribute("path")
status=statusNode.getAttribute("item")
# print(filePath + " = " + status)
if status in cmds:
cmd = cmds[status].format(filePath)
print(cmd)
runCmd(cmd)
runCmd("svn commit -m \"auto commit by python\" ")
svnCommit()
通过python获取svn状态
_Bruce2023-10-28 21:56
相关推荐
a0023450016 分钟前
python类型转换&深浅拷贝星石传说13 分钟前
python绘制年平均海表温度、盐度、ph分布图丁总学Java37 分钟前
Cannot deserialize instance of java.lang.String out of START_ARRAY token魔道不误砍柴功3 小时前
Java中的Stream API:从入门到实战xinghuitunan4 小时前
时间转换(acwing)c/c++/java/pythontekin4 小时前
Python 高级数据结构操作全解析:从理论到实践关关钧4 小时前
【R语言】绘图m0_748248025 小时前
爬虫自动化(DrissionPage)量化投资技术5 小时前
【量化科普】Arbitrage,套利量化投资技术5 小时前
【量化科普】Liquidity,流动性