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

Contents

1 pip install SSLCertVerificationError
2 蠍 蟾讌
3 sftp れ企


1 pip install SSLCertVerificationError #

WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:1108)'))

pip --trusted-host pypi.org --trusted-host files.pythonhosted.org install

pip install <package> --trusted-host pypi.org --trusted-host files.pythonhosted.org --proxy="<IP>:<port>"


2 蠍 蟾讌 #

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

3 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 2024-04-29 08:08:21

蠏碁所 ロ 讌 襷 碁襯 襴糾 襷 . (れ梗)