win32wnet.WNetAddConnection2 to specific network interface?

S

Sean DiZazzo

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
 
D

Dennis Lee Bieber

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(...)
 
S

Sean DiZazzo

        The presence of "self" in that parameter list implies this is a
method defined inside a class.


        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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top