Forum Discussion

thouhid1's avatar
thouhid1
Occasional Contributor
4 years ago
Solved

i want to upload file to server using sftp in testcomplete

Can anyone paste the code so that i can refer and impliment accordingly 

 

Currently i am using this below code : but everytime i am getting ModuleNotFoundError: No module named 'pysftp'  . i have done Pip install pysftp and cut pasted downloaded folders inside folder C:\Program Files (x86)\SmartBear\TestComplete 14\Bin\Extensions\Python\Python36\Lib 

i am not able to figure out what is the exact issue . Need some suggesstions 

 

import pysftp as sftp
from ssh_key import SshUtil

def upload_report(reportFilePath, dashboard_report_path):

cnopts = sftp.CnOpts()
cnopts.hostkeys = None

try:
server = sftp.Connection(host='automation-dashboard', username='harman', password='harman123', cnopts=cnopts)
server.put(reportFilePath, dashboard_report_path)
server.close()
except Exception as e:
print(str(e))
os.chdir(Log.Path)
time.sleep(10)

4 Replies