summaryrefslogtreecommitdiff
path: root/lib/thandy
diff options
context:
space:
mode:
Diffstat (limited to 'lib/thandy')
-rw-r--r--lib/thandy/packagesys/ExePackages.py26
-rw-r--r--lib/thandy/util.py5
2 files changed, 21 insertions, 10 deletions
diff --git a/lib/thandy/packagesys/ExePackages.py b/lib/thandy/packagesys/ExePackages.py
index e5b843b..9bda833 100644
--- a/lib/thandy/packagesys/ExePackages.py
+++ b/lib/thandy/packagesys/ExePackages.py
@@ -57,19 +57,25 @@ class ExePackageHandle(pdb.DBBackedPackageHandle):
def getInstalledVersion(self, transaction=None):
if self._registry_ent != None:
- ver = thandy.util.getRegistryValue(self._registry_ent[0])
- if ver != None:
- return ver
- else:
- return pdb.DBBackedPackageHandle.getInstalledVersion(self, transaction)
+ try:
+ ver = thandy.util.getRegistryValue(self._registry_ent[0])
+ if ver != None:
+ return ver
+ except thandy.util.NoRegistry:
+ pass
+
+ return pdb.DBBackedPackageHandle.getInstalledVersion(self, transaction)
def isInstalled(self, transaction=None):
if self._registry_ent != None:
- ver = thandy.util.getRegistryValue(self._registry_ent[0])
- if ver == self._registry_ent[1]:
- return True
- else:
- return pdb.DBBackedPackageHandle.isInstalled(self, transaction)
+ try:
+ ver = thandy.util.getRegistryValue(self._registry_ent[0])
+ if ver == self._registry_ent[1]:
+ return True
+ except thandy.util.NoRegistry:
+ pass
+
+ return pdb.DBBackedPackageHandle.isInstalled(self, transaction)
def _doInstall(self):
diff --git a/lib/thandy/util.py b/lib/thandy/util.py
index ff617ae..ad69fa0 100644
--- a/lib/thandy/util.py
+++ b/lib/thandy/util.py
@@ -109,8 +109,13 @@ def randChooseWeighted(lst):
return lst[-1][1]
+class NoRegistry(thandy.Exception):
+ pass
+
def getRegistryValue(keyname):
"""Read the contents of a Windows registry key from a given base."""
+ if _winreg is None:
+ raise NoRegistry()
hkey, rest = keyname.split("\\", 1)
key, value = rest.rsplit("\\", 1)