@@ -0,0 +1,1875 @@
+'''%0D%0ACreated on 12.03.2013%0D%0A%0D%0A@author: mputz%0D%0A'''%0D%0A%0D%0Aimport os%0D%0Aimport platform%0D%0Aimport subprocess%0D%0Aimport sys%0D%0Aimport stat%0D%0A%0D%0Afrom trace import  IsTrace, Trace%0D%0A%0D%0ASUBPROCESSES = %5B%5D%0D%0A%0D%0A%0D%0Adef terminateHandle(signal, frame):%0D%0A    for cmd in SUBPROCESSES:%0D%0A        if cmd:%0D%0A            cmd.terminate()%0D%0A    sys.exit(0)%0D%0A%0D%0A%0D%0Adef stream2str(stream):%0D%0A    return str(stream, encoding='UTF-8')%0D%0A%0D%0A%0D%0Adef isUnix():%0D%0A    if platform.system() == %22Windows%22:%0D%0A        return False%0D%0A    else:%0D%0A        return True%0D%0A%0D%0A%0D%0Adef isPosix():%0D%0A    return platform.system() != %22Windows%22%0D%0A%0D%0A%0D%0Adef toUnixPath(path):%0D%0A    return path.replace('%5C%5C', '/')%0D%0A%0D%0A%0D%0Adef toWindowsPath(path):%0D%0A    return path.replace('/', '%5C%5C')%0D%0A%0D%0A%0D%0Adef os_link(src, dst):%0D%0A    if isUnix():%0D%0A        # requires src in relation to dst%0D%0A        src = os.path.relpath(src, os.path.dirname(dst))%0D%0A        os.symlink(src, dst)%0D%0A    else:%0D%0A        isDir = True if os.path.isdir(src) else False%0D%0A        src = os.path.relpath(src, os.path.dirname(dst))%0D%0A        src = toWindowsPath(src)%0D%0A        dst = toWindowsPath(dst)%0D%0A        # ln in MinGW does not create hard links? - it copies%0D%0A        # call windows cmd tool 'mklink' from git bash (mingw)%0D%0A        if isDir:%0D%0A            cmd = 'cmd /c mklink /D %22%25s%22 %22%25s%22' %25 (dst, src)%0D%0A            if IsTrace():%0D%0A                Trace(cmd)%0D%0A            subprocess.Popen(cmd, stdout=subprocess.PIPE).wait()%0D%0A        else:%0D%0A            cmd = 'cmd /c mklink %22%25s%22 %22%25s%22' %25 (dst, src)%0D%0A            if IsTrace():%0D%0A                Trace(cmd)%0D%0A            subprocess.Popen(cmd, stdout=subprocess.PIPE).wait()%0D%0A%0D%0A%0D%0Adef removeReadOnlyFilesHandler(fn, path, excinfo):%0D%0A    removeReadOnlyFiles(fn, path)%0D%0A%0D%0A%0D%0Adef removeReadOnlyFiles(fn, path):%0D%0A    if not os.access(path, os.W_OK):%0D%0A        os.chmod(path, stat.S_IWUSR)%0D%0A        fn(path)%0D%0A    else:%0D%0A        raise Exception(%22Could not delete %25s%22 %25 path)%0D%0A

add file portable.py