Hi All,

I write this email as a follow up to a chat on #pylib with cfbolz. Bare with 
me in the code example and explanation because I'm only into python for six 
months or so.

The reason for this request is that I'm building an application with wx.Python 
that does remote file handling based on execnet. I was told that it's good 
practice to have exceptions raised in your code as low as possible, and 
handle them as high in your code as possible.

A brief setup of my app (just to illustrate)
gui/mainapp     (the gui)
dwlib/remote    (the remote module)

In the app (the gui) I call a function from dwlib that gets a remote 
dirlisting. If this fails the gui pops up a dialog with advice on how to 
continu. As the docs of execnet state. Errors on the remote side are raised 
as OSErrors and contain a textual version of the remote exception. Two that I 
forced (simulated):

OSError: [Errno 13] Permission denied: '/some/where'
OSError: [Errno 2] No such file or directory: '/some/whe'

This is correct behaviour but I would like to have them as actual exceptions 
back up to the interface. In this case I have to parse the string in the 
dwlib module with something like "if value.startswith(OSError')" and raise 
another exception my self. 

So the request is: Is it possible to actually have the Exception from the 
remote side passed on as an exception object to the local side (or recreate 
one?!?).

Attached is a script that simulates the problem. There are SSH keys in place, 
so (local)host access is functioning. As said I'm not a python guru (yet). so 
please don't shoot my code ... :-)

I hope all is clear. Questions on the mather (and tips) are very welcome.

Kind regards,

Gerard.


-- 
$Grtz =~ Gerard;
~
:wq!


Attachment: fileread.py
Description: application/python

_______________________________________________
py-dev mailing list
py-dev@codespeak.net
http://codespeak.net/mailman/listinfo/py-dev

Reply via email to