clean-cole / pysftp Goto Github PK
View Code? Open in Web Editor NEWGithub Fork for https://bitbucket.org/dundeemt/pysftp
License: BSD 3-Clause "New" or "Revised" License
Github Fork for https://bitbucket.org/dundeemt/pysftp
License: BSD 3-Clause "New" or "Revised" License
Hello
I use the latest pysftp 0.2.9.
I run the following code:
import pysftp
cnopts = pysftp.CnOpts()
cnopts.hostkeys = None
And receive the following error:
---------------------------------------------------------------------------
HostKeysException Traceback (most recent call last)
<ipython-input-10-7c5a03189319> in <module>
1 import pysftp
----> 2 pysftp.CnOpts()
~\Anaconda3\envs\controller2\lib\site-packages\pysftp-0.2.9-py3.7.egg\pysftp\__init__.py in __init__(self, knownhosts)
62 else:
63 if len(self.hostkeys.items()) == 0:
---> 64 raise HostKeysException('No Host Keys Found')
65
66 def get_hostkey(self, host):
HostKeysException: No Host Keys Found
Ultimately I want it to read from ~/.ssh/known_hosts
or just leave bypass the host keys but I get the error even before I am able to set it as such.
Please advise
I am stuck bashing my head against the wall trying to make this work. Every single attempt has failed including launching my py script via bash from cron.
The script works fine when ran manually but refuses to find the known_hosts file? or just fails to import the module entirely. As far as i can tell the pysftp module is being load it just not doing anything useful.
`import pysftp
import datetime
import os
import sys
modulename = 'pysftp'
if modulename not in sys.modules:
print("You have not imported the {} module" % modulename)
myHostname = ""
myUsername = "
myPassword = "
remote_path = "/home/remote/"
local_path = "/home/local/"
todaysDate = datetime.datetime.today().strftime('%Y-%m-%d/')
wanted_files = [
"filename1",
"filename2"
]
todaysDownloadDir = os.path.join(local_path, todaysDate)
#print(todaysDownloadDir)
if os.path.isdir(todaysDownloadDir):
print("Dir exists")
else:
print("need to mkdir")
os.mkdir(todaysDownloadDir)
with pysftp.Connection(host=myHostname, username=myUsername, password=myPassword, log=True) as sftp:
print("Connection succesfully stablished ... ")
for i in wanted_files:
localFilePath = todaysDownloadDir + i
remoteFilePath = remote_path + i
print("local->%s, remote->%s" % (localFilePath,remoteFilePath))
sftp.get(remoteFilePath, localFilePath)
sftp.close()
`
The above works when ran manually but simply prints " need to mkdir " then exists when ran via cron
Hello! Could we please have the ability to change the timeout value when calling the Connection method? Something as simple as adding a timeout=
parameter would be fantastic.
Hello!
Not sure if this is a pysftp bug but as of late I am getting an error message that states:
Exception ignored in: <function Connection.__del__ at 0x000001A9EF6CD288> Traceback (most recent call last): File "C:\Users\21321\AppData\Roaming\Python\Python37\site-packages\pysftp\__init__.py", line 1013, in __del__ File "C:\Users\21321\AppData\Roaming\Python\Python37\site-packages\pysftp\__init__.py", line 795, in close ImportError: sys.meta_path is None, Python is likely shutting down
Whenever the connection is beeing closed. It's pointing to "import logging" in the init.py file. Thought i'd put this error here, just in case, it's not somehow my system causing the error in the first place :)
Best Regards
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.