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()

相关文章

php操作SVN版本服务器类代码

SvnPeer.php 复制代码 代码如下: <?php /** * * This class for execute the external program of svn *...

七款最流行的PHP本地服务器分享

七款最流行的PHP本地服务器分享

使用Wordpress朋友总会难免需要对自己的WP进行一些个性调整或者为自己做一套个性的主题,一般的小修改直接在线调整完全没有问题,但要是为自己打造一套个性主题的时候最好还是选择本地进行...

1 行 Python 代码快速实现 FTP 服务器

1 行 Python 代码快速实现 FTP 服务器

 摘要: 当你想快速共享一个目录的时候,这是特别有用的,只需要1行代码即可实现。 当你想快速共享一个目录的时候,这是特别有用的,只需要1行代码即可实现。 FTP 服务器,在此...

在阿里云服务器上配置CentOS+Nginx+Python+Flask环境

项目运行环境 阿里云(单核CPU, 1G内存, Ubuntu 14.04 x64 带宽1Mbps), 具体购买和ssh连接阿里云本文不做描述。 实用工具 首先进入阿里云后先要升级下apt...

PHP实现的服务器一致性hash分布算法示例

本文实例讲述了PHP实现的服务器一致性hash分布算法。分享给大家供大家参考,具体如下: <?php /** * 对服务器进行一致性hash分布算法 */ clas...