python批量同步web服务器代码核心程序


Posted in Python onSeptember 01, 2014
#!/usr/bin/env python 
#coding:utf8 
import os,sys import md5,tab from mysql_co.my_db import set_mysql from ssh_co.ssh_connect import sshd from ssh_co.cfg.config import ssh_message,item_path from file import findfile def my_mysql(): 
  db_file={} 
  my_connect=set_mysql() 
  f_file=findfile.main(item_path) 
  list_file=findfile.file_list(f_file) 
  see_file=my_connect.display_db() 
  for knumber,kname,ksgin,ksize,katime,kmtime in see_file: 
    db_file[kname]=[ksgin,ksize,katime,kmtime] 
  for fname,fsize,fatime,fmtime in list_file: 
      if fname in db_file.keys(): 
        if ("%f")%fmtime == ("%f")%db_file[fname][3]: 
          print "%s The same mtime pass"%fname 
          my_connect.set_file_attribute(10,fname,fmtime) 
          pass
        else: 
          print "%s different for mtime"%fname 
          my_connect.set_file_attribute(11,fname,fmtime) 
      else: 
        my_connect.add_db(fname,fsize,fatime,fmtime) 
        my_connect.set_file_attribute(11,fname,fmtime) 
        print "%s,is new file"%fname 
  new_file=my_connect.new_db() 
  my_connect.disconn_db() 
  return new_file def my_ssh(new_file): 
  pid_host = 1
  for host_attribute in ssh_message: 
    ssh_conn=sshd(host_attribute,pid_host) 
    for file_name in new_file: 
      if file_name: 
        a=ssh_conn.put_ssh_file(file_name[1]) 
        print a 
        print "ssh_connect memoryID: %s" %pid_host 
      else: 
        pid_host = id(host_attribute) 
        ssh_conn.disconn_ssh() def main(): 
  new_file=my_mysql() 
  my_ssh(new_file) 
 if __name__ == "__main__": 
  main()
Python 相关文章推荐
Python中的Classes和Metaclasses详解
Apr 02 Python
Python模拟登陆实现代码
Jun 14 Python
使用Django启动命令行及执行脚本的方法
May 29 Python
在Python中实现shuffle给列表洗牌
Nov 08 Python
python实现windows壁纸定期更换功能
Jan 21 Python
Numpy之random函数使用学习
Jan 29 Python
Django 数据库同步操作技巧详解
Jul 19 Python
Django实现web端tailf日志文件功能及实例详解
Jul 28 Python
Python如何使用字符打印照片
Jan 03 Python
python使用gdal对shp读取,新建和更新的实例
Mar 10 Python
Python基于time模块表示时间常用方法
Jun 18 Python
python实现AHP算法的方法实例(层次分析法)
Sep 09 Python
寻找网站后台地址的python脚本
Sep 01 #Python
python批量修改文件名的实现代码
Sep 01 #Python
python中List的sort方法指南
Sep 01 #Python
Python抓取京东图书评论数据
Aug 31 #Python
Python深入学习之内存管理
Aug 31 #Python
Python深入学习之装饰器
Aug 31 #Python
Python深入学习之闭包
Aug 31 #Python
You might like
PHP读取txt文件的内容并赋值给数组的代码
2011/11/03 PHP
PHP判断一个gif图片是否为动态图片的方法
2014/11/19 PHP
php+mysql+ajax实现单表多字段多关键词查询的方法
2017/04/15 PHP
php类自动装载、链式操作、魔术方法实现代码
2017/07/23 PHP
Javascript的一种模块模式
2008/03/22 Javascript
探讨js中的双感叹号判断
2013/11/11 Javascript
使用GruntJS构建Web程序之合并压缩篇
2014/06/06 Javascript
js控制再次点击按钮之间的间隔时间可防止重复提交
2014/08/01 Javascript
原生javascript实现图片无缝滚动效果
2016/02/12 Javascript
JavaScript学习笔记之创建对象
2016/03/25 Javascript
js如何准确获取当前页面url网址信息
2020/09/13 Javascript
JQuery validate插件验证用户注册信息
2016/05/11 Javascript
jQuery实现的省市县三级联动菜单效果完整实例
2016/08/01 Javascript
jQuery事件绑定用法详解
2016/09/08 Javascript
vue+vue-validator 表单验证功能的实现代码
2017/11/13 Javascript
js+html5 canvas实现ps钢笔抠图
2019/04/28 Javascript
ant-design-vue按需加载的坑的解决
2020/05/14 Javascript
js获取url页面id,也就是最后的数字文件名
2020/09/25 Javascript
[55:35]DOTA2-DPC中国联赛 正赛 CDEC vs Dragon BO3 第二场 1月22日
2021/03/11 DOTA
对于Python的Django框架使用的一些实用建议
2015/04/03 Python
浅谈Python 字符串格式化输出(format/printf)
2016/07/21 Python
使用Python对Excel进行读写操作
2017/03/30 Python
Python引用传值概念与用法实例小结
2017/10/07 Python
Python matplotlib通过plt.scatter画空心圆标记出特定的点方法
2018/12/13 Python
opencv导入头文件时报错#include的解决方法
2019/07/31 Python
python中图像通道分离与合并实例
2020/01/17 Python
没编程基础可以学python吗
2020/06/17 Python
什么是python的函数体
2020/06/19 Python
深入了解Python 方法之类方法 & 静态方法
2020/08/17 Python
详解Django关于StreamingHttpResponse与FileResponse文件下载的最优方法
2021/01/07 Python
今天学到的CSS最新技术(与图片背景相关)
2012/12/24 HTML / CSS
如何使用html5与css3完成google涂鸦动画
2012/12/16 HTML / CSS
医院检讨书范文
2014/02/01 职场文书
师德先进个人事迹材料
2014/12/19 职场文书
通知范文怎么写
2015/04/16 职场文书
部门主管竞聘书
2015/09/15 职场文书