import base
import ftp_config
import socket
-import api_exceptions
+import cis_exceptions
import os
import logger
try:
self.ftp.cwd(self.remote_path)
except ftplib.error_perm as e:
- raise api_exceptions.FileTransferException( \
+ raise cis_exceptions.FileTransferException( \
"Could not change remote directory '%s': %s" \
% (self.remote_path, repr(e)))
for crt_fn in files:
local_fn = os.path.join(self.local_path, crt_fn)
remote_fn = os.path.join(self.remote_path, crt_fn)
+
+ if os.path.exists(local_fn):
+ raise cis_exceptions.FileAlreadyExistsException( \
+ 'file "%s" already exists' % local_fn)
+
try:
file_local = open(local_fn, 'wb')
except IOError as e:
- raise api_exceptions.FileTransferException( \
+ raise cis_exceptions.FileTransferException( \
"Could not open local file '%s' for writing: %s" \
% (local_fn, repr(e)))
self.ftp.retrbinary('RETR %s' % crt_fn, file_local.write)
file_local.close()
except ftplib.error_perm as e:
- raise api_exceptions.FileTransferException( \
+ raise cis_exceptions.FileTransferException( \
"Could not get file '%s' from Web Server: %s" \
% (remote_fn, repr(e)))
try:
self.ftp.cwd(self.remote_path)
except ftplib.error_perm as e:
- raise api_exceptions.FileTransferException( \
+ raise cis_exceptions.FileTransferException( \
"Could not change remote directory '%s': %s" \
% (self.remote_path, repr(e)))
try:
file_local = open(local_fn, 'rb')
except IOError as e:
- raise api_exceptions.FileTransferException( \
+ raise cis_exceptions.FileTransferException( \
"Could not open local file '%s' for reading: %s" \
% (local_fn, repr(e)))
self.ftp.storbinary('STOR %s' % crt_fn, file_local)
file_local.close()
except ftplib.error_perm as e:
- raise api_exceptions.FileTransferException( \
+ raise cis_exceptions.FileTransferException( \
"Could not put file '%s' to Web Server: %s" \
% (local_fn, repr(e)))