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的Django框架代码的一些示例
Apr 20 Python
pandas实现选取特定索引的行
Apr 20 Python
django 多数据库配置教程
May 30 Python
Python Learning 列表的更多操作及示例代码
Aug 22 Python
python pands实现execl转csv 并修改csv指定列的方法
Dec 12 Python
python之Flask实现简单登录功能的示例代码
Dec 24 Python
简单了解Django ContentType内置组件
Jul 23 Python
Django实现whoosh搜索引擎使用jieba分词
Apr 08 Python
Python hashlib和hmac模块使用方法解析
Dec 08 Python
PyQt5实现多张图片显示并滚动
Jun 11 Python
python面向对象版学生信息管理系统
Jun 24 Python
Python pandas之求和运算和非空值个数统计
Aug 07 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
根德YB400的电路分析
2021/03/02 无线电
如何写php程序?
2006/12/08 PHP
php中将网址转换为超链接的函数
2011/09/02 PHP
解析使用ThinkPHP应该掌握的调试手段
2013/06/20 PHP
ThinkPHP验证码使用简明教程
2014/03/05 PHP
php输出xml必须header的解决方法
2014/10/17 PHP
javascript整除实现代码
2010/11/23 Javascript
js实现遮罩层划出效果是生成div而不是显示
2014/07/29 Javascript
Node.js安装教程和NPM包管理器使用详解
2014/08/16 Javascript
js同源策略详解
2015/05/21 Javascript
javascript框架设计之类工厂
2015/06/23 Javascript
简单掌握JavaScript中const声明常量与变量的用法
2016/05/21 Javascript
微信小程序访问node.js接口服务器搭建教程
2017/04/25 Javascript
js中url对象化管理分析
2017/12/29 Javascript
angularJS1 url中携带参数的获取方法
2018/10/09 Javascript
关于js陀螺仪的理解分析
2019/04/11 Javascript
基于vue+axios+lrz.js微信端图片压缩上传方法
2019/06/25 Javascript
Python的另外几种语言实现
2015/01/29 Python
浅谈插入排序算法在Python程序中的实现及简单改进
2016/05/04 Python
python实现彩色图转换成灰度图
2019/01/15 Python
selenium python 实现基本自动化测试的示例代码
2019/02/25 Python
python循环定时中断执行某一段程序的实例
2019/06/29 Python
python  文件的基本操作 菜中菜功能的实例代码
2019/07/17 Python
Python实现银行账户资金交易管理系统
2020/01/03 Python
Jupyter Notebook 文件默认目录的查看以及更改步骤
2020/04/14 Python
美国杂志订阅折扣与优惠网站:Magazines.com
2016/08/31 全球购物
澳洲在线厨具商店:Kitchen Style
2018/05/05 全球购物
Notino希腊:购买香水和美容产品
2019/07/25 全球购物
工程造价专业大学生职业生涯规划书
2014/01/18 职场文书
《一个中国孩子的呼声》教学反思
2014/02/12 职场文书
学校联谊活动方案
2014/02/15 职场文书
教师调动申请报告
2015/05/18 职场文书
三八红旗手先进事迹材料(2016推荐版)
2016/02/25 职场文书
nginx反向代理配置去除前缀案例教程
2021/07/26 Servers
Python NumPy灰度图像的压缩原理讲解
2021/08/04 Python
无线电知识基础入门篇
2022/02/18 无线电