Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Propagate CLI arguments when updating #16937

Merged
merged 10 commits into from
Aug 7, 2024
2 changes: 1 addition & 1 deletion source/speech/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def _getFormattedDevInfo(self):
def __repr__(self):
return (
f"CancellableSpeech ("
f"{ 'cancelled' if self._checkIfCancelled() else 'still valid' }"
f"{ 'cancelled' if self._checkIfCancelled() else 'still valid'}"
f"{self._getFormattedDevInfo()}"
f")"
)
Expand Down
45 changes: 33 additions & 12 deletions source/updateCheck.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,28 +237,49 @@ def executePendingUpdate():
_executeUpdate(updateTuple[0])


def _executeUpdate(destPath):
def _executeUpdate(destPath: str) -> None:
"""Execute the update process.

:param destPath: The path to the update executable.
"""
if not destPath:
log.error("destPath must be a non-empty string.", exc_info=True)
return

_setStateToNone(state)
saveState()
if not core.triggerNVDAExit(core.NewNVDAInstance(destPath, _generate_updateParameters())):
log.error("NVDA already in process of exiting, this indicates a logic error.")


def _generate_updateParameters() -> str:
"""Generate parameters to pass to the new NVDA instance for the update process.

We generate parameters that specify:
- Whether to install, update a portable copy, or run the launcher.
- Whether to disable addons.
- The path to the configuration directory.

:return: The parameters to pass to the new NVDA instance.
"""
executeFlags: set[str] = set()
executeOptions: dict[str, str] = {}
if config.isInstalledCopy():
executeParams = "--install -m"
executeFlags.update(("--install", "-m"))
else:
portablePath = globalVars.appDir
if os.access(portablePath, os.W_OK):
executeParams = (
'--create-portable --portable-path "{portablePath}" --config-path "{configPath}" -m'.format(
portablePath=portablePath,
configPath=WritePaths.configDir,
)
)
executeFlags.update(("--create-portable", "-m"))
executeOptions["--portable-path"] = f'"{portablePath}"'
seanbudd marked this conversation as resolved.
Show resolved Hide resolved
else:
executeParams = "--launcher"
# #4475: ensure that the new process shows its first window, by providing SW_SHOWNORMAL
if not core.triggerNVDAExit(core.NewNVDAInstance(destPath, executeParams)):
log.error("NVDA already in process of exiting, this indicates a logic error.")
# We can't write to the currently running portable copy's directory, so just run the launcher.
executeFlags.add("--launcher")
if globalVars.appArgs.disableAddons:
executeFlags.add("--disable-addons")
# pass the config path to the new instance, so that if a custom config path is in use, it will be inherited.
# If the default con fig path is in use, the new instance would use it anyway, so there is no harm in passing it.
executeOptions["--config-path"] = f'"{WritePaths.configDir}"'
seanbudd marked this conversation as resolved.
Show resolved Hide resolved
return f"{' '.join(executeFlags)} {' '.join(' '.join(i) for i in executeOptions.items())}"


class UpdateChecker(garbageHandler.TrackedObject):
Expand Down
2 changes: 2 additions & 0 deletions user_docs/en/changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ The available options are:

### Changes

* The `-c`/`--config-path` and `--disable-addons` command line options are now respected when launching an update from within NVDA. (#16937)

seanbudd marked this conversation as resolved.
Show resolved Hide resolved
### Bug Fixes

* NVDA once again relies on events for caret movement in several cases, rather than only on manual querying of the caret position.
Expand Down