python 多线程批量传文件

#!/usr/bin/env python
#_*_ coding:utf-8 -*-
#autho:leiyong
#time:2017-06-05
#version: 1.3
import paramiko from conf import * from threading import Thread import sys user = 'root' passwd = '123' def threaddo(hostip): print 'Being transmitted --->',hostip t = paramiko.Transport((hostip,22)) t.connect(username=user,password=passwd) sftp = paramiko.SFTPClient.from_transport(t) sftp.put(sys.argv[1],sys.argv[2]) t.close() def main(): hostxxip = [] for (userid,hostip) in info['host']['ipaddress_netpunch_room'].items(): hostxxip.append(hostip) hostipall = list(set(hostxxip)) for hostip in hostipall: userid = Thread(target=threaddo,args=(hostip,)) userid.start() if __name__ == "__main__": main()

conf.py

#!/bin/env python
# -*- coding: utf_8 -*-

info = {
    'host':{
       'ipaddress_coordinate_proxy':{
          'coordinate_proxy_hn_1':'109.29.170.141',
          'coordinate_proxy_hn_2':'13.99.11.213',
},
},
}
原文地址:https://www.cnblogs.com/rayong/p/7450203.html