Python Forum

Full Version: PySFTP ChDir Error490
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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
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
Anybody have any suggestions? Thank you