Coder Social home page Coder Social logo

pysftp's People

Contributors

artlogic avatar dreilly1982 avatar dundeemt avatar remik avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

pysftp's Issues

pysftp.CnOpts() gives No Host Keys Found

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

Has anyone tamed this beast to work with cron?

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

ImportError: sys.meta_path is None, Python is likely shutting down

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.