dabo Commit
Revision 3550
Date: 2007-10-22 17:40:07 -0700 (Mon, 22 Oct 2007)
Author: Ed
Trac: http://svn.dabodev.com/trac/dabo/changeset/3550
Changed:
U trunk/dabo/dApp.py
U trunk/dabo/ui/uiwx/uiApp.py
Log:
Modified the web update code to check if the installation is using Subversion
to update Dabo; if so, it will not attempt to run web update, and will disable
the preferences for this. Also added code to check for the first time any
framework app is being run, and if such is the case, presents the user with a
message explaining the availability of web updates, and gives them the option
of immediately updating to the current revision.
Diff:
Modified: trunk/dabo/dApp.py
===================================================================
--- trunk/dabo/dApp.py 2007-10-22 18:40:02 UTC (rev 3549)
+++ trunk/dabo/dApp.py 2007-10-23 00:40:07 UTC (rev 3550)
@@ -377,50 +377,65 @@
def checkForUpdates(self, evt=None):
- """Public interface to the web updates mechanism."""
+ """Public interface to the web updates mechanism. Returns a
2-tuple
+ consisting of two booleans: the first is whether this is the
first time that
+ the framework is being run, and the second is whether updates
are
+ available now.
+ """
return self.uiApp.checkForUpdates(force=True)
def _checkForUpdates(self, force=False):
- ret = False
+ # If they are running Subversion, don't update.
+ usesSubversion =
os.path.isdir(os.path.join(os.path.split(dabo.__file__)[0], ".svn"))
+ if usesSubversion:
+ self._setWebUpdate(False)
+ return (False, False)
prf = self._frameworkPrefs
- val = prf.getValue
- runCheck = False
- now = datetime.datetime.now()
- if not force:
- webUpdate = val("web_update")
- if webUpdate:
- checkInterval = val("update_interval")
- if checkInterval is None:
- # Default to one day
- checkInterval = 24 * 60
- mins = datetime.timedelta(minutes=checkInterval)
- lastCheck = val("last_check")
- if lastCheck is None:
- lastCheck = datetime.datetime(1900, 1,
1)
- runCheck = (now > (lastCheck + mins))
- if runCheck:
- # See if there is a later version
- url = "http://dabodev.com/frameworkVersions/latest"
- try:
- vers = int(urllib.urlopen(url).read())
- except:
- vers = -1
- localVers = self._currentUpdateVersion()
- ret = (localVers != vers)
- prf.setValue("last_check", now)
- return ret
+ retAvailable = False
+ retFirstTime = not prf.hasKey("web_update")
+ if not retFirstTime:
+ val = prf.getValue
+ runCheck = False
+ now = datetime.datetime.now()
+ if not force:
+ webUpdate = val("web_update")
+ if webUpdate:
+ checkInterval = val("update_interval")
+ if checkInterval is None:
+ # Default to one day
+ checkInterval = 24 * 60
+ mins =
datetime.timedelta(minutes=checkInterval)
+ lastCheck = val("last_check")
+ if lastCheck is None:
+ lastCheck =
datetime.datetime(1900, 1, 1)
+ runCheck = (now > (lastCheck + mins))
+ if runCheck:
+ # See if there is a later version
+ url =
"http://dabodev.com/frameworkVersions/latest"
+ try:
+ vers = int(urllib.urlopen(url).read())
+ except:
+ vers = -1
+ localVers = self._currentUpdateVersion()
+ retAvailable = (localVers < vers)
+ urllib.urlcleanup()
+ prf.setValue("last_check", now)
+ return (retFirstTime, retAvailable)
def _updateFramework(self):
- """Get any changed files from the dabodev.com server, and
replace the local copies with them."""
+ """Get any changed files from the dabodev.com server, and
replace
+ the local copies with them. Return the new revision number"""
url = "http://dabodev.com/frameworkVersions/changedFiles/%s" %
self._currentUpdateVersion()
try:
resp = urllib.urlopen(url)
except:
# No internet access, or Dabo site is down.
+ dabo.errorLog.write(_("Cannot access the Dabo site."))
return
flist = eval(resp.read())
+ flist = eval(zz)
basePth = os.path.split(dabo.__file__)[0]
url = "http://dabodev.com/versions/dabo/%s"
for mtype, fpth in flist:
@@ -438,7 +453,13 @@
urllib.urlretrieve(url % fpth,
localFile)
except StandardError, e:
dabo.errorLog.write(_("Cannot update
file: '%s'. Error: %s") % (fpth, e))
+ url = "http://dabodev.com/frameworkVersions/latest"
+ try:
+ vers = int(urllib.urlopen(url).read())
+ except:
+ vers = self._currentUpdateVersion()
urllib.urlcleanup()
+ return vers
def _setWebUpdate(self, auto, interval=None):
Modified: trunk/dabo/ui/uiwx/uiApp.py
===================================================================
--- trunk/dabo/ui/uiwx/uiApp.py 2007-10-22 18:40:02 UTC (rev 3549)
+++ trunk/dabo/ui/uiwx/uiApp.py 2007-10-23 00:40:07 UTC (rev 3550)
@@ -170,12 +170,23 @@
def checkForUpdates(self, force=False):
answer = False
- if self.dApp._checkForUpdates(force=force):
- answer = dabo.ui.areYouSure(_("Framework updates are
available. Do you want to update now?"),
- title=_("Dabo Updates"),
cancelButton=False)
+ msg = ""
+ isFirst, updAvail = self.dApp._checkForUpdates(force=force)
+ if isFirst:
+ msg = _("This appears to be the first time you are
running Dabo. If you are "
+ "connected to the internet, Dabo will
check for updates and install them "
+ "if you wish. Click 'Yes' to get the
latest version of Dabo now, or 'No' if "
+ "you do not have internet access.")
+ # Default to checking once a day.
+ self.dApp._setWebUpdate(True, 24*60)
+ elif updAvail:
+ msg = _("Framework updates are available. Do you want
to update now?")
+ if msg:
+ answer = dabo.ui.areYouSure(msg, title=_("Dabo
Updates"), cancelButton=False)
if answer:
- self.dApp._updateFramework()
- dabo.ui.info(_("The app will now exit. Please
re-run the application."))
+ vers = self.dApp._updateFramework()
+ dabo.ui.info(_("Dabo has been updated to
revision %s. The app "
+ "will now exit. Please re-run
the application.") % vers)
return not answer
_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-dev
Searchable Archives: http://leafe.com/archives/search/dabo-dev
This message: http://leafe.com/archives/byMID/dabo-dev/[EMAIL PROTECTED]