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

IOError is masked by SCPException #82

Closed
nvgoldin opened this issue Dec 15, 2016 · 3 comments
Closed

IOError is masked by SCPException #82

nvgoldin opened this issue Dec 15, 2016 · 3 comments

Comments

@nvgoldin
Copy link

Hi,
this line https://github.com/jbardin/scp.py/blob/master/scp.py#L348 masks IOError exception when no file or directory exists, which makes it hard to catch the exception:

  File "/home/ngoldin/virtualenv/lago-venv/lib/python2.7/site-packages/scp.py", line 198, in get
    self._recv_all()
  File "/home/ngoldin/virtualenv/lago-venv/lib/python2.7/site-packages/scp.py", line 348, in _recv_all
    raise SCPException(asunicode(msg[1:]))
SCPException: scp: /var/koko/bobo: No such file or directory

If I understand correctly, the docs state that all IOError errors should be thrown.

@remram44
Copy link
Collaborator

remram44 commented Dec 15, 2016

It doesn't really. There are places in the code where it does, but this particular line raised an SCPException for an error sent by the server.

@nvgoldin
Copy link
Author

nvgoldin commented Jan 1, 2017

Ok, thanks for clarifying. Any special reason for this behaviour? Would it be (easily) possible to change it?
Currently what I did is run re.match on the exception, but I think that is fragile.

@remram44
Copy link
Collaborator

remram44 commented Jan 3, 2017

There is no standard for error codes in the SCP protocol, all you get is the human-readable string for server errors. scp.py cannot do better than your re.match unfortunately.

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

2 participants