python批量同步web伺服器代碼核心程式

來源:互聯網
上載者:User
#!/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()
  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.