[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[or-cvs] r17340: {updater} Fall back to using built-in db rather than registry when som (in updater/trunk/lib/thandy: . packagesys)
Author: nickm
Date: 2008-11-20 17:03:50 -0500 (Thu, 20 Nov 2008)
New Revision: 17340
Modified:
updater/trunk/lib/thandy/packagesys/ExePackages.py
updater/trunk/lib/thandy/util.py
Log:
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.
Modified: updater/trunk/lib/thandy/packagesys/ExePackages.py
===================================================================
--- updater/trunk/lib/thandy/packagesys/ExePackages.py 2008-11-20 21:55:35 UTC (rev 17339)
+++ updater/trunk/lib/thandy/packagesys/ExePackages.py 2008-11-20 22:03:50 UTC (rev 17340)
@@ -57,21 +57,27 @@
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):
commandline = [ self._filename ] + self._arguments
logging.info("Installing %s. Command line: %s", self._filename,
Modified: updater/trunk/lib/thandy/util.py
===================================================================
--- updater/trunk/lib/thandy/util.py 2008-11-20 21:55:35 UTC (rev 17339)
+++ updater/trunk/lib/thandy/util.py 2008-11-20 22:03:50 UTC (rev 17340)
@@ -109,8 +109,13 @@
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)