Ask a Question

i want to upload file to server using sftp in testcomplete

SOLVED
thouhid1
Occasional Contributor

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 4
Marsha_R
Community Hero

This may be helpful for making sure that your import is correct

https://support.smartbear.com/testcomplete/docs/scripting/specifics/python.html


Marsha_R
[Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
sonya_m
SmartBear Alumni (Retired)

Thank you Marsha!

 

@thouhid1, please let us know if the provided link helps! 


Sonya Mihaljova
Community and Education Specialist

thouhid1
Occasional Contributor

This solution partially helped but resolution was something different .

we have to Install python greater than 3.6.4 to make it compatible with testcomplete . 

Also use this line to point to specific python version before importing pysftp 

os.sys.path.insert(0, "C:\\Python36\Lib\\site-packages")

sonya_m
SmartBear Alumni (Retired)

Thank you so much for sharing the solution! This is going to help a lot of people. 


Sonya Mihaljova
Community and Education Specialist

cancel
Showing results for 
Search instead for 
Did you mean: