背景:

本人在公司的平台部门工作,我们部门写出的代码都是编译成.a文件,定期发布版本到各个产品,现在老大要求我负责每周向公司的某个产品发布lib。发布lib的步骤大概就是自动化的兄弟给我提供一个归档的版本号、lib的标签号(对应我们平台的代码)和产品适配的标签号(对应产品代码,我们的.a文件会定期提交到这个svn下),然后我根据这个信息,操作svn,定期把适配中指定标签下的指定的两个文件夹导出到归档目录下,然后在归档路径下创建记录这次发布信息(lib、适配各包含哪些标签、版本信息)的文档,还有就是创建一个release notes,要大家填写依赖。为了方便记录我还在另一个目录下记录着每次发布的信息。大概就是这样比较机械的操作,作为程序员当然不能甘于每周重复一次这样无趣的操作,于是乎利用今天调休的时间,用python写了个脚本代替这个工作。

主要用到的是python和pysvn(python)的一个第三方库。这里注意下pysvn要和对应版本的python使用才能生效,否则import会失败,所以建议先选pysvn,然后根据版本选python。

软件下载和使用文档:

软件下载:https://www.python.org/getit/

http://pysvn.tigris.org/project_downloads.html

pysvn非常好的官方使用说明文档:http://pysvn.tigris.org/docs/pysvn_prog_ref.html

代码:

import pysvn
import os
import time
import shutil #发布lib时对应的适配代码路径
code_path = "F:/xyp_work";
#lib的归档路径
dest_path = "F:/AR_lib发布";
#自己的备份信息
myself_save_path = "F:/save/备份.txt";
#填写依赖的路径
dependence_path = "F:/依赖";
#维护一个专门记录lib和br标签号的文档用于读取上一次发lib时的标签号
old_num_path = "F:/save/old_num.txt"; #svn 路径
lib_svn = "lib的svn路径"
br_svn = "br的svn路径" #版本号和标签号
#verson = "esap v2R2C00B100";
#lib_num = 2;
#br_num = 7; ###读取上一次的标签号和用户输入的本次lib的标签号和版本号###
print("输入版本号");
verson = input();
print("输入lib的标签号");
lib_num = int(input());
print("输入适配的标签号");
br_num = int(input()); fp = open(old_num_path,"r");
last_lib_num = fp.readline();
last_br_num = fp.readline();
fp.close(); print("last lib num is "+str(last_lib_num));
print("last br num is "+str(last_br_num));
print("current verson is "+str(verson)+"\n");
print("current lib num is "+str(lib_num)+"\n");
print("current br num is "+str(br_num)+"\n");
print("please confirm : y/n"); res=input();
if "y"== res:
print("now start");
else:
exit(); ###################创建文件夹和文件######################
vasp = dest_path+'/'+"vasp";
vaspadp = dest_path + '/' + "vaspadp";
svn_txt = dest_path + '/'+"svn.txt"; isExists=os.path.exists(dest_path);
if not isExists:
os.makedirs(dest_path);
else:
print("AR_lib发布文件夹已存在,看看是否搞错了");
exit(); isExists=os.path.exists(vasp)
if not isExists:
os.makedirs(vasp); isExists=os.path.exists(vaspadp)
if not isExists:
os.makedirs(vaspadp); #svn.txt 
fp = open(svn_txt,"a");
fp.write(verson+"\n");
fp.write((lib_svn+" "+ str(lib_num) +"\n"));
fp.write((br_svn+" "+ str(br_num) +"\n"));
fp.close(); #自己的备份记录
fp = open(myself_save_path,"a");
fp.write("\n");
fp.write("\n");
fp.write("\n");
fp.write(time.strftime("%d/%m/%Y") + "\n");
fp.write(verson+"\n");
fp.write((lib_svn+" "+ str(lib_num) +"\n"));
fp.write((br_svn+" "+ str(br_num) +"\n"));
fp.close(); #依赖文件 复制release notes.xlsx,然后重命名,否则直接创建出来不是共享的
shutil.copyfile(dependence_path+"/release notes.xlsx",dependence_path + "/" + verson+" release notes.xlsx"); #维护一个专门记录lib和br标签号的文档用于读取上一次发lib时的标签号
fp = open(old_num_path,"w");
fp.truncate(); #清除文件内容
fp.write(str(lib_num)+"\n");
fp.write(str(br_num)+"\n");
fp.close();
############################################## pysvn_current_br_num = pysvn.Revision( pysvn.opt_revision_kind.number, br_num);
pysvn_log_start = pysvn.Revision( pysvn.opt_revision_kind.number, last_lib_num);
pysvn_log_end = pysvn.Revision( pysvn.opt_revision_kind.number, lib_num);
"""
retcode - boolean, False if no username and password are available. True if subversion is to use the username and password.
username - string, the username to uses
password - string, the password to use
save - boolean, return True if you want subversion to remember the username and password in the configuration directory. return False to prevent saving the username and password.
"""
#def get_login( realm, username, may_save ):
# return retcode, username, password, save client = pysvn.Client()
#client.callback_get_login = get_login client.revert(code_path,True); client.update(code_path,True,pysvn_current_br_num,False); client.export(code_path+"/vasp",vasp,True,pysvn_current_br_num,None,False);
client.export(code_path+"/product/ar/vaspadp",vaspadp,True,pysvn_current_br_num,None,False); """
log returns a list of log entries; each log entry is a dictionary. The dictionary contains:
author - string - the name of the author who committed the revision
date - float time - the date of the commit
message - string - the text of the log message for the commit
revision - pysvn.Revision - the revision of the commit
changed_paths - list of dictionaries. Each dictionary contains:
path - string - the path in the repository
action - string
copyfrom_path - string - if copied, the original path, else None
copyfrom_revision - pysvn.Revision - if copied, the revision of the original, else None
"""
logmessege=client.log(code_path,pysvn_log_start,pysvn_log_end,False,False);
log_file = dest_path + '/'+"log.txt";
fp = open(log_file,"a");
for log_one in logmessege:
fp.write(log_one.author +" "+ log_one.message + "\n");
fp.close();

python利用pysvn发布lib的小程序的更多相关文章

  1. Python 练习冊,每天一个小程序

    Python 练习冊,每天一个小程序 说明:     Github 原文地址: 点击打开链接 Python 练习冊.每天一个小程序.注:将 Python 换成其它语言,大多数题目也试用 不会出现诸如「 ...

  2. 利用函数计算构建微信小程序的Server端

    10分钟上线 - 利用函数计算构建微信小程序的Server端-博客-云栖社区-阿里云 https://yq.aliyun.com/articles/435430 函数计算  读写 oss import ...

  3. js 利用throw 写的一个小程序

    在下边的小程序中比较特殊的是使用isNaN()函数判断一个参数是不是数字, <!DOCTYPE html> <!DOCTYPE html> <html> <h ...

  4. 如何利用MongoDB打造TOP榜小程序

    欢迎大家前往腾讯云+社区,获取更多腾讯海量技术实践干货哦~ 本文由腾讯云数据库 TencentDB发表于云+社区专栏 今天我分享的主题内容大概是两部分,最主要的还是小游戏和小程序,第一部分就是跟大家分 ...

  5. 微信小程序如何提交审核并发布?发布问题:小程序只支持https访问

    http://www.jisuapp.cn/news/305.html 发布问题:1.小程序只支持https访问 2.要配置服务域名

  6. 利用Bomb打造自己的小程序

    小程序开发 Bomb免费后端云开发 首先,小程序的开发已是热门,一个前段技术人员必备的技术就是开发小程序.在这里推荐一个入门小程序文章(连胜出品). 对于小程序的入门开发就不再做详细介绍,这里针对Bm ...

  7. CocosCreator上的游戏(调试)发布到微信小程序

    1.下载CocosCreator,微信开发者工具 官网地址:http://www.cocos.com/download 官网下载:https://developers.weixin.qq.com/mi ...

  8. uniapp发布到微信小程序整改摘要

    uniapp作为跨端的利器,可同时发布到安卓.ios.微信小程序.支付宝小程序.百度小程序.头条小程序.QQ小程序等8个平台. 如果是轻量级的应用,不涉及太多功能的话,或许可以直接打包移植,但涉及前后 ...

  9. 破界!Omi生态omi-mp发布,用小程序开发生成Web

    omi-mp 是什么 Omi 框架是微信支付线研发部和 AlloyTeam 开源的通用 Web 组件化框架,基于 Web Components,用来开发 PC.手机浏览器或者微信.手Q webview ...

随机推荐

  1. linux下的数据库管理工具phpmyadmin安装以及文件大小限制的配置修改

    1.首先需要安装mysql和apache服务.具体安装过程百度; 2.安装php环境以及对apache的扩展; sudo apt install php7.0  对于这些软件可能还需要各自进行配置,这 ...

  2. 一个模型中有两个外键指向同一张表时,创建迁移模型时报错:“ HINT: Add or change a related_name argument to the definition for 'AnswersModel.author' or 'AnswersModel.relay_to'.”解决方案

    class AnswersModel(models.Model): author = models.ForeignKey(FrontUserModel,null=True,related_name=' ...

  3. 快速上手virtualenv

    五分钟轻松学会管理项目开发环境. 在开发Python应用程序的时候,系统安装的Python3只有一个版本:3.x.所有第三方的包都会被pip安装到Python3的site-packages目录下. p ...

  4. ABP入门系列(21)——切换MySQL数据库

    ABP入门系列目录--学习Abp框架之实操演练 源码路径:Github-LearningMpaAbp 1. 引言 Abp支持MySql已经不是什么新鲜事了,但按照官方文档:Entity Framewo ...

  5. ServerSuperIO Designer IDE 发布,打造物联网通讯大脑,随心而联。附:C#驱动源代码。

    1.概况 注:ServerSuperIO Designer IDE 同行业网友随便使用,不涉及到软件使用限制的问题. 从2015年到现在的将近两年的时间,一直在开发.完善ServerSuperIO(S ...

  6. 【转载】解决refreshing gradle project 和Building gradle project info 一直卡住\速度慢

    转载: http://blog.csdn.net/xx326664162/article/details/52002616 文章出自:薛瑄的博客 分析原因: 更改Gradle的版本后,或者更新AS后, ...

  7. thymeleaf模板的使用(转)

    作者:纯洁的微笑 出处:http://www.ityouknow.com/ 在上篇文章springboot(二):web综合开发中简单介绍了一下thymeleaf,这篇文章将更加全面详细的介绍thym ...

  8. MyBatis 批量操作、集合遍历-foreach

    在使用mybatis操作数据库时,经常会使用到批量插入.IN条件查询的情况,这时就难免要使用到foreach元素.下面一段话摘自mybatis官网: foreach 元素的功能是非常强大的,它允许你指 ...

  9. 这么说吧,java线程池的实现原理其实很简单

    好处 : 线程是稀缺资源,如果被无限制的创建,不仅会消耗系统资源,还会降低系统的稳定性,合理的使用线程池对线程进行统一分配.调优和监控,有以下好处: 1.降低资源消耗: 2.提高响应速度: 3.提高线 ...

  10. Netty学习笔记(一):接收nodejs模拟表单上传的文件

    好久不写博客了,也好久不写代码了,这两天临时遇上一个事情,觉得不难,加上觉得手有些生,就动手做了一下,结果遇上了不少坑,有新坑,有老坑,痛苦无比,现在总算差不多了,赶紧记录下来,希望以后不再重复这种痛 ...