Bug 1130905 - [mozinstall] Fix re-raising of exception in case of failing install or uninstall. r=ahal
authorHenrik Skupin <mail@hskupin.info>
Mon, 09 Feb 2015 19:03:27 +0100
changeset 241831 b7a61f34185e4128b5155cc3eedfcc7cf6a90f65
parent 241830 9b6aa9b4039b4f4b3bec47bf8ef90d6f4688ca87
child 241832 a19cb997c0268d3cc1382b65214233d5976b3e50
push id624
push userdburns@mozilla.com
push dateTue, 10 Feb 2015 13:30:25 +0000
reviewersahal
bugs1130905
milestone38.0a1
Bug 1130905 - [mozinstall] Fix re-raising of exception in case of failing install or uninstall. r=ahal
testing/mozbase/mozinstall/mozinstall/mozinstall.py
--- a/testing/mozbase/mozinstall/mozinstall/mozinstall.py
+++ b/testing/mozbase/mozinstall/mozinstall/mozinstall.py
@@ -121,17 +121,17 @@ def install(src, dest):
             install_dir = _install_dmg(src, dest)
         elif src.lower().endswith('.exe'):
             install_dir = _install_exe(src, dest)
 
         return install_dir
 
     except Exception, ex:
         cls, exc, trbk = sys.exc_info()
-        error = InstallError('Failed to install "%s (%s)"' % src, str(ex))
+        error = InstallError('Failed to install "%s (%s)"' % (src, str(ex)))
         raise InstallError, error, trbk
 
     finally:
         # trbk won't get GC'ed due to circular reference
         # http://docs.python.org/library/sys.html#sys.exc_info
         del trbk
 
 
@@ -195,32 +195,32 @@ def uninstall(install_folder):
         uninstall_folder = '%s\uninstall' % install_folder
         log_file = '%s\uninstall.log' % uninstall_folder
 
         if os.path.isfile(log_file):
             trbk = None
             try:
                 cmdArgs = ['%s\uninstall\helper.exe' % install_folder, '/S']
                 result = subprocess.call(cmdArgs)
-                if not result is 0:
+                if result is not 0:
                     raise Exception('Execution of uninstaller failed.')
 
                 # The uninstaller spawns another process so the subprocess call
                 # returns immediately. We have to wait until the uninstall
                 # folder has been removed or until we run into a timeout.
                 end_time = time.time() + TIMEOUT_UNINSTALL
                 while os.path.exists(uninstall_folder):
                     time.sleep(1)
 
                     if time.time() > end_time:
                         raise Exception('Failure removing uninstall folder.')
 
             except Exception, ex:
                 cls, exc, trbk = sys.exc_info()
-                error = UninstallError('Failed to uninstall %s (%s)' % install_folder, str(ex))
+                error = UninstallError('Failed to uninstall %s (%s)' % (install_folder, str(ex)))
                 raise UninstallError, error, trbk
 
             finally:
                 # trbk won't get GC'ed due to circular reference
                 # http://docs.python.org/library/sys.html#sys.exc_info
                 del trbk
 
     # Ensure that we remove any trace of the installation. Even the uninstaller
@@ -283,17 +283,17 @@ def _install_exe(src, dest):
     dest = os.path.join(dest, filename.split('.')[0])
 
     # possibly gets around UAC in vista (still need to run as administrator)
     os.environ['__compat_layer'] = 'RunAsInvoker'
     cmd = [src, '/S', '/D=%s' % os.path.realpath(dest)]
 
     # As long as we support Python 2.4 check_call will not be available.
     result = subprocess.call(cmd)
-    if not result is 0:
+    if result is not 0:
         raise Exception('Execution of installer failed.')
 
     return dest
 
 
 def install_cli(argv=sys.argv[1:]):
     parser = OptionParser(usage="usage: %prog [options] installer")
     parser.add_option('-d', '--destination',