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

yipeiwu_com5年前服务器
#!/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()

相关文章

Session服务器配置指南与使用经验的深入解析

一.摘要所有Web程序都会使用Session保存数据. 使用独立的Session服务器可以解决负载均衡场景中的Session共享问题.本文介绍.NET平台下建立Session服务器的几种...

PyCharm 配置远程python解释器和在本地修改服务器代码

PyCharm 配置远程python解释器和在本地修改服务器代码

最近在学习机器学习的过程中,常常需要将本地写的代码传到GPU服务器中,然后在服务器上运行。之前的做法一直是先在本地写好代码,然后通过FileZilla这样的文件传输工具来将写好的文件传到...

python下paramiko模块实现ssh连接登录Linux服务器

本文实例讲述了python下paramiko模块实现ssh连接登录Linux服务器的方法。分享给大家供大家参考。具体分析如下: python下有个paramiko模块,这个模块可以实现s...

python制作websocket服务器实例分享

python制作websocket服务器实例分享

一、开始的话   使用python简单的实现websocket服务器,可以在浏览器上实时显示远程服务器的日志信息。   之前做了一个web版的发布系统,但没实现在线看日志,每次发布版本后...

通过PHP自带的服务器来查看正则匹配结果的方法

通过PHP自带的服务器来查看正则匹配结果的方法

众所周知,PHP代码需要web服务器来执行,要测试PHP代码就得搭建一个web服务器,这就给我们平时学习带来了较多不便。不过好在PHP v5.4版本以后,PHP会自带一个功能简单的web...