python und win32com

Sockets, TCP/IP, (XML-)RPC und ähnliche Themen gehören in dieses Forum
Antworten
matze80

Hallo,

habe ein kleines Problem mit Python und Windows. Ich versuche gerade ein Tool zu schreiben, welches mir die IP Adresse für einen Windows Netzwerkadapter setzt. Ich verwende "python-2.4.1.msi" und "win32-py2.41.exe".

Mein Problem ist die EnableStatic Methode von Win32_NetworkAdapterConfiguration.

---snip---

Code: Alles auswählen

def setIP():

    strIPAddress = ["192.168.0.1"]
    strSubnetMask = ["255.255.255.0"]


    colItems = objSWbemServices.ExecQuery("Select * from Win32_NetworkAdapterConfiguration Where IPEnabled=TRUE And Index=%s" % (index))
    for objNetAdapter in colItems:
        errEnable = objNetAdapter.EnableStatic (IPAddress=strIPAddress, SubnetMask=strSubnetMask)
        if errEnable == 0:
            print "static ip is set for network adapter %s" % (index)
        elif errEnable == 1:
            print "static ip is set for network adapter %s" % (index)
            print "to complete this, you should restart your computer"
        else:
            print "can't set static ip for network adapter %s" % (index)
---snip---

Ich bekomme immer folgenden Fehler:

--snip--

Code: Alles auswählen

errEnable = objNetAdapter.EnableStatic (IPAddress=strIPAddress, SubnetMask=s
trSubnetMask)
TypeError: 'int' object is not callable
--snip--

Habe schon eine Menge rumprobiert! Bekomme das ganze ohne die Klammern hinter EnableStatic (errEnable = objNetAdapter.EnableStatic) auch zum laufen, aber bringt natürlich nichts!

Danke, für eure Hilfe

Edit (Leonidas): Python-Code in Python-Tags gesetzt, Fehlermeldung in Code Tags.
Antworten