commit/StationPlaylist: 8 new changesets

  • From: commits-noreply@xxxxxxxxxxxxx
  • To: nvda-addons-commits@xxxxxxxxxxxxx
  • Date: Fri, 13 Nov 2015 04:38:09 -0000

8 new commits in StationPlaylist:

https://bitbucket.org/nvdaaddonteam/stationplaylist/commits/e2f35a876e61/
Changeset: e2f35a876e61
Branch: None
User: josephsl
Date: 2015-11-13 03:55:34+00:00
Summary: Rainbow/gold (7.0 prealpha): Starting construction of golden road
towards the rainbow.

An essential feature of Project Rainbow (add-on 7) is ability to prompt for
updates. For now, because NVDA Core does not provide update downloader, ask the
default browser to download new add-on installers.
Specifically:
* A new module claled splupdate will be used to manage update checks.
* Urllib is now used to obtain content header for SPL add-on installer. Among
other things, this allows the add-on to query version (via URL string), content
length (instlaler size) and last modified date.
* The update check interface will be quite simpler than that of NvDA Core
update check module.
This will be the foundation for add-on 7.0 in 2016.

Affected #: 2 files

diff --git a/addon/appModules/splstudio/__init__.py
b/addon/appModules/splstudio/__init__.py
index 6cc7bfa..d5c37a5 100755
--- a/addon/appModules/splstudio/__init__.py
+++ b/addon/appModules/splstudio/__init__.py
@@ -35,9 +35,13 @@ import textInfos
import tones
import splconfig
import splmisc
+import splupdate
import addonHandler
addonHandler.initTranslation()

+def update():
+ splupdate._updateCheckEx()
+
# The finally function for status announcement scripts in this module (source:
Tyler Spivey's code).
def finally_(func, final):
"""Calls final after func, even if it fails."""
@@ -1539,6 +1543,9 @@ class AppModule(appModuleHandler.AppModule):
def script_openOnlineDoc(self, gesture):

os.startfile("https://bitbucket.org/nvdaaddonteam/stationplaylist/wiki/SPLDevAddonGuide";)

+ def script_updateCheck(self, gesture):
+ splupdate.updateCheck()
+

__SPLAssistantGestures={
"kb:p":"sayPlayStatus",
@@ -1572,6 +1579,7 @@ class AppModule(appModuleHandler.AppModule):
"kb:0":"metadataEnabled",
"kb:f1":"layerHelp",
"kb:shift+f1":"openOnlineDoc",
+ "kb:control+shift+u":"updateCheck",
}

__SPLAssistantJFWGestures={
@@ -1606,6 +1614,7 @@ class AppModule(appModuleHandler.AppModule):
"kb:0":"metadataEnabled",
"kb:f1":"layerHelp",
"kb:shift+f1":"openOnlineDoc",
+ "kb:control+shift+u":"updateCheck",
}

__gestures={

diff --git a/addon/appModules/splstudio/splupdate.py
b/addon/appModules/splstudio/splupdate.py
new file mode 100755
index 0000000..f6d1177
--- /dev/null
+++ b/addon/appModules/splstudio/splupdate.py
@@ -0,0 +1,59 @@
+# StationPlaylist Studio update checker
+# A support module for SPL add-on
+# Copyright 2015-2016, Joseph Lee, released under GPL.
+
+# Provides update check facility.
+
+import urllib
+import os # Essentially, update download is no different than file downloads.
+import gui
+import wx
+import tones
+import splconfig
+
+# Cache the file size for the last downloaded SPL add-on installer.
+SPLAddonSize = 0
+# Update URL.
+SPLUpdateURL = "http://addons.nvda-project.org/files/get.php?file=spl-dev";
+
+def _versionFromURL(url):
+ filename = url.split("/")[-1]
+ name = filename.split(".nvda-addon")[0]
+ return name[name.find("-")+1:]
+
+def updateCheck():
+ #global SPLAddonSize
+ tones.beep(900, 200)
+ # All the information will be stored in the URL object, so just close
it once the headers are downloaded.
+ url = urllib.urlopen(SPLUpdateURL)
+ url.close()
+ if url.code != 200:
+ wx.CallAfter(gui.messageBox, "Add-on update check failed.",
"Check for add-on update")
+ return
+ size = int(url.info().getheader("Content-Length"))
+ if size == SPLAddonSize:
+ wx.CallAfter(gui.messageBox, "No add-on update available.",
"Check for add-on update")
+ return
+ else:
+ version = _versionFromURL(url.url)
+ wx.CallAfter(gui.messageBox, "Studio add-on {newVersion} is
available.".format(newVersion = version), "Check for add-on update")
+ #SPLAddonSize = size
+
+def _updateCheckEx():
+ #global SPLAddonSize
+ url = urllib.urlopen(SPLUpdateURL)
+ if url.code != 200:
+ print "Update check failed"
+ url.close()
+ return
+ size = int(url.info().getheader("Content-Length"))
+ if size == SPLAddonSize:
+ print "You have the latest version"
+ url.close()
+ return
+ else:
+ version = _versionFromURL(url.url)
+ print "Add-on version {newVersion} is
available.".format(newVersion = version)
+ url.close()
+ #SPLAddonSize = size
+


https://bitbucket.org/nvdaaddonteam/stationplaylist/commits/56de1cd10328/
Changeset: 56de1cd10328
Branch: None
User: josephsl
Date: 2015-11-13 03:55:35+00:00
Summary: Rainbow/gold (7.0 prealpha): Barriers, switches and version checks.

Make sure NVDA can detect that no updates are avilable. This will be done by
checking the current version against the one returned from the server, and in
case of dev branch, file size.
Also, in some cases, NVDA may freeze when URL opeing operation takes too long,
so play a progress tone every second.
As part of update check, a qualification check will be done. This function will
return None, empty string or the version if there are no updates, newer version
is installed or if an update is available, respectively. The update check will
then change the dialog text accordingly.
One step closer to 7.0 alpha.

Affected #: 1 file

diff --git a/addon/appModules/splstudio/splupdate.py
b/addon/appModules/splstudio/splupdate.py
index f6d1177..9683408 100755
--- a/addon/appModules/splstudio/splupdate.py
+++ b/addon/appModules/splstudio/splupdate.py
@@ -10,10 +10,17 @@ import gui
import wx
import tones
import splconfig
+import addonHandler
+
+# Add-on manifest routine (credit: various add-on authors including Noelia
Martinez).
+# Do not rely on using absolute path to open to manifest, as installation
directory may change in a future NVDA Core version (highly unlikely, but...).
+_addonDir = os.path.join(os.path.dirname(__file__), "..", "..")
+# Move this to the main app module in case version will be queried by users.
+SPLAddonVersion = addonHandler.Addon(_addonDir).manifest['version']

# Cache the file size for the last downloaded SPL add-on installer.
SPLAddonSize = 0
-# Update URL.
+# 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";

def _versionFromURL(url):
@@ -21,23 +28,44 @@ def _versionFromURL(url):
name = filename.split(".nvda-addon")[0]
return name[name.find("-")+1:]

+def updateProgress():
+ tones.beep(440, 40)
+
+def updateQualify(url):
+ size = int(url.info().getheader("Content-Length"))
+ version = _versionFromURL(url.url)
+ # In case we are running the latest version, check the content length
(size).
+ if version == SPLAddonVersion:
+ if "-dev" not in version or ("-dev" in SPLAddonVersion and size
== SPLAddonSize):
+ return None
+ elif version > SPLAddonVersion or ("-dev" in version and size !=
SPLAddonSize):
+ return version
+ else:
+ return ""
+
def updateCheck():
#global SPLAddonSize
- tones.beep(900, 200)
+ tones.beep(110, 40)
+ # Try builds does not (and will not) support upgrade checking unless
absolutely required.
# All the information will be stored in the URL object, so just close
it once the headers are downloaded.
+ progressTone = wx.PyTimer(updateProgress)
+ progressTone.Start(1000)
url = urllib.urlopen(SPLUpdateURL)
url.close()
if url.code != 200:
- wx.CallAfter(gui.messageBox, "Add-on update check failed.",
"Check for add-on update")
- return
- size = int(url.info().getheader("Content-Length"))
- if size == SPLAddonSize:
- wx.CallAfter(gui.messageBox, "No add-on update available.",
"Check for add-on update")
- return
+ checkMessage = "Add-on update check failed."
else:
- version = _versionFromURL(url.url)
- wx.CallAfter(gui.messageBox, "Studio add-on {newVersion} is
available.".format(newVersion = version), "Check for add-on update")
- #SPLAddonSize = size
+ # In case we are running the latest version, check the content
length (size).
+ qualified = updateQualify(url)
+ if qualified is None:
+ checkMessage = "No add-on update available."
+ elif qualified == "":
+ checkMessage = "You appear to be running a version
newer than the latest released version. Please reinstall the official version
to downgrade."
+ else:
+ checkMessage = "Studio add-on {newVersion} is
available.".format(newVersion = qualified)
+ progressTone.Stop()
+ wx.CallAfter(gui.messageBox, checkMessage, "Check for add-on update")
+ #SPLAddonSize = size

def _updateCheckEx():
#global SPLAddonSize


https://bitbucket.org/nvdaaddonteam/stationplaylist/commits/1190c0c48a99/
Changeset: 1190c0c48a99
Branch: None
User: josephsl
Date: 2015-11-13 03:55:35+00:00
Summary: Rainbow/gold (7.0 prealpha): Have a sign saying when the road was
last paved.

When a development version is being updated (for now, stalbe will count as
well), display the last modified date of the add-on installer found on the
Community Add-ons server.

Affected #: 1 file

diff --git a/addon/appModules/splstudio/splupdate.py
b/addon/appModules/splstudio/splupdate.py
index 9683408..921110a 100755
--- a/addon/appModules/splstudio/splupdate.py
+++ b/addon/appModules/splstudio/splupdate.py
@@ -6,6 +6,7 @@

import urllib
import os # Essentially, update download is no different than file downloads.
+from calendar import month_abbr # Last modified date formatting.
import gui
import wx
import tones
@@ -28,6 +29,12 @@ def _versionFromURL(url):
name = filename.split(".nvda-addon")[0]
return name[name.find("-")+1:]

+def _lastModified(lastModified):
+ # Add-ons server uses British date format (dd-mm-yyyy).
+ day, month, year = lastModified.split()[1:4]
+ month = str({v: k for k,v in enumerate(month_abbr)}[month]).zfill(2)
+ return "-".join([year, month, day])
+
def updateProgress():
tones.beep(440, 40)

@@ -55,14 +62,14 @@ def updateCheck():
if url.code != 200:
checkMessage = "Add-on update check failed."
else:
- # In case we are running the latest version, check the content
length (size).
+ # Am I qualified to update?
qualified = updateQualify(url)
if qualified is None:
checkMessage = "No add-on update available."
elif qualified == "":
checkMessage = "You appear to be running a version
newer than the latest released version. Please reinstall the official version
to downgrade."
else:
- checkMessage = "Studio add-on {newVersion} is
available.".format(newVersion = qualified)
+ checkMessage = "Studio add-on {newVersion}
({modifiedDate}) is available.".format(newVersion = qualified, modifiedDate =
_lastModified(url.info().getheader("Last-Modified")))
progressTone.Stop()
wx.CallAfter(gui.messageBox, checkMessage, "Check for add-on update")
#SPLAddonSize = size


https://bitbucket.org/nvdaaddonteam/stationplaylist/commits/4d31c743de12/
Changeset: 4d31c743de12
Branch: None
User: josephsl
Date: 2015-11-13 03:55:36+00:00
Summary: Give credit to month to index conversion routine (Stack Overflow)

Affected #: 1 file

diff --git a/addon/appModules/splstudio/splupdate.py
b/addon/appModules/splstudio/splupdate.py
index 921110a..50e42b7 100755
--- a/addon/appModules/splstudio/splupdate.py
+++ b/addon/appModules/splstudio/splupdate.py
@@ -32,6 +32,7 @@ def _versionFromURL(url):
def _lastModified(lastModified):
# Add-ons server uses British date format (dd-mm-yyyy).
day, month, year = lastModified.split()[1:4]
+ # Adopted from a Stack Overflow entry on converting month abbreviations
to indecies.
month = str({v: k for k,v in enumerate(month_abbr)}[month]).zfill(2)
return "-".join([year, month, day])



https://bitbucket.org/nvdaaddonteam/stationplaylist/commits/ab7ae1e56218/
Changeset: ab7ae1e56218
Branch: None
User: josephsl
Date: 2015-11-13 03:55:37+00:00
Summary: Rainbow/gold (7.0 prealpha): When meeting a barrier, ask for
permission to cross.

When a new version of the add-on is available, ask if users wish to download,
and if yes, update add-on installer size (stored as hex).

Affected #: 2 files

diff --git a/addon/appModules/splstudio/splconfig.py
b/addon/appModules/splstudio/splconfig.py
index 3e19611..88d6078 100755
--- a/addon/appModules/splstudio/splconfig.py
+++ b/addon/appModules/splstudio/splconfig.py
@@ -16,6 +16,7 @@ import gui
import wx
from winUser import user32
import tones
+import splupdate

# Configuration management
SPLIni = os.path.join(globalVars.appArgs.configPath, "splstudio.ini")
@@ -121,6 +122,8 @@ def initConfig():
except WindowsError:
pass
SPLConfig = SPLConfigPool[0]
+ # 7.0: Store add-on installer size in case one wishes to check for
updates (default size is 0 or no update checked attempted).
+ if "PSZ" in SPLConfig: splupdate.SPLAddonSize != conf["PSZ"]
# Locate instant profile.
if "InstantProfile" in SPLConfig:
try:
@@ -250,6 +253,9 @@ def _preSave(conf):
# 6.0 only: Remove obsolete keys.
if "MetadataURL" in conf:
del conf["MetadataURL"]
+ # 7.0: Check if updates are pending.
+ if "PSZ" in conf and splupdate.SPLAddonSize != conf["PSZ"]:
+ conf["PSZ"] = splupdate.SPLAddonSize
# For other profiles, remove global settings before writing to disk.
else:
# 6.1: Make sure column order and inclusion aren't same as
default values.

diff --git a/addon/appModules/splstudio/splupdate.py
b/addon/appModules/splstudio/splupdate.py
index 50e42b7..5aadee5 100755
--- a/addon/appModules/splstudio/splupdate.py
+++ b/addon/appModules/splstudio/splupdate.py
@@ -10,7 +10,6 @@ from calendar import month_abbr # Last modified date
formatting.
import gui
import wx
import tones
-import splconfig
import addonHandler

# Add-on manifest routine (credit: various add-on authors including Noelia
Martinez).
@@ -19,8 +18,8 @@ _addonDir = os.path.join(os.path.dirname(__file__), "..",
"..")
# Move this to the main app module in case version will be queried by users.
SPLAddonVersion = addonHandler.Addon(_addonDir).manifest['version']

-# Cache the file size for the last downloaded SPL add-on installer.
-SPLAddonSize = 0
+# Cache the file size for the last downloaded SPL add-on installer (stored in
hexadecimal for security).
+SPLAddonSize = "0x0"
# 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";

@@ -32,7 +31,7 @@ def _versionFromURL(url):
def _lastModified(lastModified):
# Add-ons server uses British date format (dd-mm-yyyy).
day, month, year = lastModified.split()[1:4]
- # Adopted from a Stack Overflow entry on converting month abbreviations
to indecies.
+ # Adapted an entry on Stack Overflow on how to convert month names to
indecies.
month = str({v: k for k,v in enumerate(month_abbr)}[month]).zfill(2)
return "-".join([year, month, day])

@@ -52,12 +51,12 @@ def updateQualify(url):
return ""

def updateCheck():
- #global SPLAddonSize
tones.beep(110, 40)
# Try builds does not (and will not) support upgrade checking unless
absolutely required.
# All the information will be stored in the URL object, so just close
it once the headers are downloaded.
progressTone = wx.PyTimer(updateProgress)
progressTone.Start(1000)
+ updateCandidate = False
url = urllib.urlopen(SPLUpdateURL)
url.close()
if url.code != 200:
@@ -70,10 +69,16 @@ def updateCheck():
elif qualified == "":
checkMessage = "You appear to be running a version
newer than the latest released version. Please reinstall the official version
to downgrade."
else:
- checkMessage = "Studio add-on {newVersion}
({modifiedDate}) is available.".format(newVersion = qualified, modifiedDate =
_lastModified(url.info().getheader("Last-Modified")))
+ checkMessage = "Studio add-on {newVersion}
({modifiedDate}) is available. Would you like to update?".format(newVersion =
qualified, modifiedDate = _lastModified(url.info().getheader("Last-Modified")))
+ updateCandidate = True
progressTone.Stop()
- wx.CallAfter(gui.messageBox, checkMessage, "Check for add-on update")
- #SPLAddonSize = size
+ if not updateCandidate: wx.CallAfter(gui.messageBox, checkMessage,
"Check for add-on update")
+ else: wx.CallAfter(getUpdateResponse, checkMessage, "Check for add-on
update", url.info().getheader("Content-Length"))
+
+def getUpdateResponse(message, caption, size):
+ if gui.messageBox(message, caption, wx.YES | wx.NO | wx.CANCEL |
wx.CENTER | wx.ICON_QUESTION) == wx.YES:
+ SPLAddonSize = hex(int(size))
+ print SPLAddonSize

def _updateCheckEx():
#global SPLAddonSize


https://bitbucket.org/nvdaaddonteam/stationplaylist/commits/43eed98b18a8/
Changeset: 43eed98b18a8
Branch: None
User: josephsl
Date: 2015-11-13 03:55:37+00:00
Summary: Rainbow/gold (7.0 prealpha): compare integers versus integers, and
hex versus hex.

Affected #: 1 file

diff --git a/addon/appModules/splstudio/splupdate.py
b/addon/appModules/splstudio/splupdate.py
index 5aadee5..7534daf 100755
--- a/addon/appModules/splstudio/splupdate.py
+++ b/addon/appModules/splstudio/splupdate.py
@@ -39,7 +39,7 @@ def updateProgress():
tones.beep(440, 40)

def updateQualify(url):
- size = int(url.info().getheader("Content-Length"))
+ size = hex(int(url.info().getheader("Content-Length")))
version = _versionFromURL(url.url)
# In case we are running the latest version, check the content length
(size).
if version == SPLAddonVersion:


https://bitbucket.org/nvdaaddonteam/stationplaylist/commits/5b7c39a945f2/
Changeset: 5b7c39a945f2
Branch: None
User: josephsl
Date: 2015-11-13 03:56:50+00:00
Summary: Merge branch 'rainbow/goldUpdateCheck' of
https://bitbucket.org/nvdaaddonteam/stationPlaylist into rainbow/goldUpdateCheck

Affected #: 0 files



https://bitbucket.org/nvdaaddonteam/stationplaylist/commits/e05234aa73ed/
Changeset: e05234aa73ed
Branch: rainbow/goldUpdateCheck
User: josephsl
Date: 2015-11-13 04:37:46+00:00
Summary: Rainbow/gold (7.0 prealpha): The golden road is now open for
traffic.

Officially enable add-on update from main app module and from update module.
Specifically:
* The update size will now live in user config file.
* When told to 'download' the update, NVDA will open the default web browser.
This complete 7.0 snapshot 1.

Affected #: 2 files

diff --git a/addon/appModules/splstudio/splconfig.py
b/addon/appModules/splstudio/splconfig.py
index 88d6078..c164e13 100755
--- a/addon/appModules/splstudio/splconfig.py
+++ b/addon/appModules/splstudio/splconfig.py
@@ -254,7 +254,8 @@ def _preSave(conf):
if "MetadataURL" in conf:
del conf["MetadataURL"]
# 7.0: Check if updates are pending.
- if "PSZ" in conf and splupdate.SPLAddonSize != conf["PSZ"]:
+ if (("PSZ" in conf and splupdate.SPLAddonSize != conf["PSZ"])
+ or ("PSZ" not in conf and splupdate.SPLAddonSize != 0x0)):
conf["PSZ"] = splupdate.SPLAddonSize
# For other profiles, remove global settings before writing to disk.
else:

diff --git a/addon/appModules/splstudio/splupdate.py
b/addon/appModules/splstudio/splupdate.py
index 7534daf..fed05b7 100755
--- a/addon/appModules/splstudio/splupdate.py
+++ b/addon/appModules/splstudio/splupdate.py
@@ -76,25 +76,8 @@ def updateCheck():
else: wx.CallAfter(getUpdateResponse, checkMessage, "Check for add-on
update", url.info().getheader("Content-Length"))

def getUpdateResponse(message, caption, size):
+ global SPLAddonSize
if gui.messageBox(message, caption, wx.YES | wx.NO | wx.CANCEL |
wx.CENTER | wx.ICON_QUESTION) == wx.YES:
SPLAddonSize = hex(int(size))
- print SPLAddonSize
-
-def _updateCheckEx():
- #global SPLAddonSize
- url = urllib.urlopen(SPLUpdateURL)
- if url.code != 200:
- print "Update check failed"
- url.close()
- return
- size = int(url.info().getheader("Content-Length"))
- if size == SPLAddonSize:
- print "You have the latest version"
- url.close()
- return
- else:
- version = _versionFromURL(url.url)
- print "Add-on version {newVersion} is
available.".format(newVersion = version)
- url.close()
- #SPLAddonSize = size
+ os.startfile(SPLUpdateURL)

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: