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 ...
随机推荐
- View Controller 生命周期的各个方法的用法
(void)awakeFromNib; 这个方法用的时候,outlet还没有连接起来,是view Controller刚从storyboard建的时候,没有完全建好,不过可能有一些事情要在这个方法里面 ...
- Android 关于获取摄像头帧数据解码
由于Android下摄像头预览数据只能 ImageFormat.NV21 格式的,所以解码时要经过一翻周折. Camera mCamera = Camera.open(); Camera.Param ...
- Python标准库:内置函数bytearray([source[, encoding[, errors]]])
返回一个新字节数组.这个数组里的元素是可变的.而且每一个元素的值范围: 0 <= x < 256.能够通过"字节与字节数组操作"章节来查看相关字节数组的内容.以下说明一 ...
- Ellipse常用快捷键
Ctrl+m:视窗大小变化 Ctrl+F6:在打开的文件件进行切换 Ctrl+F7:在资源窗口间切换Ctrl+F8:在各种模式下进行切换 Ctrl+e:选择某个打开的文件Shift+home:整行选取 ...
- monkeyrunner 详细介绍
MonkeyRunner: monkeyrunner工具提供了一个API,使用此API写出的程序可以在Android代码之外控制Android设备和模拟器.通过monkeyrunner,您可以写出一个 ...
- [Angular 2] Rendering an Observable Date with the Async and Date Pipes
Instead of simply pushing numbers on a timer into the template, now we'll move on to pushing actual ...
- [Angular 2] Get start with Firebase
Create a Firebase Servcie: import {Injectable} from 'angular2/core'; import {Http, Response} from 'a ...
- Linux下查看显示器输出状态以及修改显示器工作模式(复制 or 扩展)
//关闭显示器VGA1xrandr --output VGA1 --off //开启显示器VGA1xrandr --output VGA1 --auto //关闭显示器LVDS1xrandr --ou ...
- EventBus 事件总线 案例
简介 地址:https://github.com/greenrobot/EventBus EventBus是一个[发布 / 订阅]的事件总线.简单点说,就是两人[约定]好怎么通信,一人发布消息,另外一 ...
- codevs 1028 花店橱窗布置 (KM)
/*裸地KM*/ #include<iostream> #include<cstdio> #include<cstring> #define maxn 110 #d ...