Skip to content

Commit

Permalink
Merged 2012.2 branch
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelDCurran committed May 21, 2012
2 parents fb92374 + 320fd5d commit faefdd2
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 30 deletions.
6 changes: 3 additions & 3 deletions source/gui/installerGui.py
Expand Up @@ -29,7 +29,7 @@ def doInstall(createDesktopShortcut,startOnLogon,copyPortableConfig,isUpdate,sil
else _("Please wait while NVDA is being installed"))
try:
res=config.execElevated(config.SLAVE_FILENAME,["install",str(int(createDesktopShortcut)),str(int(startOnLogon))],wait=True,handleAlreadyElevated=True)
if res==2: raise installer.RetriableFailier
if res==2: raise installer.RetriableFailure
if copyPortableConfig:
installedUserConfigPath=config.getInstalledUserConfigPath()
if installedUserConfigPath:
Expand All @@ -39,7 +39,7 @@ def doInstall(createDesktopShortcut,startOnLogon,copyPortableConfig,isUpdate,sil
log.error("Failed to execute installer",exc_info=True)
progressDialog.done()
del progressDialog
if isinstance(res,installer.RetriableFailier):
if isinstance(res,installer.RetriableFailure):
# Translators: a message dialog asking to retry or cancel when NVDA install fails
message=_("The installation is unable to remove or overwrite a file. Another copy of NVDA may be running on another logged-on user account. Please make sure all installed copies of NVDA are shut down and try the installation again.")
# Translators: the title of a retry cancel dialog when NVDA installation fails
Expand Down Expand Up @@ -212,7 +212,7 @@ def doCreatePortable(portableDirectory,copyUserConfig=False):
except Exception as e:
log.error("Failed to create portable copy",exc_info=True)
d.done()
if isinstance(e,installer.RetriableFailier):
if isinstance(e,installer.RetriableFailure):
# Translators: a message dialog asking to retry or cancel when NVDA portable copy creation fails
message=_("NVDA is unable to remove or overwrite a file.")
# Translators: the title of a retry cancel dialog when NVDA portable copy creation fails
Expand Down
52 changes: 27 additions & 25 deletions source/installer.py
Expand Up @@ -115,7 +115,7 @@ def copyProgramFiles(destPath):
try:
os.rename(destFilePath,tempPath)
except (WindowsError,OSError):
raise RetriableFailier("Failed to rename %s after failed remove"%destFilePath)
raise RetriableFailure("Failed to rename %s after failed remove"%destFilePath)
if windll.kernel32.MoveFileExW(u"\\\\?\\"+tempPath,None,4)==0:
raise OSError("Unable to mark file %s for delete on reboot"%tempPath)
if windll.kernel32.CopyFileW(u"\\\\?\\"+sourceFilePath,u"\\\\?\\"+destFilePath,False)==0:
Expand All @@ -136,7 +136,7 @@ def copyUserConfig(destPath):
try:
os.rename(destFilePath,tempPath)
except (WindowsError,OSError):
raise RetriableFailier("Failed to rename %s after failed remove"%destFilePath)
raise RetriableFailure("Failed to rename %s after failed remove"%destFilePath)
if windll.kernel32.MoveFileExW(u"\\\\?\\"+tempPath,None,4)==0:
raise OSError("Unable to mark file %s for delete on reboot"%tempPath)
if windll.kernel32.CopyFileW(u"\\\\?\\"+sourceFilePath,u"\\\\?\\"+destFilePath,False)==0:
Expand Down Expand Up @@ -220,22 +220,36 @@ def unregisterInstallation():
except WindowsError:
pass

class RetriableFailier(Exception):
class RetriableFailure(Exception):
pass

MB_RETRYCANCEL=0x5
MB_SYSTEMMODAL=0x1000
IDRETRY=4
IDCANCEL=3
def tryRemoveFile(path,numRetries=6,retryInterval=0.5):
def tryRemoveFile(path,numRetries=6,retryInterval=0.5,rebootOK=False):
dirPath=os.path.dirname(path)
tempPath=tempfile.mktemp(dir=dirPath)
try:
os.rename(path,tempPath)
except (WindowsError,IOError):
raise RetriableFailure("Failed to rename file %s before remove"%path)
for count in xrange(numRetries):
try:
os.remove(path)
if os.path.isdir(tempPath):
os.rmdir(tempPath)
else:
os.remove(tempPath)
return
except OSError:
pass
time.sleep(retryInterval)
raise RetriableFailier("File %s could not be removed"%path)
if rebootOK:
log.debugWarning("Failed to delete file %s, marking for delete on reboot"%tempPath)
if windll.kernel32.MoveFileExA("\\\\?\\"+tempPath,None,4)==0:
raise OSError("Unable to mark file %s for delete on reboot"%tempPath)
return
try:
os.rename(tempPath,path)
except:
log.error("Unable to rename back to %s before retriable failier"%path)
raise RetriableFailure("File %s could not be removed"%path)

def install(shouldCreateDesktopShortcut=True,shouldRunAtLogon=True):
prevInstallPath=getInstallPath(noDefault=True)
Expand All @@ -259,7 +273,7 @@ def install(shouldCreateDesktopShortcut=True,shouldRunAtLogon=True):
f=os.path.join(installDir,f)
if os.path.isfile(f):
if windll.kernel32.CopyFileW(u"\\\\?\\"+f,u"\\\\?\\"+os.path.join(installDir,"nvda.exe"),False)==0:
raise RetriableFailier("Error copying %s to nvda.exe, error %d"%(f,GetLastError()))
raise RetriableFailure("Error copying %s to nvda.exe, error %d"%(f,GetLastError()))
break
else:
raise RuntimeError("No available executable to use as nvda.exe")
Expand All @@ -277,20 +291,8 @@ def removeOldLoggedFiles(installPath):
lines.append(os.path.join(installPath,'uninstall.dat'))
for line in lines:
filePath=line.rstrip('\n')
try:
if os.path.isfile(filePath):
os.remove(filePath)
elif os.path.isdir(filePath):
os.rmdir(filePath)
except WindowsError:
log.debugWarning("Failed to remove %s, removing on reboot"%filePath)
tempPath=tempfile.mktemp(dir=installPath)
try:
os.rename(filePath,tempPath)
except (WindowsError,IOError):
raise RetriableFailier("Failed to rename file %s after failed remove"%filePath)
if windll.kernel32.MoveFileExA("\\\\?\\"+tempPath,None,4)==0:
raise OSError("Unable to mark file %s for delete on reboot"%tempPath)
if os.path.exists(filePath):
tryRemoveFile(filePath,rebootOK=True)

def createPortableCopy(destPath,shouldCopyUserConfig=True):
destPath=os.path.abspath(destPath)
Expand Down
2 changes: 1 addition & 1 deletion source/nvda_slave.pyw
Expand Up @@ -24,7 +24,7 @@ def main():
import installer
try:
installer.install(bool(int(args[0])),bool(int(args[1])))
except installer.RetriableFailier:
except installer.RetriableFailure:
logHandler.log.error("Installation failed, try again",exc_info=True)
sys.exit(2)
elif action=="unregisterInstall":
Expand Down
2 changes: 1 addition & 1 deletion user_docs/en/changes.t2t
Expand Up @@ -8,7 +8,7 @@ Highlights of this release include an in-built installer and portable creation

== New Features ==
- NVDA can now automatically check for, download and install updates. (#73)
- Extending NVDA's functionality has been made easier with the addition of an Add-ons Manager (found under Tools in the NVDA menu) allowing you to install and uninstall new NVDA add-on packages (.nvda-addon files) containing plugins and drivers. Note the Add-on manager does not show older custom plugins and drivers manually copied in to your configuration directory. (#213)
- Extending NVDA's functionality has been made easier with the addition of an Add-ons Manager (found under Tools in the NVDA menu) allowing you to install and uninstall new NVDA add-on packages (.nvda-addon files) containing plugins and drivers. Note the Add-on manager does not show older custom plugins and drivers manually copied in to your configuration directory. (#213)
- Many more common NVDA features now work in Windows 8 Metro style apps when using an installed release of NVDA, including speaking of typed characters, and browse mode for web documents (includes support for metro version of Internet Explorer 10). Portable copies of NVDA cannot access metro style apps. (#1801)
- In browse mode documents (Internet Explorer, Firefox, etc.), you can now jump to the start and past the end of certain containing elements (such as lists and tables) with shift+, and , respectively. (#123)
- New language: Greek.
Expand Down

0 comments on commit faefdd2

Please sign in to comment.