The reason for the error:
'NoneType' object has no attribute '___getitem___'
Is in the line:
keyCheck = (edit_registry.CheckRegistryKey("machine", r"SOFTWARE\Wow6432Node\Microsoft\VisualStudio\10.0\VC\VCRedist", "x86", "Installed"))[0]
The fragment edit_registry.CheckRegistryKey("machine", r"SOFTWARE\Wow6432Node\Microsoft\VisualStudio\10.0\VC\VCRedist", "x86", "Installed")
is returning None
.
This means you end up with:
keyCheck = (None)[0]
This is what is throwing your error. You are trying to get an item on a object that is None.
The reason that this you are getting None
back from your CheckRegistryKey
function is that if an error occurs you aren't returning anything. You need to return False
when you catch a EnvironmentError
:
try:
aSubKey=OpenKey(aKey,softwareName)
val=QueryValueEx(aSubKey, keyName)
return val
except EnvironmentError:
return False
I would also modify your code so that you are only calling CheckRegistryKey
once:
registryKey = edit_registry.CheckRegistryKey("machine", r"SOFTWARE\Wow6432Node\Microsoft\VisualStudio\10.0\VC\VCRedist", "x86", "Installed")
if registryKey is not False:
keyCheck = registryKey[0]