2013-03-19 6 views
0

DNS에 나열되지 않은 서버에 연결하려고합니다. 단지 ip가있는 서버입니다.파이썬에서 wnet_connect (호스트, 사용자 이름 = 없음, 암호 = 없음)를 사용합니다.

netpath = r'\\10.5.1.22\Products' 
    networkPath = netpath 
    unc = ''.join(['\\\\', host]) 
    print unc 
    try: 
      win32wnet.WNetAddConnection2(0, None, unc, None, username, password) 
    except Exception, err: 
     if isinstance(err, win32wnet.error): 
      #Disconnect previous connections if detected, and reconnect. 
      if err[0] == 1219: 
       win32wnet.WNetCancelConnection2(unc, 0, 0) 
       return wnet_connect(host, username, password) 
     raise err 

내가 서버 나 컴퓨터에 연결하는 파이썬 2.7

답변

0

그것의 불가능을 사용하고이 상황에서 연결하는 더 좋은 방법이있다 :

은이 코드를 사용하여 운이 점점되지 오전 , 그것이 DNS에없는 경우.