summaryrefslogtreecommitdiffstats
path: root/Tools/scripts/ftpmirror.py
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2007-01-10 16:19:56 (GMT)
committerGuido van Rossum <guido@python.org>2007-01-10 16:19:56 (GMT)
commitb940e113bf90ff71b0ef57414ea2beea9d2a4bc0 (patch)
tree0b9ea19eba1e665dac95126c3140ac2bc36326ad /Tools/scripts/ftpmirror.py
parent893523e80a2003d4a630aafb84ba016e0070cbbd (diff)
downloadcpython-b940e113bf90ff71b0ef57414ea2beea9d2a4bc0.zip
cpython-b940e113bf90ff71b0ef57414ea2beea9d2a4bc0.tar.gz
cpython-b940e113bf90ff71b0ef57414ea2beea9d2a4bc0.tar.bz2
SF patch 1631942 by Collin Winter:
(a) "except E, V" -> "except E as V" (b) V is now limited to a simple name (local variable) (c) V is now deleted at the end of the except block
Diffstat (limited to 'Tools/scripts/ftpmirror.py')
-rwxr-xr-xTools/scripts/ftpmirror.py20
1 files changed, 10 insertions, 10 deletions
diff --git a/Tools/scripts/ftpmirror.py b/Tools/scripts/ftpmirror.py
index caade16..39ef18e 100755
--- a/Tools/scripts/ftpmirror.py
+++ b/Tools/scripts/ftpmirror.py
@@ -45,7 +45,7 @@ def main():
global verbose, interactive, mac, rmok, nologin
try:
opts, args = getopt.getopt(sys.argv[1:], 'a:bil:mnp:qrs:v')
- except getopt.error, msg:
+ except getopt.error as msg:
usage(msg)
login = ''
passwd = ''
@@ -108,13 +108,13 @@ def mirrorsubdir(f, localdir):
if verbose: print 'Creating local directory', repr(localdir)
try:
makedir(localdir)
- except os.error, msg:
+ except os.error as msg:
print "Failed to establish local directory", repr(localdir)
return
infofilename = os.path.join(localdir, '.mirrorinfo')
try:
text = open(infofilename, 'r').read()
- except IOError, msg:
+ except IOError as msg:
text = '{}'
try:
info = eval(text)
@@ -190,13 +190,13 @@ def mirrorsubdir(f, localdir):
print "Creating symlink %r -> %r" % (filename, linkto)
try:
os.symlink(linkto, tempname)
- except IOError, msg:
+ except IOError as msg:
print "Can't create %r: %s" % (tempname, msg)
continue
else:
try:
fp = open(tempname, 'wb')
- except IOError, msg:
+ except IOError as msg:
print "Can't create %r: %s" % (tempname, msg)
continue
if verbose:
@@ -209,7 +209,7 @@ def mirrorsubdir(f, localdir):
try:
f.retrbinary('RETR ' + filename,
fp1.write, 8*1024)
- except ftplib.error_perm, msg:
+ except ftplib.error_perm as msg:
print msg
t1 = time.time()
bytes = fp.tell()
@@ -222,7 +222,7 @@ def mirrorsubdir(f, localdir):
pass # Ignore the error
try:
os.rename(tempname, fullname)
- except os.error, msg:
+ except os.error as msg:
print "Can't rename %r to %r: %s" % (tempname, fullname, msg)
continue
info[filename] = infostuff
@@ -292,7 +292,7 @@ def mirrorsubdir(f, localdir):
print 'Remote cwd', repr(subdir)
try:
f.cwd(subdir)
- except ftplib.error_perm, msg:
+ except ftplib.error_perm as msg:
print "Can't chdir to", repr(subdir), ":", repr(msg)
else:
if verbose: print 'Mirroring as', repr(localsubdir)
@@ -322,13 +322,13 @@ def remove(fullname):
return 0
try:
os.rmdir(fullname)
- except os.error, msg:
+ except os.error as msg:
print "Can't remove local directory %r: %s" % (fullname, msg)
return 0
else:
try:
os.unlink(fullname)
- except os.error, msg:
+ except os.error as msg:
print "Can't remove local file %r: %s" % (fullname, msg)
return 0
return 1