How to use remote_scp method in autotest

Best Python code snippet using autotest_python

file2.py

Source:file2.py Github

copy

Full Screen

1import os2from paramiko import Transport, SFTPClient3def remote_scp(ftp_type, host_ip, remote_path, local_path, username, password):4 ssh_port = 225 try:6 conn = Transport((host_ip, ssh_port))7 conn.connect(username=username, password=password)8 sftp = SFTPClient.from_transport(conn)9 if ftp_type == 'remoteRead':10 print('read')11 if not local_path:12 filename = os.path.split(remote_path)13 local_path = os.path.join('/tmp', filename[-1])14 print('开始从服务器下载文件......')15 sftp.get(remote_path, local_path)16 print(f'文件{filename[-1]}已经下载到本地')17 if ftp_type == "remoteWrite":18 print('write')19 sftp.put(local_path, remote_path)20 conn.close()21 return True22 except IOError as e:23 print('没有找到目录', e)24 except Exception as e:25 print('error!!!', e)26remote_scp('remoteRead', '172.25.16.89', '/usr/local/aquila_pd_test/tomcat/dt.sh', '', 'aquila_pd_test', 'aquila_pd_test')...

Full Screen

Full Screen

download_info.py

Source:download_info.py Github

copy

Full Screen

1# encoding:utf-82import paramiko3import os4def remote_scp():5 HOST_IP = '47.95.120.23'6 REMOTE_PATH = '/work/update_gdtcookies/'7 REMOTE_FILENAME = 'info.json'8 LOCAL_PATH = './'9 USERNAME = 'zmwork'10 PASSWORD = 'ab&C2S8$14Xr#s0o'11 if not os.path.isdir(LOCAL_PATH):12 os.makedirs(LOCAL_PATH)13 if not os.path.isfile(LOCAL_PATH + '/' + REMOTE_FILENAME):14 fp = open(LOCAL_PATH + '/' + REMOTE_FILENAME, 'w')15 fp.close()16 t = paramiko.Transport((HOST_IP, 22))17 t.connect(username=USERNAME, password=PASSWORD) # 登录远程服务器18 sftp = paramiko.SFTPClient.from_transport(t) # sftp传输协议19 src = REMOTE_PATH + '/' + REMOTE_FILENAME20 des = LOCAL_PATH + '/' + REMOTE_FILENAME21 sftp.get(src, des)22 t.close()23if __name__ == '__main__':...

Full Screen

Full Screen

download.py

Source:download.py Github

copy

Full Screen

1import paramiko2import datetime3def remote_scp(host_ip, remote_path, local_path, username, password):4 t = paramiko.Transport((host_ip, 22))5 t.connect(username=username, password=password)6 sftp = paramiko.SFTPClient.from_transport(t)7 start_time = datetime.datetime.now()8 src = remote_path9 des = local_path10 sftp.get(src, des)11 t.close()12 end_time = datetime.datetime.now()13 c = 58 / (end_time - start_time).seconds14 print('下载速度为:{}M/s'.format(c))15if __name__ == '__main__':16 host_ip = '192.168.1.115'17 remote_path = '/home/ifarm-lcc-exec.jar'18 local_path = r'c:\Users\a\ifarm-lcc-exec.jar'19 username = 'root'20 password = '123456'...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run autotest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful