summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2008-11-20 22:03:50 +0000
committerNick Mathewson <nickm@torproject.org>2008-11-20 22:03:50 +0000
commit3b50b5c9971acfcc49e11a732061ce1414211ab2 (patch)
treef0bc670b8de1944e5fb90053b97623ee2d4861de /lib
parentb6380e73f9800c7d14f8379248592b23d1a527d5 (diff)
Fall back to using built-in db rather than registry when some clever person decides to try installing a win32 binary on their linux box.
git-svn-id: file:///home/or/svnrepo/updater/trunk@17340 55e972cd-5a19-0410-ae62-a4d7a52db4cd
Diffstat (limited to 'lib')
-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)