def is_locked_version_dir(vdir): """Check whether the given version dir is locked.""" if sys.platform == "win32": lockfile = os.path.join(vdir,ESKY_CONTROL_DIR,"bootstrap-manifest.txt") try: os.rename(lockfile,lockfile) except EnvironmentError: return True else: return False else: lockfile = os.path.join(vdir,ESKY_CONTROL_DIR,"lockfile.txt") f = open(lockfile,"r") try: fcntl.flock(f,fcntl.LOCK_EX|fcntl.LOCK_NB) except EnvironmentError, e: if e.errno not in (errno.EACCES,errno.EAGAIN,): raise return True else: