python批量同步web服务器代码核心程序
#!/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()热门推荐
10 八一幼儿祝福语大全简短
11 公司乔迁食堂祝福语简短
12 婚礼结束聚餐祝福语简短
13 儿媳买车妈妈祝福语简短
14 毕业送礼老师祝福语简短
15 同事辞职正常祝福语简短
16 恭贺新婚文案祝福语简短
17 金店立秋祝福语简短英文
18 婆婆高寿祝福语大全简短