ich habe da mal wieder so ein sch.. Problem mit dem Windows Client, vermute ich. Mein Code ist übersichtlich :
Code: Alles auswählen
from CANOE_Interface import *
canoe_inst = CANoe()
def main(args):
canoe_inst.Start()
canoe_inst.SetSysVar('SmokeTest','svTestStart',1)
return 0
if __name__ == '__main__':
import sys
sys.exit(main(sys.argv))
Folgende Fehlermeldung kommt :
Traceback (most recent call last):
File "CANoe_Test.py", line 37, in <module>
sys.exit(main(sys.argv))
File "CANoe_Test.py", line 31, in main
canoe_inst.SetSysVar('SmokeTest','svTestStart',1)
File "D:\DSUsers\uid02589\PLAST\CANOE_Interface.py", line 439, in SetSysVar
varType = self.GetSysVarType(varNamespace, varName)
File "D:\DSUsers\uid02589\PLAST\CANOE_Interface.py", line 415, in GetSysVarType
varType = self.Application.System.Namespaces(varNamespace).Variables(varName).Type
File "C:\LegacyApp\Python36\lib\site-packages\win32com\client\__init__.py", line 473, in __getattr__
raise AttributeError("'%s' object has no attribute '%s'" % (repr(self), attr))
AttributeError: '<win32com.gen_py.CANoe 10.0 Type Library.IVariable instance at 0x2152718570720>' object has no attribute 'Type'
------------------
(program exited with code: 1)
Drücken Sie eine beliebige Taste . . .
Was "CANoe_Test.py", line 37, in <module> sys.exit(main(sys.argv)) mit dem Rest der Meldungen zu tun hat weiß ich nicht, deshalb hier mal weiter :
2. Bezieht sich auf die Zeile canoe_inst.SetSysVar('SmokeTest','svTestStart',1) , die ersten beide strings sind ok , aber die 1 sollte eine IntVar sein und das scheint das Problem zu sein.
Eine Etage tiefer beim CANoe_Interface.py dann :
Code: Alles auswählen
def SetSysVar(self, varNamespace, varName, varVal):
#Syntax SetSysVarType(varNamespace, varName, varVal)
#Description Sets the value of a SystemVariable object.
#Parameters
#1. varNamespace (string) The namespace where the system variable is stored.
#2. varName (string) The name of the system variable.
#3. varVal (varying) The value that is to be assigned to the system variable.
#Return Values -
#Example can_inst.SetSysVar('SecurityAccess', 'TesterPresentEnable', 1)
#or:
#can_inst.SetSysVar('CodingParameters::CP_F198_Param', 'ByteArray', (48, 49, 50, 51, 52, 53))
varType = self.GetSysVarType(varNamespace, varName) [b] Kommentar: hier Zeile 439 ! [/b]
if (varType is 'Integer' or 'Float' or 'String' or 'LongLong'):
self.Application.System.Namespaces(varNamespace).Variables(varName).Value = varVal
elif (varType is 'Float Array' or 'Integer Array' or 'Byte Array' or 'Generic Array'):
self.Application.System.Namespaces(varNamespace).Variables(varName).Value = varVal
elif (varType is 'Struct'):
self.Application.System.Namespaces(varNamespace).Variables(varName).Value = varVal
else: #(varType is 'Invalid')
print("Invalid System Variable Type!")
Code: Alles auswählen
############################################
# The base of all makepy generated classes
############################################
class DispatchBaseClass:
def __init__(self, oobj=None):
if oobj is None:
oobj = pythoncom.new(self.CLSID)
elif isinstance(oobj, DispatchBaseClass):
try:
oobj = oobj._oleobj_.QueryInterface(self.CLSID, pythoncom.IID_IDispatch) # Must be a valid COM instance
except pythoncom.com_error as details:
import winerror
# Some stupid objects fail here, even tho it is _already_ IDispatch!!??
# Eg, Lotus notes.
# So just let it use the existing object if E_NOINTERFACE
if details.hresult != winerror.E_NOINTERFACE:
raise
oobj = oobj._oleobj_
self.__dict__["_oleobj_"] = oobj # so we dont call __setattr__
# Provide a prettier name than the CLSID
def __getattr__(self, attr):
args=self._prop_map_get_.get(attr)
if args is None:
raise AttributeError("'%s' object has no attribute '%s'" % (repr(self), attr)) [b] Kommentar : hier Zeile 473 ! [/b]
return self._ApplyTypes_(*args)
Code: Alles auswählen
from win32com.client import DispatchBaseClass
class IAdditionalDescription(DispatchBaseClass):
'IAdditonalDescription'
CLSID = IID('{0B764757-2F83-4493-A185-E4AA29BD8EEF}')
coclass_clsid = IID('{094FC1CC-96B5-43B9-84D0-4AED35E4678C}')
def CloseWindows(self, windows=255):
'method CloseWindows'
return self._oleobj_.InvokeTypes(10, LCID, 1, (24, 0), ((3, 49),),windows
)
def OpenWindows(self, windows=255):
'method OpenWindows'
return self._oleobj_.InvokeTypes(9, LCID, 1, (24, 0), ((3, 49),),windows
)
_prop_map_get_ = {
"Application": (1, 2, (9, 0), (), "Application", None),
"DiagVariants": (3, 2, (9, 0), (), "DiagVariants", None),
"FilePath": (5, 2, (8, 0), (), "FilePath", None),
"Language": (7, 2, (8, 0), (), "Language", None),
# Method 'MasterDescription' returns object of type 'IDiagDescription'
"MasterDescription": (8, 2, (9, 0), (), "MasterDescription", '{8BDDB46D-7835-4FCE-9872-A208BE41ECC1}'),
"Name": (0, 2, (8, 0), (), "Name", None),
"Parent": (2, 2, (9, 0), (), "Parent", None),
"Qualifier": (4, 2, (8, 0), (), "Qualifier", None),
"Variant": (6, 2, (8, 0), (), "Variant", None),
}
Gruß, Hlech65730