Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

win32wnet.WNetAddConnection2 to specific network interface?

40 views
Skip to first unread message

Sean DiZazzo

unread,
Apr 14, 2010, 6:18:11 PM4/14/10
to
Hi!

I have a small app that uses pywin32 to log on to a remote host and
send some files around. It works well, but I've found a machine that
the app won't work on.

The machine is dual-homed, with one interface able to see the server
machine, but the other can not. I don't have the exact error because
I can't currently get on to the machine where the app fails, but I am
told it is something like that "that server doesn't exist".

Could it be that it is trying to use the wrong interface? ie. The
interface on the wrong vlan? If so, is there a way to force the
connection to go to a specific interface? I'll post the exact error
after I can get on that machine. Thanks!

~Sean

I'm using this wnet_connect() function that I found somewhere. It
works perfectly except on this one machine.

def wnet_connect(self, host, username, password):
unc = ''.join(['\\\\', host])
try:
win32wnet.WNetAddConnection2(win32.RESOURCETYPE_DISK,
None,
unc,
None, username, password)
except Exception, err:
if isinstance(err, win32wnet.error):
if err[0] == 1219:
win32wnet.WNetCancelConnection2(unc, 0, 0)
return wnet_connect(host, username, password)
raise err


Message has been deleted

Sean DiZazzo

unread,
Apr 15, 2010, 1:12:45 AM4/15/10
to
On Apr 14, 9:22 pm, Dennis Lee Bieber <wlfr...@ix.netcom.com> wrote:
> On Wed, 14 Apr 2010 15:18:11 -0700 (PDT), Sean DiZazzo
> <half.ital...@gmail.com> declaimed the following in
> gmane.comp.python.general:

>
>
>
> >     def wnet_connect(self, host, username, password):
>
>         The presence of "self" in that parameter list implies this is a
> method defined inside a class.
>
> >                     return wnet_connect(host, username, password)
>
>         This recursive call is missing the instance reference...
>
>                                 return self.wnet_connect(...)


Wow. Good eye! To be honest, I'm not sure how that happened. I
guess it should have given me an error if it ever reached that block
though, right?

I'll take a close look at that tomorrow AM. Thanks!

~Sean

0 new messages