Python学习—— 导出SVN中指定版本后增加的资源
来源:互联网 发布:互联网金融数据库 编辑:程序博客网 时间:2024/06/09 17:23
<pre name="code" class="python">#清除文件夹下所有文件def cleanAllFiles(rootdir): if not os.path.isdir(rootdir): return; filelist=os.listdir(rootdir) for f in filelist: filepath = os.path.join( rootdir, f ) if os.path.isfile(filepath): os.remove(filepath) print(filepath+" removed!") elif os.path.isdir(filepath): shutil.rmtree(filepath,True) print("dir "+filepath+" removed!")
第一步首先要清空导出到的文件夹
#更新SVN文件信息def updateSvnInfo(svnUrl,localSvnInfoPath): command ='svn info ' + svnUrl +' -R --xml > ' + localSvnInfoPath; print("localSvnInfoPath:" + localSvnInfoPath); print("svnUrl:" + svnUrl); print("svn info update.....Please wait for a while") os.system(command)
第二步需要更新svn信息到本地 以用作下一步比较(先确保SVN安装了命令行环境svn help *安装时候要自动点选)
#导出指定版本之上新增资源#指定版本,输出文件夹路径,SVN版本数据def importVersion(lastVersion,outPutPath,localSvnInfoPath): dom = xml.dom.minidom.parse(localSvnInfoPath); root = dom.documentElement itemlist = root.getElementsByTagName('entry') for item in itemlist: filetype = item.getAttribute("kind"); path = item.getAttribute("path"); commitInfo = item.getElementsByTagName("commit"); vsn = int(commitInfo[0].getAttribute("revision")); if(vsn > lastVersion): if(filetype == "file"): itemInfo = item.getElementsByTagName("url")[0]; itemUrl = itemInfo.childNodes[0].nodeValue; pos = path.rfind("\\") dirUrl = path[:pos] print("dirUrl:" + dirUrl); if not os.path.isdir(outPutPath +"\\" + dirUrl): os.makedirs(outPutPath + "\\" + dirUrl) command = "svn export " + itemUrl + " " + outPutPath + "\\" + dirUrl; os.system(command)
第三步就可以导出指定版本以上的资源了
如果出现中文路径出错可以在 Python27\Lib\site-packages 下放置sitecustomize.py
import syssys.setdefaultencoding('utf-8')或者在代码中对中文路径处理
type = sys.getfilesystemencoding()svnGamePath = ("http://192.168.7.126:8080//svn//游戏//联运//客户端//Yxzg").decode('utf-8').encode(type)
0 0
- Python学习—— 导出SVN中指定版本后增加的资源
- svn版本库管理--版本库中指定版本的删除
- svn版本库管理--版本库中指定版本的删除
- 删除svn中指定的文件以及合并svn版本库
- 导出ORACLE中指定的程序包\视图等.
- 用svn下载github中指定目录的文件
- maven中指定jdk版本
- 抓取网页中指定节点的内容(java版本)
- <head>中指定解析document使用的浏览器版本
- 读出文件文件中指定字符后的字符串
- 正则 字符串中指定增加字符串
- 如何用python读取文本中指定行的内容
- python 使用-读取文件、替换文件中指定的内容
- 4、CRM2011编程实战——将窗体中指定控件的值做处理后更新到另一个字段中
- 根据资源路径加载ZIP压缩包中指定的资源
- 根据资源路径加载ZIP压缩包中指定的资源
- ionic 命令行中指定模拟器版本
- SVN版本库的导出
- 网站整理
- Service和Activity通讯的3种常用方式示例
- JavaScript弹出框
- string变为wstring
- 浏览器探究——webkit部分——http请求
- Python学习—— 导出SVN中指定版本后增加的资源
- 黑马程序员_字符串操作总结
- SIFT特征提取分析
- 网络交互的方法
- Java File类部分属性
- 浅析Sql Server参数化查询
- Service详解
- 【9018p1407】拦截导弹(二分)
- poj 1753 Flip Game