使用python 操作liunx的svn,方案一
在服务器中要做几个操作,使用命令操作svn,svn文件的创建,svn文件更新,并把指定demo路径,移动到创建的文件夹中,进行提交,
# -*- coding:utf-8 -*-
import pysvn
import locale
import datetime
import os
import sys def setlocale():
language_code, encoding = locale.getdefaultlocale()
if language_code is None:
language_code = 'en_GB'
if encoding is None:
encoding = 'UTF-8'
if encoding.lower == 'utf':
encoding = 'UTF-8'
locale.setlocale(locale.LC_ALL, '%s.%s' % (language_code, encoding)) def get_login(realm, username, may_save):
return True, 'test', 'test', True #获取svn地址,url指svn地址,path,指项目拉取到哪个地方
def svncheckout(url,path):
client = pysvn.Client()
# client.callback_get_login = get_login
ret = client.checkout(url, path)
print ret #更新svn的地址
def svnupdate():
client = pysvn.Client()
ret = client.update(path)
return ret def svncheckin(url):
client = pysvn.Client()
#url=svnurl+"/"+projectname
# os.makedirs(url)
client.add(url)
client.checkin(url,u'项目文件的创建') #写入日志到本地,主要用于更新信息使用的
def svninfo(path):
client = pysvn.Client()
entry = client.info(path)
Version = "Version: %s" % entry.commit_revision.number
Author = "Author: %s" % entry.commit_author
Update = "Update Date: %s" % str(datetime.datetime.fromtimestamp(entry.commit_time))[:-7]
url=path + '\log.txt'
print url
f = file(url, 'a')
f.write(Version + '\n' + Author + '\n' + Update + '\n' + '-' * 32 + '\n')
f.close() def copyFiles(sourceDir, targetDir): #文件的复制
if sourceDir.find(".svn") > 0:
return
for file in os.listdir(sourceDir):
sourceFile = os.path.join(sourceDir, file)
targetFile = os.path.join(targetDir, file)
if os.path.isfile(sourceFile):
if not os.path.exists(targetDir):
os.makedirs(targetDir)
if not os.path.exists(targetFile) or (
os.path.exists(targetFile) and (os.path.getsize(targetFile) != os.path.getsize(sourceFile))):
open(targetFile, "wb").write(open(sourceFile, "rb").read())
if os.path.isdir(sourceFile):
First_Directory = False
copyFiles(sourceFile, targetFile) def run(svnurl,path,projectname):
#url为svn的仓库地址,path为本地路径,project为项目路径
# svncheckout(svnurl, path)
sourceDir=path+"/template"
print sourceDir
targetDir=path + "/" + projectname
print targetDir
copyFiles(sourceDir,targetDir) #资源文件
#svncheckin(targetDir) if __name__ == "__main__":
svnurl = "http://svn.egomsl.com/svn/repos/autotest.globalegrow.com/projectScript/uitest"
#run(svnurl,"./script/ui",sys.argv[0]) #从控制台接收一个名称,进行文件夹的创建
path='./script/ui';
run(svnurl, path, sys.argv[0])
使用python 操作liunx的svn,方案一的更多相关文章
- 使用python 操作liunx的svn,方案二
在对liunx操作svn的方式,做了改动,使用python的,subprocess进行操作 在第一种方案中,我使用了先拉到本地,然后再创建,在进行上传,实际在svn中可以直接创建文件,并进行文件复制, ...
- python操作email
python操作email 参考链接: python官网imaplib: https://docs.python.org/2/library/imaplib.html Python 用IMAP接收邮件 ...
- MongoDB的安装与python操作MongoDB
一.安装MongoDB 因为我个人使用的是windows,就只记录下windows下的安装 1.下载安装 就是官网,下载msi,选个路径安装 2.配置 看见别的地方说需要手动在bin同级目录创建dat ...
- Python几种并发实现方案的性能比较
http://blog.csdn.net/permike/article/details/54846831 Python几种并发实现方案的性能比较 2017-02-03 14:33 1541人阅读 评 ...
- redis缓存数据库及Python操作redis
缓存数据库介绍 NoSQL(NoSQL = Not Only SQL ),意即“不仅仅是SQL”,泛指非关系型的数据库,随着互联网web2.0网站的兴起,传统的关系数据库在应付web2.0网站, 特 ...
- python操作elasticsearch增、删、改、查
最近接触了个新东西--es数据库 这东西虽然被用的很多,但我是前些天刚刚接触的,发现其资料不多,学起来极其痛苦,写个文章记录下 导入库from elasticsearch import Elastic ...
- es的查询、排序查询、分页查询、布尔查询、查询结果过滤、高亮查询、聚合函数、python操作es
今日内容概要 es的查询 Elasticsearch之排序查询 Elasticsearch之分页查询 Elasticsearch之布尔查询 Elasticsearch之查询结果过滤 Elasticse ...
- 五、Python操作redis
五.Python操作redis 一.python对redis基本操作 (1)连接redis # 方式1 import redis r = redis.Redis(host='127.0.0.1', p ...
- Python(九) Python 操作 MySQL 之 pysql 与 SQLAchemy
本文针对 Python 操作 MySQL 主要使用的两种方式讲解: 原生模块 pymsql ORM框架 SQLAchemy 本章内容: pymsql 执行 sql 增\删\改\查 语句 pymsql ...
随机推荐
- JAVA-2NIO之Channel
注意:转载自并发编程网 – ifeve.com本文链接地址: Java NIO系列教程(二) Channel Channel Java NIO的通道类似流,但又有些不同: 既可以从通道中读取数据,又可 ...
- 用户IP地址的三个属性的区别(HTTP_X_FORWARDED_FOR,HTTP_VIA,REM_addr)
一.没有使用代理服务器的情况: REMOTE_ADDR = 您的 IP HTTP_VIA = 没数值或不显示 HTTP_X_FORWARDED_FOR = 没数值或不显示 二.使用 ...
- centos关闭selinux
SELinux(Security-Enhanced Linux) 是美国国家安全局(NSA)对于强制访问控制的实现,是 Linux历史上最杰出的新安全子系统.在这种访问控制体系的限制下,进程只能访问那 ...
- code.google.com certificate error: certificate is for www.google.com
有时候我们会碰到下面错误:code.google.com certificate error: certificate is for www.google.com,类似如下: D:\>go ge ...
- HDU 2544(简单最短路)
http://acm.hdu.edu.cn/showproblem.php?pid=2544 /* 使用pair代替结构 */ #include <iostream> #include & ...
- luogu P3065 first——trie树相关
题目描述 Bessie has been playing with strings again. She found that by changing the order of the alphabe ...
- mysql中LOCATE和CASE WHEN...THEN...ELSE...END结合用法
之前项目中需要写一个sql,就是查出某个调研详情中,选A答案,B答案,C答案...F答案的人各有多少人,这个sql也是费了很大的力气才写出来,故记下来,方便以后使用. 其中tbl_research_i ...
- EasyNetQ简单使用
class Program { static void Main(string[] args) { //打开消息确认机制 using (var bus = RabbitHutch.CreateBus( ...
- Android 黑色样式menu
效果图:
- JMeter测试WEB性能入门
一.JMeter介绍 1.Apache JMeter是什么 Apache JMeter 是Apache组织的开放源代码项目,是一个100%纯Java桌面应用,用于压力测试和性能测量.它最初被设计用于W ...