Skip to content

Commit

Permalink
Esky.cleanup_at_exit: re-launch best version rather than cur version
Browse files Browse the repository at this point in the history
  • Loading branch information
rfk committed Jun 2, 2010
1 parent 34f2ee4 commit fbb3660
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 11 deletions.
9 changes: 4 additions & 5 deletions ChangeLog.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@

v0.7.3:

* DefaultVersionFinder: when a downloaded file fails because it is
corrupted, remove it from disk as well as from the version graph.

v0.7.2:

* added methods Esky.needs_cleanup() and VersionFinder.needs_cleanup();
Expand All @@ -13,6 +8,10 @@ v0.7.2:
* allow Esky.lock() and Esky.unlock() to be called via sudo proxy.
* support for Python 3 on win32 (cx-freeze only).
* fixed compatability with Python 2.5 (via __future__ imports).
* Esky.cleanup_at_exit: try to launch the latest version rather than
the current version, so current version can be cleaned up.
* DefaultVersionFinder: when a downloaded file fails because it is
corrupted, remove it from disk as well as from the version graph.

v0.7.1:

Expand Down
24 changes: 18 additions & 6 deletions esky/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,6 @@
__ver_sub__ = ""
__version__ = "%d.%d.%d%s" % (__ver_major__,__ver_minor__,__ver_patch__,__ver_sub__)


import os
import sys
import shutil
Expand Down Expand Up @@ -523,12 +522,25 @@ def cleanup_at_exit(self):
return self.sudo_proxy.cleanup_at_exit()
if not getattr(sys,"frozen",False):
exe = [sys.executable,"-c","import esky; esky.run_startup_hooks()","--esky-spawn-cleanup"]
elif os.path.basename(sys.executable).lower() in ("python","pythonw"):
exe = [sys.executable,"-c","import esky; esky.run_startup_hooks()","--esky-spawn-cleanup"]
else:
if not _startup_hooks_were_run:
raise OSError(None,"unable to sudo: startup hooks not run")
exe = [sys.executable,"--esky-spawn-cleanup"]
exe = sys.executable
# Try to re-launch the best available version, so that the
# currently in-use version can be cleaned up.
if self.active_version is not None:
appdir = self.appdir
bestver = get_best_version(appdir,include_partial_installs=True)
(_,version,_) = split_app_version(bestver)
if self.active_version != version:
if self.active_version in exe:
exe = exe.replace(self.active_version,version)
if not os.path.isfile(exe):
exe = sys.executable
if os.path.basename(exe).lower() in ("python","pythonw"):
exe = [exe,"-c","import esky; esky.run_startup_hooks()","--esky-spawn-cleanup"]
else:
if not _startup_hooks_were_run:
raise OSError(None,"unable to cleanup: startup hooks not run")
exe = [exe,"--esky-spawn-cleanup"]
exe = exe + [b64encode(pickle.dumps(self,pickle.HIGHEST_PROTOCOL))]
@atexit.register
def spawn_cleanup():
Expand Down

0 comments on commit fbb3660

Please sign in to comment.