Ticket #73: 73-1.diff

File 73-1.diff, 2.8 KB (added by orcauser, 6 months ago)
  • source/versionInfo.py

    === modified file 'source/versionInfo.py'
     
    66 
    77import os 
    88 
     9def getlatestVersionNumber(): 
     10    """Check if there is a new stable release of nvda.""" 
     11    import re 
     12    import urllib 
     13    try: 
     14        f = urllib.urlopen("http://www.nvda-project.org/wiki/Download") 
     15        pageText = f.read() 
     16        f.close() 
     17    except IOError: 
     18        # Translators: this message is displayed in the about dialog, when trying to find the latest version. 
     19        return _("Unable to contact website.") 
     20    # we know that the version number is on a line where we have stable, release and the ver number. 
     21    verReg = re.compile('.*?stable.*?release.*?(?P<newVer>[0-9]+\.[0-9])', re.IGNORECASE) 
     22    results = verReg.findall(pageText) 
     23 
     24    if not len(results):  
     25        # Translators: this message is displayed in the about dialog, when trying to find the latest version. 
     26        return _("Could not find latest version information.") 
     27    try: 
     28        # if the current version is less than the one found on the site. 
     29        if float(version[0:6]) < float(results[0]): 
     30            return results[0] # version found number on website 
     31        # Translators: this message is displayed in the about dialog, when trying to find the latest version. 
     32        return _("Your version is up to date.") 
     33    except ValueError: 
     34        # running from bzr or a snapshot. 
     35        # Translators: this message is displayed in the about dialog, when trying to find the latest version. 
     36        return _("Unable to check for newer version, this does not look like a release version of NVDA.") 
     37 
    938def _updateVersionFromVCS(): 
    1039        """Update the version from version control system metadata if possible. 
    1140        """ 
     
    4372        years=copyrightYears) 
    4473aboutMessage=_(u"""{longName} ({name}) 
    4574Version: {version} 
     75Latest version: {latestVersion} 
    4676URL: {url} 
    4777{copyright} 
    4878 
     
    5181It can also be viewed online at: http://www.gnu.org/licenses/old-licenses/gpl-2.0.html 
    5282 
    5383{name} is developed by NV Access, a non-profit organisation committed to helping and promoting free and open source solutions for blind and vision impaired people. 
    54 If you find NVDA useful and want it to continue to improve, please consider donating to NV Access. You can do this by selecting Donate from the NVDA menu.""").format(**globals()) 
     84If you find NVDA useful and want it to continue to improve, please consider donating to NV Access. You can do this by selecting Donate from the NVDA menu.""").format(latestVersion=getlatestVersionNumber(), **globals()) 
    5585 
    5686# A test version is anything other than a final or rc release. 
    5787isTestVersion = not version[0].isdigit() or "alpha" in version or "beta" in version or "dev" in version