commit/StationPlaylist: josephsl: 7.0 beta: allow some beta testers to switch to stable channel for updates (will be removed in official release, to be resurrected before LTS hits the air).

  • From: commits-noreply@xxxxxxxxxxxxx
  • To: nvda-addons-commits@xxxxxxxxxxxxx
  • Date: Mon, 21 Mar 2016 05:26:24 -0000

1 new commit in StationPlaylist:

https://bitbucket.org/nvdaaddonteam/stationplaylist/commits/7bebb04551f0/
Changeset:   7bebb04551f0
Branch:      master
User:        josephsl
Date:        2016-03-17 18:43:27+00:00
Summary:     7.0 beta: allow some beta testers to switch to stable channel for 
updates (will be removed in official release, to be resurrected before LTS hits 
the air).

The update qualify check now takes an optional cv (current version) string, 
which is used to let NVDA obtain older releases (this will be used in 7.x 
LTS/8.0). Also adds a preliminary control to select add-on update channel.
If stable channel is selected, the stable URL will be looked up first before 
resorting to connecting to the development URL.

Affected #:  2 files

diff --git a/addon/appModules/splstudio/splconfui.py 
b/addon/appModules/splstudio/splconfui.py
index 820edfd..b607dcb 100755
--- a/addon/appModules/splstudio/splconfui.py
+++ b/addon/appModules/splstudio/splconfui.py
@@ -307,6 +307,8 @@ class SPLConfigDialog(gui.SettingsDialog):
                self.splConPassthrough = 
splconfig.SPLConfig["Advanced"]["SPLConPassthrough"]
                self.compLayer = 
splconfig.SPLConfig["Advanced"]["CompatibilityLayer"]
                self.autoUpdateCheck = 
splconfig.SPLConfig["Update"]["AutoUpdateCheck"]
+               self.updateChannel = 0 if "PCH" in splupdate.SPLAddonState else 
1
+               self.pendingChannelChange = False
                settingsSizer.Add(item)
 
                # Translators: The label for a button in SPL add-on 
configuration dialog to reset settings to defaults.
@@ -401,9 +403,19 @@ class SPLConfigDialog(gui.SettingsDialog):
                                dataLo = 0x00010000 if 
splconfig.SPLConfig["MetadataStreaming"]["MetadataEnabled"][url] else 0xffff0000
                                user32.SendMessageW(hwnd, 1024, dataLo | url, 
36)
                # Coordinate auto update timer restart routine if told to do so.
-               if not splconfig.SPLConfig["Update"]["AutoUpdateCheck"]:
+               if not splconfig.SPLConfig["Update"]["AutoUpdateCheck"] or 
self.pendingChannelChange:
                        if splupdate._SPLUpdateT is not None and 
splupdate._SPLUpdateT.IsRunning(): splupdate._SPLUpdateT.Stop()
                        splupdate._SPLUpdateT = None
+                       if self.pendingChannelChange:
+                               if self.updateChannel == 0:
+                                       splupdate.SPLAddonState["PCH"] = True
+                               else:
+                                       if "PCH" in splupdate.SPLAddonState: 
del splupdate.SPLAddonState["PCH"]
+                               splupdate._pendingChannelChange = True
+                               # Translators: A dialog message shown when 
add-on update channel has changed.
+                               wx.CallAfter(gui.messageBox, _("You have 
changed the add-on update channel. You must restart NVDA for the change to take 
effect."),
+                               # Translators: Title of the update channel 
dialog.
+                               _("Add-on update channel changed"), 
wx.OK|wx.ICON_INFORMATION)
                else:
                        if splupdate._SPLUpdateT is None: splconfig.updateInit()
 
@@ -1270,6 +1282,15 @@ class AdvancedOptionsDialog(wx.Dialog):
                sizer.Add(self.autoUpdateCheckbox, border=10,flag=wx.TOP)
                mainSizer.Add(sizer, border=10, flag=wx.BOTTOM)
 
+               # 7.0 beta/LTS only.
+               sizer = wx.BoxSizer(wx.HORIZONTAL)
+               label = wx.StaticText(self, wx.ID_ANY, label=_("Add-on update 
channel (only available in pre-release builds):"))
+               self.channels= wx.Choice(self, wx.ID_ANY, choices=["stable", 
"development"])
+               self.channels.SetSelection(self.Parent.updateChannel)
+               sizer.Add(label)
+               sizer.Add(self.channels)
+               mainSizer.Add(sizer, border=10, flag=wx.BOTTOM)
+
                sizer = wx.BoxSizer(wx.HORIZONTAL)
                # Translators: A checkbox to toggle if SPL Controller command 
can be used to invoke Assistant layer.
                
self.splConPassthroughCheckbox=wx.CheckBox(self,wx.NewId(),label=_("Allow SPL 
C&ontroller command to invoke SPL Assistant layer"))
@@ -1306,6 +1327,8 @@ class AdvancedOptionsDialog(wx.Dialog):
                parent.splConPassthrough = self.splConPassthroughCheckbox.Value
                parent.compLayer = 
self.compatibilityLayouts[self.compatibilityList.GetSelection()][0]
                parent.autoUpdateCheck = self.autoUpdateCheckbox.Value
+               parent.pendingChannelChange = self.channels.GetSelection() != 
parent.updateChannel
+               parent.updateChannel = self.channels.GetSelection()
                parent.profiles.SetFocus()
                parent.Enable()
                self.Destroy()

diff --git a/addon/appModules/splstudio/splupdate.py 
b/addon/appModules/splstudio/splupdate.py
index 4b18d8f..7af0aab 100755
--- a/addon/appModules/splstudio/splupdate.py
+++ b/addon/appModules/splstudio/splupdate.py
@@ -29,6 +29,10 @@ SPLAddonCheck = 0
 SPLAddonState = {}
 # Update URL (the only way to change it is installing a different version from 
a different branch).
 SPLUpdateURL = "http://addons.nvda-project.org/files/get.php?file=spl-dev";
+# 7.0 beta only: Stable version URL and flag.
+SPLUpdateURL2 = "http://addons.nvda-project.org/files/get.php?file=spl";
+_stableChannel = False
+_pendingChannelChange = False
 # Update check timer.
 _SPLUpdateT = None
 # How long it should wait between automatic checks.
@@ -40,11 +44,12 @@ _updatePickle = os.path.join(globalVars.appArgs.configPath, 
"splupdate.pickle")
 
 # Come forth, update check routines.
 def initialize():
-       global SPLAddonState, SPLAddonSize, SPLAddonCheck
+       global SPLAddonState, SPLAddonSize, SPLAddonCheck, _stableChannel
        try:
                SPLAddonState = cPickle.load(file(_updatePickle, "r"))
                SPLAddonCheck = SPLAddonState["PDT"]
                SPLAddonSize = SPLAddonState["PSZ"]
+               _stableChannel = "PCH" in SPLAddonState
        except IOError:
                SPLAddonState["PDT"] = 0
                SPLAddonState["PSZ"] = 0x0
@@ -88,11 +93,12 @@ def stopUpdateProgress():
        _progressThread.Stop()
        _progressThread = None
 
-def updateQualify(url):
+# 7.0 beta/LTS: allow custom version to be passed into this function.
+def updateQualify(url, cv=None):
        # The add-on version is of the form "major.minor". The "-dev" suffix 
indicates development release.
        # Anything after "-dev" indicates a try or a custom build.
        # LTS: Support upgrading between LTS releases.
-       curVersion =SPLAddonVersion.split("-")[0]
+       curVersion =cv if cv is not None else SPLAddonVersion.split("-")[0]
        # Because we'll be using the same file name for snapshots...
        if "-dev" in SPLAddonVersion: curVersion+="-dev"
        size = hex(int(url.info().getheader("Content-Length")))
@@ -112,6 +118,9 @@ def updateQualify(url):
 # Auto is whether to respond with UI (manual check only), continuous takes in 
auto update check variable for restarting the timer.
 # LTS: The "lts" flag is used to obtain update metadata from somewhere else 
(typically the LTS server).
 def updateCheck(auto=False, continuous=False, lts=False):
+       if _pendingChannelChange:
+               wx.CallAfter(gui.messageBox, _("Did you recently tell SPL 
add-on to use a different update channel? If so, please restart NVDA before 
checking for add-on updates."), _("Update channel changed"), wx.ICON_ERROR)
+               return
        global _SPLUpdateT, SPLAddonCheck, _retryAfterFailure
        # Regardless of whether it is an auto check, update the check time.
        # However, this shouldnt' be done if this is a retry after a failed 
attempt.
@@ -125,8 +134,18 @@ def updateCheck(auto=False, continuous=False, lts=False):
                threading.Thread(target=updateProgress).start()
        updateCandidate = False
        try:
-               url = urllib.urlopen(SPLUpdateURL)
-               url.close()
+               # 7.0 beta: give priority to stable version if this is such a 
case.
+               if _stableChannel:
+                       urlStable = urllib.urlopen(SPLUpdateURL2)
+                       urlStable.close()
+                       if urlStable.code == 200 and updateQualify(urlStable, 
cv="6.a") not in (None, ""):
+                               url = urllib.urlopen(SPLUpdateURL2)
+                       else:
+                               url = urllib.urlopen(SPLUpdateURL)
+                       url.close()
+               else:
+                       url = urllib.urlopen(SPLUpdateURL)
+                       url.close()
        except IOError:
                _retryAfterFailure = True
                if not auto:
@@ -147,7 +166,7 @@ def updateCheck(auto=False, continuous=False, lts=False):
                checkMessage = _("Add-on update check failed.")
        else:
                # Am I qualified to update?
-               qualified = updateQualify(url)
+               qualified = updateQualify(url, cv ="6.a" if _stableChannel else 
None)
                if qualified is None:
                        if auto:
                                if continuous: 
_SPLUpdateT.Start(_updateInterval*1000, True)

Repository URL: https://bitbucket.org/nvdaaddonteam/stationplaylist/

--

This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.

Other related posts:

  • » commit/StationPlaylist: josephsl: 7.0 beta: allow some beta testers to switch to stable channel for updates (will be removed in official release, to be resurrected before LTS hits the air). - commits-noreply