#!/usr/bin/envpython
#coding:utf8
importos,sysimportmd5,tabfrommysql_co.my_dbimportset_mysqlfromssh_co.ssh_connectimportsshdfromssh_co.cfg.configimportssh_message,item_pathfromfileimportfindfiledefmy_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()
forknumber,kname,ksgin,ksize,katime,kmtimeinsee_file:
db_file[kname]=[ksgin,ksize,katime,kmtime]
forfname,fsize,fatime,fmtimeinlist_file:
iffnameindb_file.keys():
if("%f")%fmtime==("%f")%db_file[fname][3]:
print"%sThesamemtimepass"%fname
my_connect.set_file_attribute(10,fname,fmtime)
pass
else:
print"%sdifferentformtime"%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,isnewfile"%fname
new_file=my_connect.new_db()
my_connect.disconn_db()
returnnew_filedefmy_ssh(new_file):
pid_host=1
forhost_attributeinssh_message:
ssh_conn=sshd(host_attribute,pid_host)
forfile_nameinnew_file:
iffile_name:
a=ssh_conn.put_ssh_file(file_name[1])
printa
print"ssh_connectmemoryID:%s"%pid_host
else:
pid_host=id(host_attribute)
ssh_conn.disconn_ssh()defmain():
new_file=my_mysql()
my_ssh(new_file)
if__name__=="__main__":
main()