码迷,mamicode.com
首页 > 编程语言 > 详细

python 多线程批量传文件

时间:2017-08-29 21:54:39      阅读:146      评论:0      收藏:0      [点我收藏+]

标签:div   tran   put   net   pad   username   def   main   []   

#!/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,
},
},
}

 

python 多线程批量传文件

标签:div   tran   put   net   pad   username   def   main   []   

原文地址:http://www.cnblogs.com/rayong/p/7450203.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!