Changeset e8c61f6 in sasview


Ignore:
Timestamp:
Mar 27, 2012 9:28:56 AM (12 years ago)
Author:
Mathieu Doucet <doucetm@…>
Branches:
master, ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc, costrafo411, magnetic_scatt, release-4.1.1, release-4.1.2, release-4.2.2, release_4.0.1, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
Children:
204548c
Parents:
27edb0d
Message:

Fix 'check for update'

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sansguiframe/src/sans/guiframe/gui_manager.py

    rd71a9fe re8c61f6  
    1818import time 
    1919import py_compile 
    20 # Try to find a local config 
    2120import imp 
    2221import warnings 
     22import re 
    2323warnings.simplefilter("ignore") 
    2424import logging 
    25  
     25import urllib2 
    2626 
    2727from sans.guiframe.events import EVT_STATUS 
     
    307307        self.on_batch_selection(event=None) 
    308308        self.add_icon() 
    309         # Check for update 
    310         #self._check_update(None) 
    311309        # Register the close event so it calls our own method 
    312310        wx.EVT_CLOSE(self, self.WindowClose) 
     
    676674        # Set up extra custom tool menu 
    677675        self._setup_extra_custom() 
    678         #self.Show(True) 
    679         #self._check_update(None) 
     676        self._check_update(None) 
    680677     
    681678    def _setup_extra_custom(self):   
     
    12461243            wx.EVT_MENU(self, id, self._onAbout) 
    12471244         
    1248         # Checking for updates needs major refactoring to work with py2exe 
    1249         # We need to make sure it doesn't hang the application if the server 
    1250         # is not up. We also need to make sure there's a proper executable to 
    1251         # run if we spawn a new background process. 
    1252         #id = wx.NewId() 
    1253         #self._help_menu.Append(id,'&Check for update',  
    1254         # 'Check for the latest version of %s' % config.__appname__) 
    1255         #wx.EVT_MENU(self, id, self._check_update) 
     1245        # Checking for updates 
     1246        id = wx.NewId() 
     1247        self._help_menu.Append(id,'&Check for update',  
     1248         'Check for the latest version of %s' % config.__appname__) 
     1249        wx.EVT_MENU(self, id, self._check_update) 
    12561250        self._menubar.Append(self._help_menu, '&Help') 
    12571251             
     
    21112105        a call-back method when the current version number has been obtained. 
    21122106        """ 
    2113          
    2114         if hasattr(config, "__update_URL__"): 
    2115             import version 
    2116             checker = version.VersionThread2(config.__update_URL__, 
    2117                                             self._process_version, 
    2118                                             baggage=event==None) 
    2119             checker.start()   
     2107        try: 
     2108            f=urllib2.urlopen(config.__update_URL__,  
     2109                              timeout=1.0) 
     2110            content=f.read() 
     2111        except: 
     2112            content = "0.0.0" 
     2113        
     2114        version = content.strip() 
     2115        if len(re.findall('\d+\.\d+\.\d+$', version)) < 0: 
     2116            content = "0.0.0" 
     2117        self._process_version(content, standalone=event==None) 
    21202118     
    21212119    def _process_version(self, version, standalone=True): 
     
    21322130        """ 
    21332131        try: 
    2134             if cmp(version, config.__version__) > 0: 
    2135                 msg = "Version %s is available! See the Help " % str(version) 
    2136                 msg += "menu to download it."  
     2132            if version == "0.0.0": 
     2133                msg = "Could not connect to the application server." 
     2134                msg += " Please try again later." 
    21372135                self.SetStatusText(msg) 
     2136            elif cmp(version, config.__version__) > 0: 
     2137                msg = "Version %s is available! " % str(version) 
    21382138                if not standalone: 
    21392139                    import webbrowser 
    21402140                    webbrowser.open(config.__download_page__) 
     2141                else: 
     2142                    msg +=  "See the help menu to download it."  
     2143                self.SetStatusText(msg) 
    21412144            else: 
    21422145                if not standalone: 
Note: See TracChangeset for help on using the changeset viewer.