马上进入工作自动化:

[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的更多相关文章

  1. python的工作记录B

    这次很强了.就差最后一步,判断一下SVN的版本是否是真的库里的. #!/usr/bin/env python # -*- coding: utf-8 -*- import os,sys,command ...

  2. [工作记录] Android OpenGL ES: non-square texture - continue

    previous: [工作记录] Android OpenGL ES 2.0: square texture not supported on some device recently I found ...

  3. MySQL跨表更新字段 工作记录

    工作中遇到两表查询,从user表中获取用户唯一id字段 写入到另外一张qiuzu表中的uid字段中; 二者可以关联起来的只有用户的手机号码tel字段; 了解需求后数据量稍多,不可能一个一个的手动修改 ...

  4. 最近的linux工作记录

    最近的linux工作记录 最近公司走了一些同事,部分服务器交到了我的手里,总结一些常用的操作 注:大写的字符串一般是用来占位,需要替换 创建账户和使用密钥对登陆 1,账户系列 useradd 选项 用 ...

  5. 工作记录 - OBB的解决方案

    之前关于OBB的内容: Android上使用native IO 最近工作中的问题笔记 工作记录[续] android OBB 自从用了Java来mount OBB, 再也没有遇到挂载的问题. 但最近在 ...

  6. Python爬虫个人记录(三)爬取妹子图

    这此教程可能会比较简洁,具体细节可参考我的第一篇教程: Python爬虫个人记录(一)豆瓣250 Python爬虫个人记录(二)fishc爬虫 一.目的分析 获取煎蛋妹子图并下载 http://jan ...

  7. Python爬虫个人记录(二) 获取fishc 课件下载链接

    参考: Python爬虫个人记录(一)豆瓣250 (2017.9.6更新,通过cookie模拟登陆方法,已成功实现下载文件功能!!) 一.目的分析 获取http://bbs.fishc.com/for ...

  8. 工作记录--WPF自定义控件,实现一个可设置编辑模式的TextBox

    原文:工作记录--WPF自定义控件,实现一个可设置编辑模式的TextBox 1. 背景 因为最近在使用wpf开发桌面端应用,在查看页面需要把TextBox和Combox等控件设置为只读的.原本是个很简 ...

  9. 图书馆管理系统程序+全套开发文档(系统计划书,系统使用说明,测试报告,UML分析与设计,工作记录)

    图书馆管理系统程序+全套开发文档(系统计划书,系统使用说明,测试报告,UML分析与设计,工作记录): https://download.csdn.net/download/qq_39932172/11 ...

随机推荐

  1. oracle连接进程数设置

    SQL> select count(*) from v$session #连接数SQL> Select count(*) from v$session where status='ACTI ...

  2. selenium webdriver python 等待

    AJAX,即“Asynchronous Javascript And  XML”.可以实现网页的异步更新.也就是在不重新加载整个网页的情况下,对网页的某部分进行更新. 现在大多数网站都使用AJAX技术 ...

  3. 迁移ADT/ANT构建的Android项目至Gradle,a walk through。

    LibModule 配置更新 9 months ago   app 配置更新 9 months ago   gradle/wrapper 配置更新 9 months ago   screenshots ...

  4. java笔记11之二维数组

    格式1: 二维数组:就是元素为一维数组的一个数组 数据类型[][] 数组名 = new 数组类型[m][n] 其中m为行 n为列 注意: A:以下格式也可以表示二维数组            a:数据 ...

  5. 注释PHP和html混合代码

    <?php if(false){ ?> any code <?php } ?>

  6. 两个关于XML解析报错问题小记

    Caused by: org.xml.sax.SAXParseException: The string "--" is not permitted within comments ...

  7. Android 自定义CheckBox样式

    1.首先在drawable文件夹中添加drawable文件checkbox_style.xml. <selector xmlns:android="http://schemas.and ...

  8. Android四大组件——Activity

    Activity作为Android四大组件之一,也是其中最重要的一个组件.作为一个与用户交互的组件,我们可以把Activity比较成为windows系统上的一个文件夹窗口,是一个与用户交互的界面.再进 ...

  9. Android(java)学习笔记255:JNI之JNI概念

    1. JNI是什么? java native interface (java本机接口) 比如方法声明: public final native Class<?>  getClass(): ...

  10. 图片跟着鼠标动js

    <!DOCTYPE html><html><head> <title>duisgf</title> <meta charset=&qu ...