I'm using the win32 api to map samba shares, and I'm having trouble
handling some exceptions. In my script there are 2 possible exceptions
when the script attempts to map a share:
[color=blue][color=green][color=darkred]
>>> win32net.NetUse Add(None, 1, {'remote':r'\\f oo\bar','local' :'X[/color][/color][/color]
Traceback (most recent call last):
File "<stdin>", line 1, in ?
pywintypes.erro r: (53, 'NetUseAdd', 'The network path was not found.')
This exception occurs when '\\foo\bar' is not an existing share. Also,
when a drive letter is already in use the following occurs:
[color=blue][color=green][color=darkred]
>>> win32net.NetUse Add(None, 1,[/color][/color][/color]
{'remote':r'\\s ome_server\shar e','local':'Y:' })
Traceback (most recent call last):
File "<stdin>", line 1, in ?
pywintypes.erro r: (85, 'NetUseAdd', 'The local device name is already
in use.')
I know the exception raised in these cases is "pywintypes.err or", but
how can i differentiate between the two exceptions? Being able to do
this is critical for my script....
Thanks in advance,
--Lucas Machado
handling some exceptions. In my script there are 2 possible exceptions
when the script attempts to map a share:
[color=blue][color=green][color=darkred]
>>> win32net.NetUse Add(None, 1, {'remote':r'\\f oo\bar','local' :'X[/color][/color][/color]
Traceback (most recent call last):
File "<stdin>", line 1, in ?
pywintypes.erro r: (53, 'NetUseAdd', 'The network path was not found.')
This exception occurs when '\\foo\bar' is not an existing share. Also,
when a drive letter is already in use the following occurs:
[color=blue][color=green][color=darkred]
>>> win32net.NetUse Add(None, 1,[/color][/color][/color]
{'remote':r'\\s ome_server\shar e','local':'Y:' })
Traceback (most recent call last):
File "<stdin>", line 1, in ?
pywintypes.erro r: (85, 'NetUseAdd', 'The local device name is already
in use.')
I know the exception raised in these cases is "pywintypes.err or", but
how can i differentiate between the two exceptions? Being able to do
this is critical for my script....
Thanks in advance,
--Lucas Machado
Comment