Python batch synchronization Web server code core program _python

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_co Nnect 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_co nnect.display_db () for knumber,kname,ksgin,ksize,katime,kmtime in SEE_FILE:DB_FILE[KNAME]=[KSGIN,KSIZE,KATIME,KMT IME] for Fname,fsize,fatime,fmtime in List_file:if fname in Db_file.keys (): if ("%f")%fmtime = = ("%f") %DB_FILE[FNAME][3]: print "%s" Same Mtime pass%fname My_connect.set_file_attribute (10,fname,fmti Me) 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_attribut 
    E (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 m Ain (): 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.