Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error "raise IOError(text)" when transfer file #1860

Open
leafonsword opened this issue Aug 23, 2018 · 4 comments
Open

Error "raise IOError(text)" when transfer file #1860

leafonsword opened this issue Aug 23, 2018 · 4 comments

Comments

@leafonsword
Copy link

leafonsword commented Aug 23, 2018

my code is

from fabric import Connection
result = Connection('xx.xx.xx.xx').put('/tmp/wan.txt', remote='/tmp/')
print("Uploaded {0.local} to {0.remote}".format(result))

I got Error:

/.local/share/virtualenvs/playbook-zVtSjadl/lib/python3.6/site-packages/paramiko/sftp_client.py
  File "/root/.local/share/virtualenvs/playbook-zVtSjadl/lib/python3.6/site-packages/fabric/transfer.py", line 225, in put
    sftp.put(localpath=local, remotepath=remote)
  File "/root/.local/share/virtualenvs/playbook-zVtSjadl/lib/python3.6/site-packages/paramiko/sftp_client.py", line 727, in put
    return self.putfo(fl, remotepath, file_size, callback, confirm)
  File "/root/.local/share/virtualenvs/playbook-zVtSjadl/lib/python3.6/site-packages/paramiko/sftp_client.py", line 683, in putfo
    with self.file(remotepath, 'wb') as fr:
  File "/root/.local/share/virtualenvs/playbook-zVtSjadl/lib/python3.6/site-packages/paramiko/sftp_client.py", line 341, in open
    t, msg = self._request(CMD_OPEN, filename, imode, attrblock)
  File "/root/.local/share/virtualenvs/playbook-zVtSjadl/lib/python3.6/site-packages/paramiko/sftp_client.py", line 780, in _request
    return self._read_response(num)
  File "/root/.local/share/virtualenvs/playbook-zVtSjadl/lib/python3.6/site-packages/paramiko/sftp_client.py", line 832, in _read_response
    self._convert_status(msg)
  File "/root/.local/share/virtualenvs/playbook-zVtSjadl/lib/python3.6/site-packages/paramiko/sftp_client.py", line 865, in _convert_status
    raise IOError(text)
OSError: Failure 

And I found stackoverflow has gave the error:
Python paramiko SFTP IOError

@mathiasbc
Copy link

I have the same problem @leafonsword, did you manage to overcome this ? Strange thing about my code is that it worked for months until one this started happening.

@leafonsword
Copy link
Author

@mathiasbc I'm also waiting~

@JackelynOliveira
Copy link

JackelynOliveira commented Oct 13, 2022

I had the same error. I'm using Fabric version 2.7.0 and I needed to transfer a file from a Linux host to a Windows host.
I tried the fix suggested on that StackOverflow question that @leafonsword attached here (which is basically specifying both the path and the desired filename on the remote host) but it did not work.
I had something like that:

conn.put("/folder/filename.extension", "c:/users/myuser/filename.extension")

I couldn't understand why it was not working. Looking at Fabric documentation regarding transfer it is mentioned an OSError error will be raised if a nonexisting local path is specified, but that was not the case.
So I started looking on how I could troubleshoot this error and I found this page. I enabled debug logging level as instructed there and I saw the following log:

DEBUG:fabric:Massaged relative remote path 'c:/users/myuser/filename.extension' into '/C:/Users/myuser/c:/users/myuser/filename.extension'

So Fabric is actually rewriting the remote path I specify!
The solution for me was omitting the remote path altogether, like that:

conn.put("/folder/filename.extension")

But this Fabric behavior does look like a bug. It should be looked into.

@honglei
Copy link

honglei commented Oct 25, 2023

If paramiko failed to open the remote path /home/uos/inotify-info when put file,it will raise builtins.OSError: Failure

INFO:paramiko.transport.sftp:[chan 1] Opened sftp connection (server version 3)
DEBUG:paramiko.transport.sftp:[chan 1] normalize(b'.')
DEBUG:fabric:Massaged relative remote path 'inotify-info' into '/home/uos/inotify-info'
DEBUG:fabric:Massaged relative local path PureWindowsPath('../tools/inotify-info') into 'E:\\PythonPrj\\6xx\\cetc54trans\\tools\\inotify-info'
DEBUG:fabric:Uploading 'E:\\PythonPrj\\6xx\\tools\\inotify-info' to '/home/uos/inotify-info'
DEBUG:paramiko.transport.sftp:[chan 1] open(b'/home/uos/inotify-info', 'wb')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants