你知道问题是什么吗?
try:
localFile = open(localDir + '/' + iso + '/' + output, 'w')
except:
emit('update-status', (iso, 'Error: Couldn\'t create file ' + localDir + '/' + iso + '/' + output + ' !'))
return
print('RETR ' + as400Dir + '/' + output)
try:
ftp.retrlines('RETR ' + as400Dir + '/' + output, localFile.write)
except ftplib.all_errors as e:
# except Exception as e:
emit('update-status', (iso, 'Error: Couldn\'t download file ' + as400Dir + "/" + output + ' ! -> ' + str(e)))
return
localFile.close()
控制台输出:
RETR /xreff/pgmref.csv
Exception in thread Thread-5:
Traceback (most recent call last):
File "D:\LocalData\xxx\Install\Python35-32\lib\threading.py", line 914, in _bootstrap_inner
self.run()
File "D:\LocalData\xxx\Install\Python35-32\lib\threading.py", line 862, in run
self._target(*self._args, **self._kwargs)
File "D:\LocalData\xxx\Install\Python35-32\lib\site-packages\socketio\server.py", line 452, in _handle_event_internal
r = server._trigger_event(data[0], namespace, sid, *data[1:])
File "D:\LocalData\xxx\Install\Python35-32\lib\site-packages\socketio\server.py", line 481, in _trigger_event
return self.handlers[namespace][event](*args)
File "D:\LocalData\xxx\Install\Python35-32\lib\site-packages\flask_socketio\__init__.py", line 236, in _handler
*args)
File "D:\LocalData\xxx\Install\Python35-32\lib\site-packages\flask_socketio\__init__.py", line 618, in _handle_event
ret = handler(*args)
File "./index.py", line 453, in updateDatabase
downloadResourceFiles(iso, user, password, xreff, gafint, sugar)
File "./index.py", line 545, in downloadResourceFiles
downloadFiles()
File "./index.py", line 523, in downloadFiles
ftp.retrlines('RETR ' + as400Dir + '/' + output, localFile.write)
File "D:\LocalData\xxx\Install\Python35-32\lib\ftplib.py", line 467, in retrlines
with self.transfercmd(cmd) as conn, \
AttributeError: __exit__
如果我尝试
例外情况除外,如e
ftplib除外。所有_错误为e
我得到:
RETR /xreff/pgmref.csv
emitting event "update-status" to b563563a763e48fbba2d394ae8c871e7 [/]
b563563a763e48fbba2d394ae8c871e7: Sending packet MESSAGE data 2["update-status","NL","Error: Couldn't download file /xreff/pgmref.csv ! -> __exit__"]