I am quite new to programming and have written a simple piece of code to check for the presence of a specific name within the windows device manager.
I am using the following library https://pypi.org/project/infi.devicemanager/
my function:
def searchdongle():
found = 0
devicesname = ""
dm = DeviceManager()
dm.root.rescan()
devices = dm.all_devices
for device in devices:
#print(device)
devicesname = device
print(devicesname)
#if devicesname == "<Gaurdant Code>":
if "Gaurdant" in devicesname and "Code" in devicesname:
found = 1
print("Found it!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!")
return found
But I cannot detect the name at all. I believe this is because Device is of type "Device" and not a string??? how would I cast this to a string to test??? I did try using the python IN operator but got the error TypeError: argument of type 'Device' is not iterable
testing both print statements yields the correct results:
Any help appreciated thanks