python的工作记录A
马上进入工作自动化:
[root@localhost ~]# cat svn_bbs.py
import os,sys,commands,subprocess
import re,time
svnUrl = "svn://xxx"
svnExportCmdPre = "svn export svn://xxx/"
sitePath = "/xxx"
updateFolder = "/srv/salt/xxx/"
saltMinion = "xxx"
saltCpCmdPre = "salt '" + saltMinion + "' cmd.run " + "' cp "
saltChownCmdPre = "salt '" + saltMinion + "' cmd.run " + "'chown nginx:nginx "
saltChmodCmdPre = "salt '" + saltMinion + "' cmd.run " + "'chmod 664 "
saltGetFilePre = "salt '" + saltMinion + "' cp.get_file salt://xxx/"
localFileList = []
remoteFileList = []
def getSvnFile(rVersion):
svnLogCmd ="svn log -v -r" + rVersion +" " + svnUrl
svnLogOut = subprocess.Popen(svnLogCmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
for line in svnLogOut.stdout.readlines():
if len(line.strip())!=0 and line.startswith(" "):
fileName = line.split()[1]
fileNameS = fileName.split('/')[-1]
filePath = sitePath + fileName
localFileList.append(fileNameS)
remoteFileList.append(filePath)
svnExportCmd = svnExportCmdPre + fileName + " " + updateFolder + fileNameS
subprocess.Popen(svnExportCmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
def backupFile(bFileName):
cpCmd = saltCpCmdPre + bFileName + " " + bFileName +".old'"
subprocess.Popen(cpCmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
saltChownCmd = saltChownCmdPre + bFileName + ".old'"
subprocess.Popen(saltChownCmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
saltChmodCmd = saltChmodCmdPre + bFileName + ".old'"
subprocess.Popen(saltChmodCmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
def updateFile(localFile, remoteFile):
saltCpCmd = saltGetFilePre + localFile + " " + remoteFile + " makedirs=True"
#print saltCpCmd
subprocess.Popen(saltCpCmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
saltChownCmd = saltChownCmdPre + remoteFile + "'"
subprocess.Popen(saltChownCmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
saltChmodCmd = saltChmodCmdPre + remoteFile + "'"
subprocess.Popen(saltChmodCmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
def main():
getSvnFile(rVersion)
print localFileList
for file in remoteFileList:
backupFile(file)
#updateFile(uF, rF)
for local,remote in zip(localFileList,remoteFileList):
print local,remote
if __name__=="__main__":
rVersion = sys.argv[1]
main()
python的工作记录A的更多相关文章
- python的工作记录B
这次很强了.就差最后一步,判断一下SVN的版本是否是真的库里的. #!/usr/bin/env python # -*- coding: utf-8 -*- import os,sys,command ...
- [工作记录] Android OpenGL ES: non-square texture - continue
previous: [工作记录] Android OpenGL ES 2.0: square texture not supported on some device recently I found ...
- MySQL跨表更新字段 工作记录
工作中遇到两表查询,从user表中获取用户唯一id字段 写入到另外一张qiuzu表中的uid字段中; 二者可以关联起来的只有用户的手机号码tel字段; 了解需求后数据量稍多,不可能一个一个的手动修改 ...
- 最近的linux工作记录
最近的linux工作记录 最近公司走了一些同事,部分服务器交到了我的手里,总结一些常用的操作 注:大写的字符串一般是用来占位,需要替换 创建账户和使用密钥对登陆 1,账户系列 useradd 选项 用 ...
- 工作记录 - OBB的解决方案
之前关于OBB的内容: Android上使用native IO 最近工作中的问题笔记 工作记录[续] android OBB 自从用了Java来mount OBB, 再也没有遇到挂载的问题. 但最近在 ...
- Python爬虫个人记录(三)爬取妹子图
这此教程可能会比较简洁,具体细节可参考我的第一篇教程: Python爬虫个人记录(一)豆瓣250 Python爬虫个人记录(二)fishc爬虫 一.目的分析 获取煎蛋妹子图并下载 http://jan ...
- Python爬虫个人记录(二) 获取fishc 课件下载链接
参考: Python爬虫个人记录(一)豆瓣250 (2017.9.6更新,通过cookie模拟登陆方法,已成功实现下载文件功能!!) 一.目的分析 获取http://bbs.fishc.com/for ...
- 工作记录--WPF自定义控件,实现一个可设置编辑模式的TextBox
原文:工作记录--WPF自定义控件,实现一个可设置编辑模式的TextBox 1. 背景 因为最近在使用wpf开发桌面端应用,在查看页面需要把TextBox和Combox等控件设置为只读的.原本是个很简 ...
- 图书馆管理系统程序+全套开发文档(系统计划书,系统使用说明,测试报告,UML分析与设计,工作记录)
图书馆管理系统程序+全套开发文档(系统计划书,系统使用说明,测试报告,UML分析与设计,工作记录): https://download.csdn.net/download/qq_39932172/11 ...
随机推荐
- 最受欢迎linux命令
1. 以 root 帐户执行上一条命令 sudo !! 2. 利用 Python 搭建一个简单的 Web 服务器,可通过 http://$HOSTNAME:8000访问 python -m ...
- MVC三层架构编程(Dao、service、servlet 之间的关系)
木哈哈~先开心一会儿,人生的第一篇博客aaa.我一定好好写.不过之前也没怎么看别人写过,还是有点小激动呢,加油.好好总结,会总结的宝宝才会有提高! 今天想总结一下mvc三层架构模型编程,宝宝学习不怎么 ...
- 第一章 工欲善其事 必先利其器—Android SDK工具(3)
1.3没有真机一样开发--Android模拟器 有些时候,我们手头上可能并没有符合要求的Android设备.那么这时候我们是不是对调试或者开发就一筹莫展了呢?当然不是.由于我们有Android模拟器. ...
- Chapter 4. Using the Gradle Command-Line 使用gradle命令行
This chapter introduces the basics of the Gradle command-line. You run a build using the gradle comm ...
- javascript基础之自执行函数
1.匿名函数的定义方式 如下 var temp = function(){} 2.自执行函数 (function(){ 内容 }) () 不带参数 (fun ...
- 从BufferedImage到InputStream,实现绘图后进行下载(生成二维码图片并下载)
@SuppressWarnings("resource") public void download() throws Exception{ String filename = & ...
- 使用__doPostBack函数来达到使用客户端的控件来调用服务器端的函数的--小结
类比LinkButton按钮 LinkButton前台生成代码: JS代码: //<![CDATA[ var theForm = document.forms['form1']; if (!th ...
- asp.net 连接oracle,报错误“System.Data.OracleClient 需要 Oracle 客户端软件 8.1.7 或更高版本
1.http://www.oracle.com/technetwork/database/features/instant-client/index-097480.html 下载对用版本的Instan ...
- SQL数据库中把一个表中的数据复制到另一个表中
1.如果是整个表复制表达如下: insert into table1 select * from table2 2.如果是有选择性的复制数据表达如下: insert into table1(colu ...
- Linux shell 脚本中”2>&1″的含义解释
脚本是:nohup /mnt/Nand3/H2000G >/dev/null 2>&1 & 对于& 1 更准确的说应该是文件描述符 1,而1 一般代表的就是 ...