-
-
Notifications
You must be signed in to change notification settings - Fork 3
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
addon-updaterの更新 #9
Merged
Merged
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,12 +17,7 @@ | |
from urllib.parse import urlencode | ||
from .constants import * | ||
from .translate import * | ||
|
||
try: | ||
import addonHandler | ||
addonHandler.initTranslation() | ||
except BaseException: | ||
def _(x): return x | ||
from . import updaterStrings as strs | ||
|
||
try: | ||
import updateCheck | ||
|
@@ -38,6 +33,22 @@ def _(x): return x | |
AUTO=0 | ||
MANUAL=1 | ||
|
||
def isCompatibleWith2025(): | ||
return versionInfo.version_year >= 2025 | ||
|
||
def messageBox(message, title): | ||
if isCompatibleWith2025(): | ||
gui.message.MessageDialog.alert(message, title) | ||
else: | ||
gui.messageBox(message, title, style=wx.CENTER) | ||
|
||
def confirm(message, title): | ||
if isCompatibleWith2025(): | ||
return gui.message.MessageDialog.confirm(message, title) == gui.message.ReturnCode.OK | ||
else: | ||
return gui.messageBox(message, title, style=wx.CENTER | wx.OK | wx.CANCEL | wx.ICON_INFORMATION) == wx.ID_OK | ||
|
||
|
||
class AutoUpdateChecker: | ||
def __init__(self): | ||
self.updater = None | ||
|
@@ -74,13 +85,12 @@ def check_update(self): | |
f = urlopen(req) | ||
except BaseException: | ||
if self.mode == MANUAL: | ||
gui.messageBox(_("Unable to connect to update server.\nCheck your internet connection."), | ||
_("Error"), style=wx.CENTER | wx.ICON_WARNING) | ||
messageBox(strs.ERROR_UNABLE_TO_CONNECT, strs.ERROR) | ||
return False | ||
|
||
if f.getcode() != 200: | ||
if self.mode == MANUAL: | ||
gui.messageBox(_("Unable to connect to update server."), _("Error"), style=wx.CENTER | wx.ICON_WARNING) | ||
messageBox(strs.ERROR_UNABLE_TO_CONNECT_SERVERSIDE, strs.ERROR) | ||
return False | ||
|
||
try: | ||
|
@@ -89,31 +99,25 @@ def check_update(self): | |
update_dict = json.loads(update_dict) | ||
except BaseException: | ||
if self.mode == MANUAL: | ||
gui.messageBox( | ||
_("The update information is invalid.\nPlease contact ACT Laboratory for further information."), | ||
_("Error"), | ||
style=wx.CENTER | wx.ICON_WARNING) | ||
gui.messageBox(strs.ERROR_UPDATE_INFO_INVALID, strs.ERROR) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
ではないでしょうか。 |
||
return False | ||
|
||
code = update_dict["code"] | ||
if code == UPDATER_LATEST: | ||
if self.mode == MANUAL: | ||
gui.messageBox(_("No updates found.\nYou are using the latest version."), _("Update check"), style=wx.CENTER | wx.ICON_INFORMATION) | ||
messageBox(strs.NO_UPDATES, strs.UPDATE_CHECK_TITLE) | ||
return False | ||
elif code == UPDATER_BAD_PARAM: | ||
if self.mode == MANUAL: | ||
gui.messageBox(_("The request parameter is invalid. Please contact the developer."), | ||
_("Update check"), style=wx.CENTER | wx.ICON_INFORMATION) | ||
messageBox(strs.ERROR_REQUEST_PARAMETERS_INVALID, strs.UPDATE_CHECK_TITLE) | ||
return False | ||
elif code == UPDATER_NOT_FOUND: | ||
if self.mode == MANUAL: | ||
gui.messageBox(_("The updater is not registered. Please contact the developer."), | ||
_("Update check"), style=wx.CENTER | wx.ICON_INFORMATION) | ||
messageBox(strs.UPDATER_NOT_REGISTERED, strs.UPDATE_CHECK_TITLE) | ||
return False | ||
elif code == UPDATER_VISIT_SITE: | ||
if self.mode == MANUAL: | ||
gui.messageBox(_("An update was found, but updating from the current version is not possible. Please visit the software's website. "), | ||
_("Update check"), style=wx.CENTER | wx.ICON_INFORMATION) | ||
messageBox(strs.UPDATE_NOT_POSSIBLE, strs.UPDATE_CHECK_TITLE) | ||
return False | ||
|
||
new_version = update_dict["update_version"] | ||
|
@@ -124,11 +128,11 @@ def check_update(self): | |
hash = update_dict["updater_hash"] | ||
# end set hash | ||
|
||
caption = _("Update confirmation") | ||
question = _("{summary} Ver.{newVersion} is available.\nWould you like to update?\nCurrent version: {currentVersion}\nNew version: {newVersion}").format( | ||
caption = strs.UPDATE_CONFIRMATION_TITLE | ||
question = strs.UPDATE_CONFIRMATION_MESSAGE.format( | ||
summary=addonSummary, newVersion=new_version, currentVersion=addonVersion) | ||
answer = gui.messageBox(question, caption, style=wx.CENTER | wx.OK | wx.CANCEL | wx.CANCEL_DEFAULT | wx.ICON_INFORMATION) | ||
if answer == wx.OK: | ||
answer = confirm(question, caption) | ||
if answer == True: | ||
downloader = UpdateDownloader(addonName, [url], hash) | ||
wx.CallAfter(downloader.start) | ||
return | ||
|
@@ -151,8 +155,8 @@ def start(self): | |
self._shouldCancel = False | ||
self._guiExecTimer = wx.PyTimer(self._guiExecNotify) | ||
gui.mainFrame.prePopup() | ||
self._progressDialog = wx.ProgressDialog(_("Downloading add-on update"), | ||
_("Connecting"), | ||
self._progressDialog = wx.ProgressDialog(strs.DOWNLOADING, | ||
strs.CONNECTING, | ||
style=wx.PD_CAN_ABORT | wx.PD_ELAPSED_TIME | wx.PD_REMAINING_TIME | wx.PD_AUTO_HIDE, | ||
parent=gui.mainFrame) | ||
self._progressDialog.Raise() | ||
|
@@ -163,10 +167,7 @@ def start(self): | |
def _error(self): | ||
self._stopped() | ||
self.cleanup_tempfile() | ||
gui.messageBox( | ||
_("Error downloading add-on update."), | ||
translate("Error"), | ||
wx.OK | wx.ICON_ERROR) | ||
messageBox(strs.ERROR_DOWNLOADING, strs.ERROR) | ||
|
||
def _download(self, url): | ||
headers = {} | ||
|
@@ -221,27 +222,23 @@ def _downloadSuccess(self): | |
bundle = addonHandler.AddonBundle(self.destPath) | ||
except BaseException: | ||
log.error("Error opening addon bundle from %s" % self.destPath, exc_info=True) | ||
gui.messageBox(translate("Failed to open add-on package file at %s - missing file or invalid file format") % self.destPath, | ||
translate("Error"), | ||
wx.OK | wx.ICON_ERROR) | ||
messageBox(strs.ERROR_OPENING % self.destPath, strs.ERROR) | ||
return | ||
bundleName = bundle.manifest['name'] | ||
for addon in addonHandler.getAvailableAddons(): | ||
if not addon.isPendingRemove and bundleName == addon.manifest['name']: | ||
addon.requestRemove() | ||
break | ||
progressDialog = gui.IndeterminateProgressDialog(gui.mainFrame, | ||
_("Updating add-on"), | ||
_("Please wait while the add-on is being updated.")) | ||
strs.UPDATING, | ||
strs.UPDATING_PLEASE_WAIT) | ||
try: | ||
gui.ExecAndPump(addonHandler.installAddonBundle, bundle) | ||
except BaseException: | ||
log.error("Error installing addon bundle from %s" % self.destPath, exc_info=True) | ||
progressDialog.done() | ||
del progressDialog | ||
gui.messageBox(_("Failed to update add-on from %s.") % self.destPath, | ||
translate("Error"), | ||
wx.OK | wx.ICON_ERROR) | ||
messageBox(strs.ERROR_FAILED_TO_UPDATE % self.destPath, strs.ERROR) | ||
return | ||
else: | ||
progressDialog.done() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
try: | ||
import addonHandler | ||
addonHandler.initTranslation() | ||
except BaseException: | ||
def _(x): return x | ||
|
||
ERROR = _("Error") | ||
ERROR_UNABLE_TO_CONNECT = _("Unable to connect to update server.\nCheck your internet connection.") | ||
ERROR_UNABLE_TO_CONNECT_SERVERSIDE = _("Unable to connect to update server.") | ||
ERROR_UPDATE_INFO_INVALID = _("The update information is invalid.\nPlease contact ACT Laboratory for further information.") | ||
ERROR_REQUEST_PARAMETERS_INVALID = _("The request parameter is invalid. Please contact the developer.") | ||
ERROR_DOWNLOADING = _("Error downloading add-on update.") | ||
ERROR_OPENING = _("Failed to open add-on package file at %s - missing file or invalid file format") | ||
ERROR_FAILED_TO_UPDATE = _("Failed to update add-on from %s.") | ||
NO_UPDATES = _("No updates found.\nYou are using the latest version.") | ||
UPDATER_NOT_REGISTERED = _("The updater is not registered. Please contact the developer.") | ||
UPDATE_NOT_POSSIBLE = _("An update was found, but updating from the current version is not possible. Please visit the software's website. ") | ||
UPDATE_CHECK_TITLE = _("Update check") | ||
UPDATE_CONFIRMATION_TITLE = _("Update confirmation") | ||
UPDATE_CONFIRMATION_MESSAGE = _("{summary} Ver.{newVersion} is available.\nWould you like to update?\nCurrent version: {currentVersion}\nNew version: {newVersion}") | ||
DOWNLOADING = _("Downloading add-on update") | ||
CONNECTING = _("Connecting") | ||
UPDATING = _("Updating add-on") | ||
UPDATING_PLEASE_WAIT = _("Please wait while the add-on is being updated.") |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
gui.messageBox()
の戻り値は、wx.ID_OK
ではなくwx.OK
のようです。There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ほんまや