_ | 覦覈襦 | 豕蠏手 | 殊螳 | 譯殊碁
FrontPage › PythonTip&Tech

Contents

1 蠍 蟾讌
2 sftp れ企


1 蠍 蟾讌 #

from matplotlib import font_manager, rc
font_name = font_manager.FontProperties(fname="c:/Windows/Fonts/malgun.ttf").get_name()
rc('font', family=font_name)
matplotlib.rcParams['axes.unicode_minus'] = False

2 sftp れ企 #

1螳 朱..
import paramiko
from base64 import decodebytes
host = "192.168.100.100"
port = 22
id = "id"
pw = "pw"

client = paramiko.SSHClient()
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
client.load_system_host_keys()

client.connect(host, username=id, password=pw, port=port, timeout=14400) # 殊 蟆曙 timeout 誤讌 朱 蠍覦 伎.
tr = client.get_transport()
#tr.default_max_packet_size = 214748364 #願 觜殊 .
tr.default_window_size = 2147483647 #願 誤讌 朱 覓 襴 豐 10kb
paramiko.sftp_file.SFTPFile.MAX_REQUEST_SIZE = pow(2, 22) #願 誤讌 朱 貅 伎.
sftp = client.open_sftp()


remonte_file_path = '/remote_dir/sample.log.gz'
local_file_path = '/local_dir/sample.log.gz'

sftp.get(remonte_file_path, local_file_path)
client.close()

襴 蟇 覈 れ企
import os
import sys
import paramiko
from stat import S_ISDIR

host = "192.168.100.100"
port = 22
id = "id"
pw = "pw"

client = paramiko.SSHClient()
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
client.load_system_host_keys()

client.connect(host, username=id, password=pw, port=port, timeout=14400) #timeout 誤讌 朱 蠍覦 伎.
tr = client.get_transport()
#tr.default_max_packet_size = 214748364 #願 觜殊 .
tr.default_window_size = 2147483647 #願 誤讌 朱 覓 襴 豐 10kb
paramiko.sftp_file.SFTPFile.MAX_REQUEST_SIZE = pow(2, 22) #願 誤讌 朱 貅 伎.
sftp = client.open_sftp()

remonte_file_path = sys.argv[1] #/remote_dir/
local_file_path = sys.argv[2] #/local_dir/


def sftp_walk(remotepath):
    path=remotepath
    files=[]
    folders=[]
    for f in sftp.listdir_attr(remotepath):
        if S_ISDIR(f.st_mode):
            folders.append(f.filename)
        else:
            files.append(f.filename)
    if files:
        yield path, files
    for folder in folders:
        new_path=os.path.join(remotepath,folder)
        for x in sftp_walk(new_path):
            yield x

os.system("mkdir " + local_file_path)
for path, files in sftp_walk(remonte_file_path):
	for file in files:
		print(os.path.join(os.path.join(path,file)))
		sftp.get(os.path.join(os.path.join(path,file)), local_file_path+file)

client.close()
蠍 蠍郁鍵..
企: : るジ讓曙 襦螻豺 企Ν 譯殊語. 襦螻豺
EditText : Print : Mobile : FindPage : DeletePage : LikePages : Powered by MoniWiki : Last modified 2019-10-16 14:06:49

磯Μ螳 覈 殊 磯Μ 苦 觜襦. 豢 伎 螻伎 觜郁 襷 蟆 覦 . (覯 )