Changeset 6df04e43 in sasview
- Timestamp:
- Nov 18, 2011 2:43:13 PM (13 years ago)
- 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:
- 3dc977c
- Parents:
- 930f559
- Location:
- sansguiframe/src/sans/guiframe
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
sansguiframe/src/sans/guiframe/dummyapp.py
r70ecd530 r6df04e43 122 122 123 123 if __name__ == "__main__": 124 from multiprocessing import freeze_support 125 freeze_support() 124 126 sansview = SansView() 125 -
sansguiframe/src/sans/guiframe/gui_manager.py
r70ecd530 r6df04e43 288 288 self.add_icon() 289 289 # Check for update 290 #self._check_update(None)290 self._check_update(None) 291 291 # Register the close event so it calls our own method 292 292 wx.EVT_CLOSE(self, self.Close) … … 657 657 self._setup_extra_custom() 658 658 #self.Show(True) 659 #self._check_update(None)659 self._check_update(None) 660 660 661 661 def _setup_extra_custom(self): … … 698 698 """ 699 699 number = self.sb.get_msg_position() 700 wx.Frame.SetStatusText( number=number, *args, **kwds)700 wx.Frame.SetStatusText(self, number=number, *args, **kwds) 701 701 702 702 def PopStatusText(self, *args, **kwds): … … 704 704 """ 705 705 field = self.sb.get_msg_position() 706 wx.Frame.PopStatusText( field=field)706 wx.Frame.PopStatusText(self, field=field) 707 707 708 708 def PushStatusText(self, *args, **kwds): … … 1233 1233 #self._help_menu.Append(id,'&Check for update', 1234 1234 #'Check for the latest version of %s' % config.__appname__) 1235 #wx.EVT_MENU(self, id, self._check_update)1235 wx.EVT_MENU(self, id, self._check_update) 1236 1236 self._menubar.Append(self._help_menu, '&Help') 1237 1237 … … 2085 2085 a call-back method when the current version number has been obtained. 2086 2086 """ 2087 2087 2088 if hasattr(config, "__update_URL__"): 2088 2089 import version 2089 checker = version.VersionThread (config.__update_URL__,2090 checker = version.VersionThread2(config.__update_URL__, 2090 2091 self._process_version, 2091 2092 baggage=event==None) … … 2106 2107 try: 2107 2108 if cmp(version, config.__version__) > 0: 2108 msg = "Version %s is available! See the Help " 2109 msg += "menu to download it." % version2109 msg = "Version %s is available! See the Help " % str(version) 2110 msg += "menu to download it." 2110 2111 self.SetStatusText(msg) 2111 2112 if not standalone: … … 2115 2116 if not standalone: 2116 2117 msg = "You have the latest version" 2117 msg += " of %s" % config.__appname__2118 msg += " of %s" % str(config.__appname__) 2118 2119 self.SetStatusText(msg) 2119 2120 except: … … 3206 3207 self.frame.Show(True) 3207 3208 event.Skip() 3208 3209 3209 3210 if __name__ == "__main__": 3210 3211 app = ViewApp(0) -
sansguiframe/src/sans/guiframe/version.py
r8c347a6 r6df04e43 14 14 import time 15 15 import subprocess 16 import urllib 17 import re 16 18 import os 17 19 import getopt … … 22 24 ## Local storage file name 23 25 VERSION_FILE = '.current_version' 26 27 DEFAULT_VERSION = '0.0.0' 24 28 25 29 class VersionChecker(object): … … 71 75 return f.read() 72 76 except: 73 return '0.0.0'77 return DEFAULT_VERSION 74 78 75 79 class VersionThread(Thread): … … 96 100 time.sleep(1) 97 101 self._call_back(checker.get_version(), self._baggage) 102 103 104 def get_version(url, q=None): 105 """ 106 """ 107 h = urllib.urlopen(url) 108 for line in h.readlines(): 109 version = line.strip() 110 if len(re.findall('\d+\.\d+\.\d+$', version)) > 0: 111 if q is not None: 112 q.put(version) 113 return version 114 if q is not None: 115 q.put(DEFAULT_VERSION) 116 return DEFAULT_VERSION 117 118 class VersionThread2(Thread): 119 """ 120 Thread used to start the process of reading the current version of an 121 application from the deployment server. 122 123 The VersionChecker is user in a Thread to allow the main application 124 to continue dealing with UI requests from the user. The main application 125 provides a call-back method for when the version number is obtained. 126 """ 127 def __init__ (self, url, call_back=None, baggage=None): 128 Thread.__init__(self) 129 self._url = url 130 self._call_back = call_back 131 self._baggage = baggage 132 self._t_0 = time.time() 133 134 def run(self): 135 """ 136 Execute the process of reading the current application version number. 137 """ 138 def is_complete(p): 139 """ 140 """ 141 if(time.time() - self._t_0 < MAX_WAIT_TIME): 142 if p.is_alive(): 143 return True 144 return False 145 else: 146 return False 147 148 from multiprocessing import Process, Queue 149 q = Queue() 150 p = Process(target=get_version, args=(self._url, q,)) 151 p.start() 152 while(not is_complete(p)): 153 time.sleep(1) 154 version = q.get() 155 p.join() 156 p.terminate() 157 self._call_back(version, self._baggage) 158 98 159 99 160 def write_version(version, filename=VERSION_FILE): … … 114 175 115 176 """ 116 import urllib117 import re118 177 try: 119 h = urllib.urlopen(url) 120 for line in h.readlines(): 121 version = line.strip() 122 if len(re.findall('\d+\.\d+\.\d+$', version)) > 0: 123 write_version(version) 124 return 125 write_version('0.0.0') 178 version = _get_version(url) 179 write_version(version) 126 180 except: 127 write_version('0.0.0') 181 write_version(DEFAULT_VERSION) 182 183 128 184 129 185 if __name__ == "__main__":
Note: See TracChangeset
for help on using the changeset viewer.