don't die on unreadable files etc.
This commit is contained in:
parent
3326b672bd
commit
d2966cb95a
|
@ -1,4 +1,4 @@
|
||||||
#! /usr/local/bin/python
|
#! /ufs/guido/bin/sgi/python
|
||||||
|
|
||||||
# Mirror a remote ftp subtree into a local directory tree.
|
# Mirror a remote ftp subtree into a local directory tree.
|
||||||
# Basic usage: ftpmirror [options] host remotedir localdir
|
# Basic usage: ftpmirror [options] host remotedir localdir
|
||||||
|
@ -43,7 +43,7 @@ interactive = 0
|
||||||
mac = 0
|
mac = 0
|
||||||
rmok = 0
|
rmok = 0
|
||||||
nologin = 0
|
nologin = 0
|
||||||
skippats = []
|
skippats = ['.', '..', '.mirrorinfo']
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
global verbose, interactive, mac, rmok, nologin
|
global verbose, interactive, mac, rmok, nologin
|
||||||
|
@ -136,9 +136,6 @@ def mirrorsubdir(f, localdir):
|
||||||
(words[-3], words[-1])
|
(words[-3], words[-1])
|
||||||
continue
|
continue
|
||||||
filename = words[-1]
|
filename = words[-1]
|
||||||
if filename in ('.', '..'):
|
|
||||||
if verbose > 1: print 'Skipping . or ..'
|
|
||||||
continue
|
|
||||||
infostuff = words[-5:-1]
|
infostuff = words[-5:-1]
|
||||||
mode = words[0]
|
mode = words[0]
|
||||||
skip = 0
|
skip = 0
|
||||||
|
@ -167,6 +164,10 @@ def mirrorsubdir(f, localdir):
|
||||||
if not info.has_key(filename):
|
if not info.has_key(filename):
|
||||||
info[filename] = 'Not retrieved'
|
info[filename] = 'Not retrieved'
|
||||||
continue
|
continue
|
||||||
|
try:
|
||||||
|
os.unlink(fullname)
|
||||||
|
except os.error:
|
||||||
|
pass
|
||||||
try:
|
try:
|
||||||
fp = open(fullname, 'w')
|
fp = open(fullname, 'w')
|
||||||
except IOError, msg:
|
except IOError, msg:
|
||||||
|
@ -180,7 +181,10 @@ def mirrorsubdir(f, localdir):
|
||||||
else:
|
else:
|
||||||
fp1 = fp
|
fp1 = fp
|
||||||
t0 = time.time()
|
t0 = time.time()
|
||||||
|
try:
|
||||||
f.retrbinary('RETR ' + filename, fp1.write, 8*1024)
|
f.retrbinary('RETR ' + filename, fp1.write, 8*1024)
|
||||||
|
except ftplib.error_perm, msg:
|
||||||
|
print msg
|
||||||
t1 = time.time()
|
t1 = time.time()
|
||||||
bytes = fp.tell()
|
bytes = fp.tell()
|
||||||
fp.close()
|
fp.close()
|
||||||
|
|
Loading…
Reference in New Issue