Bug 1130905 - [mozinstall] Fix re-raising of exception in case of failing install or uninstall. r=ahal
--- 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',