Python bulk Sync Web server code core program

Source: Internet
Author: 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_conne   CT 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.d isplay_db () for knumber,kname,ksgin,ksize,katime,kmtime in See_file:db_file[kname]=[ksgin,ksize,katime,kmtime] fo R fname,fsize,fatime,fmtime in List_file:if fname in Db_file.keys (): if ("%f")%fmtime = = ("%f")%db_file[fna           ME][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 fil       E_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 ()
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    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.