]> git.proxmox.com Git - mirror_edk2.git/blobdiff - AppPkg/Applications/Python/Python-2.7.2/Demo/pdist/cmptree.py
edk2: Remove AppPkg, StdLib, StdLibPrivateInternalFiles
[mirror_edk2.git] / AppPkg / Applications / Python / Python-2.7.2 / Demo / pdist / cmptree.py
diff --git a/AppPkg/Applications/Python/Python-2.7.2/Demo/pdist/cmptree.py b/AppPkg/Applications/Python/Python-2.7.2/Demo/pdist/cmptree.py
deleted file mode 100644 (file)
index 2f8a8a8..0000000
+++ /dev/null
@@ -1,208 +0,0 @@
-"""Compare local and remote dictionaries and transfer differing files -- like rdist."""\r
-\r
-import sys\r
-from repr import repr\r
-import FSProxy\r
-import time\r
-import os\r
-\r
-def main():\r
-    pwd = os.getcwd()\r
-    s = raw_input("chdir [%s] " % pwd)\r
-    if s:\r
-        os.chdir(s)\r
-        pwd = os.getcwd()\r
-    host = ask("host", 'voorn.cwi.nl')\r
-    port = 4127\r
-    verbose = 1\r
-    mode = ''\r
-    print """\\r
-Mode should be a string of characters, indicating what to do with differences.\r
-r - read different files to local file system\r
-w - write different files to remote file system\r
-c - create new files, either remote or local\r
-d - delete disappearing files, either remote or local\r
-"""\r
-    s = raw_input("mode [%s] " % mode)\r
-    if s: mode = s\r
-    address = (host, port)\r
-    t1 = time.time()\r
-    local = FSProxy.FSProxyLocal()\r
-    remote = FSProxy.FSProxyClient(address, verbose)\r
-    compare(local, remote, mode)\r
-    remote._close()\r
-    local._close()\r
-    t2 = time.time()\r
-    dt = t2-t1\r
-    mins, secs = divmod(dt, 60)\r
-    print mins, "minutes and", round(secs), "seconds"\r
-    raw_input("[Return to exit] ")\r
-\r
-def ask(prompt, default):\r
-    s = raw_input("%s [%s] " % (prompt, default))\r
-    return s or default\r
-\r
-def askint(prompt, default):\r
-    s = raw_input("%s [%s] " % (prompt, str(default)))\r
-    if s: return string.atoi(s)\r
-    return default\r
-\r
-def compare(local, remote, mode):\r
-    print\r
-    print "PWD =", repr(os.getcwd())\r
-    sums_id = remote._send('sumlist')\r
-    subdirs_id = remote._send('listsubdirs')\r
-    remote._flush()\r
-    print "calculating local sums ..."\r
-    lsumdict = {}\r
-    for name, info in local.sumlist():\r
-        lsumdict[name] = info\r
-    print "getting remote sums ..."\r
-    sums = remote._recv(sums_id)\r
-    print "got", len(sums)\r
-    rsumdict = {}\r
-    for name, rsum in sums:\r
-        rsumdict[name] = rsum\r
-        if not lsumdict.has_key(name):\r
-            print repr(name), "only remote"\r
-            if 'r' in mode and 'c' in mode:\r
-                recvfile(local, remote, name)\r
-        else:\r
-            lsum = lsumdict[name]\r
-            if lsum != rsum:\r
-                print repr(name),\r
-                rmtime = remote.mtime(name)\r
-                lmtime = local.mtime(name)\r
-                if rmtime > lmtime:\r
-                    print "remote newer",\r
-                    if 'r' in mode:\r
-                        recvfile(local, remote, name)\r
-                elif lmtime > rmtime:\r
-                    print "local newer",\r
-                    if 'w' in mode:\r
-                        sendfile(local, remote, name)\r
-                else:\r
-                    print "same mtime but different sum?!?!",\r
-                print\r
-    for name in lsumdict.keys():\r
-        if not rsumdict.keys():\r
-            print repr(name), "only locally",\r
-            fl()\r
-            if 'w' in mode and 'c' in mode:\r
-                sendfile(local, remote, name)\r
-            elif 'r' in mode and 'd' in mode:\r
-                os.unlink(name)\r
-                print "removed."\r
-            print\r
-    print "gettin subdirs ..."\r
-    subdirs = remote._recv(subdirs_id)\r
-    common = []\r
-    for name in subdirs:\r
-        if local.isdir(name):\r
-            print "Common subdirectory", repr(name)\r
-            common.append(name)\r
-        else:\r
-            print "Remote subdirectory", repr(name), "not found locally"\r
-            if 'r' in mode and 'c' in mode:\r
-                pr = "Create local subdirectory %s? [y] " % \\r
-                     repr(name)\r
-                if 'y' in mode:\r
-                    ok = 'y'\r
-                else:\r
-                    ok = ask(pr, "y")\r
-                if ok[:1] in ('y', 'Y'):\r
-                    local.mkdir(name)\r
-                    print "Subdirectory %s made" % \\r
-                            repr(name)\r
-                    common.append(name)\r
-    lsubdirs = local.listsubdirs()\r
-    for name in lsubdirs:\r
-        if name not in subdirs:\r
-            print "Local subdirectory", repr(name), "not found remotely"\r
-    for name in common:\r
-        print "Entering subdirectory", repr(name)\r
-        local.cd(name)\r
-        remote.cd(name)\r
-        compare(local, remote, mode)\r
-        remote.back()\r
-        local.back()\r
-\r
-def sendfile(local, remote, name):\r
-    try:\r
-        remote.create(name)\r
-    except (IOError, os.error), msg:\r
-        print "cannot create:", msg\r
-        return\r
-\r
-    print "sending ...",\r
-    fl()\r
-\r
-    data = open(name).read()\r
-\r
-    t1 = time.time()\r
-\r
-    remote._send_noreply('write', name, data)\r
-    remote._flush()\r
-\r
-    t2 = time.time()\r
-\r
-    dt = t2-t1\r
-    print len(data), "bytes in", round(dt), "seconds",\r
-    if dt:\r
-        print "i.e.", round(len(data)/dt), "bytes/sec",\r
-    print\r
-\r
-def recvfile(local, remote, name):\r
-    ok = 0\r
-    try:\r
-        rv = recvfile_real(local, remote, name)\r
-        ok = 1\r
-        return rv\r
-    finally:\r
-        if not ok:\r
-            print "*** recvfile of %r failed, deleting" % (name,)\r
-            local.delete(name)\r
-\r
-def recvfile_real(local, remote, name):\r
-    try:\r
-        local.create(name)\r
-    except (IOError, os.error), msg:\r
-        print "cannot create:", msg\r
-        return\r
-\r
-    print "receiving ...",\r
-    fl()\r
-\r
-    f = open(name, 'w')\r
-    t1 = time.time()\r
-\r
-    length = 4*1024\r
-    offset = 0\r
-    id = remote._send('read', name, offset, length)\r
-    remote._flush()\r
-    while 1:\r
-        newoffset = offset + length\r
-        newid = remote._send('read', name, newoffset, length)\r
-        data = remote._recv(id)\r
-        id = newid\r
-        if not data: break\r
-        f.seek(offset)\r
-        f.write(data)\r
-        offset = newoffset\r
-    size = f.tell()\r
-\r
-    t2 = time.time()\r
-    f.close()\r
-\r
-    dt = t2-t1\r
-    print size, "bytes in", round(dt), "seconds",\r
-    if dt:\r
-        print "i.e.", size//dt, "bytes/sec",\r
-    print\r
-    remote._recv(id) # ignored\r
-\r
-def fl():\r
-    sys.stdout.flush()\r
-\r
-if __name__ == '__main__':\r
-    main()\r