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 ...
随机推荐
- King's Quest - poj 1904(强连通分量+外挂输入输出)
题意:国王有N个儿子,每个儿子都有很多喜欢的姑娘,官员为每个王子都找了一个姑娘让他们结婚,不过国王不满意,他想知道他的每个儿子都可以和那个姑娘结婚(前提他的儿子必须喜欢那个姑娘) 分析:因为最下面一行 ...
- 基于Equinox构建OSGi项目
几种OSGi框架 Several independently implemented OSGi frameworks exist today, including four that are avai ...
- 转:有关Java泛型的类型擦除(type erasing)
转载自:拈花微笑 自从Java 5引入泛型之后,Java与C++对于泛型不同的实现的优劣便一直是饭后的谈资.在我之前的很多training中,当讲到Java泛型时总是会和C++的实现比较,一般得出的结 ...
- Java并发编程:并发容器ConcurrentHashMap
Java并发编程:并发容器之ConcurrentHashMap(转载) 下面这部分内容转载自: http://www.haogongju.net/art/2350374 JDK5中添加了新的concu ...
- jquery表单实时验证
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- 《火球——UML大战需求分析》(第1章 大话UML)——1.4 如何学好UML?
说明: <火球——UML大战需求分析>是我撰写的一本关于需求分析及UML方面的书,我将会在CSDN上为大家分享前面几章的内容,总字数在几万以上,图片有数十张.欢迎你按文章的序号顺序阅读,谢 ...
- rk3288 ov8858 camera移植
平台:瑞芯的rk3288 SDK:4.4/5.0/5.1 作者:fulinux *****本文同意转载.只是请注明出处:http://blog.csdn.net/fulinus**** rk3288的 ...
- Linux应用程序打包
原文地址:http://blog.solrex.cn/articles/packaging-1-src.html1. 应用程序打包技术之一(源代码篇) 相信很多朋友都曾经为方便做某件事写过自己的小 ...
- Android捕获崩溃异常
开发中最让人头疼的是应用突然爆炸,然后跳回到桌面.而且我们常常不知道这种状况会何时出现,在应用调试阶段还好,还可以通过调试工具的日志查看错误出现在哪里.但平时使用的时候给你闹崩溃,那你就欲哭无泪了. ...
- Myeclipse中点(.)不出来方法或者属性?