Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
PySFTP ChDir Error490
#1
Hello. I am trying to figure out why I keep getting this error where I try to change the directory (see code below)
OverflowError: mode out of range


But this for statement works if I put the same string defined as remotepath and then upload the files. The files were successfully uploaded using the remotepath and filename combination. Is there something I am missing below in the code that generates the error or is it an issue with the directory? I tried researching to see if there is a similar error out there, but could not find.

uploadlist=glob.glob('*.csv')

remotepath = '/data/PG'

for file in uploadlist:
dest.put(file,remotepath + file)


dest = pysftp.Connection('server',username='user',password='password', cnopts=cnopts)
loc=dest.chdir('data/PG')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Anaconda_Python\lib\site-packages\pysftp\__init__.py", line 524, in chdir
    self._sftp.chdir(remotepath)
  File "C:\Anaconda_Python\lib\site-packages\paramiko\sftp_client.py", line 615, in chdir
    if not stat.S_ISDIR(self.stat(path).st_mode):
OverflowError: mode out of range
Reply
#2
I think the issue with this is that pysftp does not recognize what I am passing it as a directory. I find that odd because it is a directory. Other forums have this question about the os module, but not for pysftp. I was able to implement when adding another / since the os module sees just one / as an escape character. But that did not work for pysftp.isdir. The isdir method returns false. Am I missing something in my code below? Thanks

import pysftp
dest = pysftp.Connection('server',username='user',password='password', cnopts=cnopts)
remotepath = '/d/dt/PGG/Archive'
dest.isdir('remotepath')
False
Reply
#3
Anybody have any suggestions? Thank you
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  pysftp connection issue geil007 0 2,784 May-18-2022, 08:40 AM
Last Post: geil007
  Does pysftp need a logout? Pedroski55 2 3,310 Jun-24-2019, 10:05 PM
Last Post: Pedroski55
  Use pysftp to get the content of a remote folder Pedroski55 0 6,898 Jun-18-2019, 09:22 AM
Last Post: Pedroski55
  pysftp pop-up 'Client forking' micksulley 5 3,323 Dec-21-2018, 02:07 AM
Last Post: Larz60+
  PYSFTP - Password Change torz 0 2,393 Dec-11-2017, 02:32 AM
Last Post: torz

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020