'Python pysftp get_r from Linux works fine on Linux but not on Windows

I would like to copy an entire directory structure with files and subfolders recursively using SFTP from a Linux server to a local machine (both Windows and Linux) using Python 2.7.

I am able to ping the server and download the files using WinSCP from the same machine.

I tried the following code, works fine on Linux but not on Windows.

I tried \, /, os.join, all gives me same error, checked permissions as well.

import os
import pysftp

cnopts = pysftp.CnOpts()
cnopts.hostkeys = None    # disable host key checking.
sftp=pysftp.Connection('xxxx.xxx.com', username='xxx', password='xxx', cnopts=cnopts)
sftp.get_r('/abc/def/ghi/klm/mno', 'C:\pqr', preserve_mtime=False)
File "<stdin>", line 1, in <module> File "C:\Python27\lib\site-packages\pysftp_init_.py", line 311, in get_r preserve_mtime=preserve_mtime)
File "C:\Python27\lib\site-packages\pysftp_init_.py", line 249, in get self._sftp.get(remotepath, localpath, callback=callback)
File "C:\Python27\lib\site-packages\paramiko\sftp_client.py", line 769, in get with open(localpath, 'wb') as fl: IOError: [Errno 2] No such file or directory: u'C:\\pqr\\./abc/def/ghi/klm/mno/.nfs0000000615c569f500000004' 


Solution 1:[1]

Script setup is not exposed by default in subcomponents, if you need to use the sub-component you need to use the defineExpose API, like this:

export interface XXXAPI{
  loginAction:typeof loginAction
}

const loginAction = ()=>{
  // do something
}

defineExpose({
  loginAction
})

parent component:

const accountRef = ref<XXXAPI>();


const handleClickLogin = () =>{
  accountRef.value?.loginAction();
}

Solution 2:[2]

Try to use Ref

import { Ref } from "vue"

const accountRef = Ref<InstanceTyp<typeof LoginAccount>>()

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2 linka