summaryrefslogtreecommitdiffstats
path: root/Demo/pdist/cmptree.py
diff options
context:
space:
mode:
authorCollin Winter <collinw@gmail.com>2007-07-17 20:59:35 (GMT)
committerCollin Winter <collinw@gmail.com>2007-07-17 20:59:35 (GMT)
commit6f2df4d5e193d54244b0c2de91ef0ab1604b9243 (patch)
tree5e172400da7561eb4bb8fafc62c8cab511d74dad /Demo/pdist/cmptree.py
parenta8c360ee76fb76902a2e2140fbb38d4b06b2d9fb (diff)
downloadcpython-6f2df4d5e193d54244b0c2de91ef0ab1604b9243.zip
cpython-6f2df4d5e193d54244b0c2de91ef0ab1604b9243.tar.gz
cpython-6f2df4d5e193d54244b0c2de91ef0ab1604b9243.tar.bz2
Run 2to3 over the Demo/ directory to shut up parse errors from 2to3 about lingering print statements.
Diffstat (limited to 'Demo/pdist/cmptree.py')
-rwxr-xr-xDemo/pdist/cmptree.py86
1 files changed, 43 insertions, 43 deletions
diff --git a/Demo/pdist/cmptree.py b/Demo/pdist/cmptree.py
index 5031869..d6962e9 100755
--- a/Demo/pdist/cmptree.py
+++ b/Demo/pdist/cmptree.py
@@ -13,7 +13,7 @@ def raw_input(prompt):
def main():
pwd = os.getcwd()
- s = raw_input("chdir [%s] " % pwd)
+ s = input("chdir [%s] " % pwd)
if s:
os.chdir(s)
pwd = os.getcwd()
@@ -21,14 +21,14 @@ def main():
port = 4127
verbose = 1
mode = ''
- print """\
+ print("""\
Mode should be a string of characters, indicating what to do with differences.
r - read different files to local file system
w - write different files to remote file system
c - create new files, either remote or local
d - delete disappearing files, either remote or local
-"""
- s = raw_input("mode [%s] " % mode)
+""")
+ s = input("mode [%s] " % mode)
if s: mode = s
address = (host, port)
t1 = time.time()
@@ -40,74 +40,74 @@ d - delete disappearing files, either remote or local
t2 = time.time()
dt = t2-t1
mins, secs = divmod(dt, 60)
- print mins, "minutes and", round(secs), "seconds"
- raw_input("[Return to exit] ")
+ print(mins, "minutes and", round(secs), "seconds")
+ input("[Return to exit] ")
def ask(prompt, default):
- s = raw_input("%s [%s] " % (prompt, default))
+ s = input("%s [%s] " % (prompt, default))
return s or default
def askint(prompt, default):
- s = raw_input("%s [%s] " % (prompt, str(default)))
+ s = input("%s [%s] " % (prompt, str(default)))
if s: return string.atoi(s)
return default
def compare(local, remote, mode):
- print
- print "PWD =", repr(os.getcwd())
+ print()
+ print("PWD =", repr(os.getcwd()))
sums_id = remote._send('sumlist')
subdirs_id = remote._send('listsubdirs')
remote._flush()
- print "calculating local sums ..."
+ print("calculating local sums ...")
lsumdict = {}
for name, info in local.sumlist():
lsumdict[name] = info
- print "getting remote sums ..."
+ print("getting remote sums ...")
sums = remote._recv(sums_id)
- print "got", len(sums)
+ print("got", len(sums))
rsumdict = {}
for name, rsum in sums:
rsumdict[name] = rsum
- if not lsumdict.has_key(name):
- print repr(name), "only remote"
+ if name not in lsumdict:
+ print(repr(name), "only remote")
if 'r' in mode and 'c' in mode:
recvfile(local, remote, name)
else:
lsum = lsumdict[name]
if lsum != rsum:
- print repr(name),
+ print(repr(name), end=' ')
rmtime = remote.mtime(name)
lmtime = local.mtime(name)
if rmtime > lmtime:
- print "remote newer",
+ print("remote newer", end=' ')
if 'r' in mode:
recvfile(local, remote, name)
elif lmtime > rmtime:
- print "local newer",
+ print("local newer", end=' ')
if 'w' in mode:
sendfile(local, remote, name)
else:
- print "same mtime but different sum?!?!",
- print
- for name in lsumdict.keys():
- if not rsumdict.keys():
- print repr(name), "only locally",
+ print("same mtime but different sum?!?!", end=' ')
+ print()
+ for name in list(lsumdict.keys()):
+ if not list(rsumdict.keys()):
+ print(repr(name), "only locally", end=' ')
fl()
if 'w' in mode and 'c' in mode:
sendfile(local, remote, name)
elif 'r' in mode and 'd' in mode:
os.unlink(name)
- print "removed."
- print
- print "gettin subdirs ..."
+ print("removed.")
+ print()
+ print("gettin subdirs ...")
subdirs = remote._recv(subdirs_id)
common = []
for name in subdirs:
if local.isdir(name):
- print "Common subdirectory", repr(name)
+ print("Common subdirectory", repr(name))
common.append(name)
else:
- print "Remote subdirectory", repr(name), "not found locally"
+ print("Remote subdirectory", repr(name), "not found locally")
if 'r' in mode and 'c' in mode:
pr = "Create local subdirectory %s? [y] " % \
repr(name)
@@ -117,15 +117,15 @@ def compare(local, remote, mode):
ok = ask(pr, "y")
if ok[:1] in ('y', 'Y'):
local.mkdir(name)
- print "Subdirectory %s made" % \
- repr(name)
+ print("Subdirectory %s made" % \
+ repr(name))
common.append(name)
lsubdirs = local.listsubdirs()
for name in lsubdirs:
if name not in subdirs:
- print "Local subdirectory", repr(name), "not found remotely"
+ print("Local subdirectory", repr(name), "not found remotely")
for name in common:
- print "Entering subdirectory", repr(name)
+ print("Entering subdirectory", repr(name))
local.cd(name)
remote.cd(name)
compare(local, remote, mode)
@@ -136,10 +136,10 @@ def sendfile(local, remote, name):
try:
remote.create(name)
except (IOError, os.error) as msg:
- print "cannot create:", msg
+ print("cannot create:", msg)
return
- print "sending ...",
+ print("sending ...", end=' ')
fl()
data = open(name).read()
@@ -152,10 +152,10 @@ def sendfile(local, remote, name):
t2 = time.time()
dt = t2-t1
- print len(data), "bytes in", round(dt), "seconds",
+ print(len(data), "bytes in", round(dt), "seconds", end=' ')
if dt:
- print "i.e.", round(len(data)/dt), "bytes/sec",
- print
+ print("i.e.", round(len(data)/dt), "bytes/sec", end=' ')
+ print()
def recvfile(local, remote, name):
ok = 0
@@ -165,17 +165,17 @@ def recvfile(local, remote, name):
return rv
finally:
if not ok:
- print "*** recvfile of %r failed, deleting" % (name,)
+ print("*** recvfile of %r failed, deleting" % (name,))
local.delete(name)
def recvfile_real(local, remote, name):
try:
local.create(name)
except (IOError, os.error) as msg:
- print "cannot create:", msg
+ print("cannot create:", msg)
return
- print "receiving ...",
+ print("receiving ...", end=' ')
fl()
f = open(name, 'w')
@@ -200,10 +200,10 @@ def recvfile_real(local, remote, name):
f.close()
dt = t2-t1
- print size, "bytes in", round(dt), "seconds",
+ print(size, "bytes in", round(dt), "seconds", end=' ')
if dt:
- print "i.e.", int(size/dt), "bytes/sec",
- print
+ print("i.e.", int(size/dt), "bytes/sec", end=' ')
+ print()
remote._recv(id) # ignored
def fl():