Can I disable paramiko sftp client stat check w/o touching source code ?

Asked by kyaw z. than

I am using the sftp client in Paramiko 1.7.3 for EDI to remote sites (to push files out). On quite a few of the remote sites, it is not possible to check the status of the sent file due to restrictions (file cannot be stat'd, or file is taken away upon arrival). Thus using the put method generates a file not found error.

I currently have to edit out the remote file size checking code in the put method of the sftp_client class sftp_client.py. The code I comment out is:

<cut>
s = self.stat(remotepath)
          if s.st_size != size:
              raise IOError('size mismatch in put! %d != %d' % (s.st_size, size))
<cut>

at the end of the method.

I am wondering if there is a better way of going about this then editing the code (which is not really desirable since any upgrade or patches of paramiko would have to keep this in mind).

I could use the the OS's sftp with pyexpect, but since I have already invested time in paramiko for other purposes as well, I want to continue using it. Any suggestions would be much appreciated.

thanks,
kyaw than

Question information

Language:
English Edit question
Status:
Solved
For:
paramiko Edit question
Assignee:
No assignee Edit question
Solved by:
Jonathan Marsden
Solved:
Last query:
Last reply:
Revision history for this message
Best Jonathan Marsden (jmarsden) said :
#1

I suggest that you contact the author of paramiko and ask them to make this check optional.
(Either an additional parameter to the put method, or a separate put_no_check method could be implemented?). If you have the Python skills to create and test a patch to this effect, I suspect that might be appreciated.

This way, future upgrades will continue to contain the fix, and also other users of paramiko will benefit.

You *could* file a wishlist bug about this here on Launchpad, but since the issue is not Ubuntu-specific, I don't think that is a good way forward in this case.

Jonathan

Revision history for this message
kyaw z. than (kyawzthan) said :
#2

Hi Jonathan,

Thanks for your prompt reply (and sorry for my tardiness !).
I think I will take up your suggestion wrt providing a patch. It probably will not happen until next month or so though; I am caught up in an ERP upgrade that I can't shake loose from.

Thanks a lot.

Revision history for this message
kyaw z. than (kyawzthan) said :
#3

Thanks Jonathan Marsden, that solved my question.