[IMP] Improved warning messages for document module

bzr revid: pso@tinyerp.com-20120725103334-rx24b2aojluvxuap
This commit is contained in:
Saurang Suthar(OpenERP) 2012-07-25 16:03:34 +05:30 committed by pso (OpenERP)
parent c8b2503d05
commit d3f30baa81
9 changed files with 98 additions and 98 deletions

View File

@ -96,10 +96,10 @@ class indexer(object):
raise NhException('No appropriate method to index file !')
def _doIndexContent(self,content):
raise NhException("Content not handled here!")
raise NhException("Content cannot be handled here!")
def _doIndexFile(self,fpath):
raise NhException("Content not handled here!")
raise NhException("Content cannot be handled here!")
def __repr__(self):
return "<indexer %s.%s>" %(self.__module__, self.__class__.__name__)
@ -132,7 +132,7 @@ class contentIndex(object):
f = True
if f:
_logger.debug('Register content indexer: %r', obj)
_logger.debug('Register content indexer: %r.', obj)
if not f:
raise Exception("Your indexer should at least support a mimetype or extension.")
@ -169,22 +169,22 @@ class contentIndex(object):
(result, _) = pop.communicate()
mime2 = result.split(';')[0]
_logger.debug('File gave us: %s', mime2)
_logger.debug('File gives us: %s', mime2)
# Note that the temporary file still exists now.
mime,fobj = mime_match(mime2, self.mimes)
if not mime:
mime = mime2
except Exception:
_logger.exception('Cannot determine mime type')
_logger.exception('Cannot determine mime type.')
try:
if fobj:
res = (mime, fobj.indexContent(content,filename,fname or realfname) )
else:
_logger.debug("Have no object, return (%s, None)", mime)
_logger.debug("Have no object, return (%s, None).", mime)
res = (mime, None )
except Exception:
_logger.exception("Could not index file %s (%s)",
_logger.exception("Cannot index file %s (%s).",
filename, fname or realfname)
res = None
@ -193,7 +193,7 @@ class contentIndex(object):
try:
os.unlink(fname)
except Exception:
_logger.exception("Could not unlink %s", fname)
_logger.exception("Cannot unlink %s.", fname)
return res
cntIndex = contentIndex()

View File

@ -339,7 +339,7 @@ class document_file(osv.osv):
if r:
unres.append(r)
else:
self.loggerdoc.warning("Unlinking attachment #%s %s that has no storage",
self.loggerdoc.warning("Unlinking attachment #%s %s that has no storage.",
f.id, f.name)
res = super(document_file, self).unlink(cr, uid, ids, context)
stor.do_unlink(cr, uid, unres)

View File

@ -108,7 +108,7 @@ class document_directory(osv.osv):
_sql_constraints = [
('dirname_uniq', 'unique (name,parent_id,ressource_id,ressource_parent_type_id)', 'The directory name must be unique !'),
('no_selfparent', 'check(parent_id <> id)', 'Directory cannot be parent of itself!'),
('dir_parented', 'check(parent_id IS NOT NULL OR storage_id IS NOT NULL)', 'Directory must have a parent or a storage')
('dir_parented', 'check(parent_id IS NOT NULL OR storage_id IS NOT NULL)', 'Directory must have a parent or a storage.')
]
def name_get(self, cr, uid, ids, context=None):
res = []
@ -193,7 +193,7 @@ class document_directory(osv.osv):
elif dbro.type == 'ressource':
return nodes.node_res_dir
else:
raise ValueError("dir node for %s type", dbro.type)
raise ValueError("dir node for %s type!", dbro.type)
def _prepare_context(self, cr, uid, nctx, context=None):
""" Fill nctx with properties for this database

View File

@ -188,7 +188,7 @@ class nodefd_db(StringIO, nodes.node_descriptor):
elif mode == 'a':
StringIO.__init__(self, None)
else:
_logger.error("Incorrect mode %s specified", mode)
_logger.error("Incorrect mode %s is specified.", mode)
raise IOError(errno.EINVAL, "Invalid file mode!")
self.mode = mode
@ -238,7 +238,7 @@ class nodefd_db(StringIO, nodes.node_descriptor):
(out, len(data), par.file_id))
cr.commit()
except Exception:
_logger.exception('Cannot update db file #%d for close:', par.file_id)
_logger.exception('Cannot update db file #%d for close.', par.file_id)
raise
finally:
cr.close()
@ -268,7 +268,7 @@ class nodefd_db64(StringIO, nodes.node_descriptor):
elif mode == 'a':
StringIO.__init__(self, None)
else:
_logger.error("Incorrect mode %s specified", mode)
_logger.error("Incorrect mode %s is specified.", mode)
raise IOError(errno.EINVAL, "Invalid file mode!")
self.mode = mode
@ -420,7 +420,7 @@ class document_storage(osv.osv):
"""
boo = self.browse(cr, uid, id, context=context)
if not boo.online:
raise IOError(errno.EREMOTE, 'medium offline!')
raise IOError(errno.EREMOTE, 'Medium offline!')
if fil_obj:
ira = fil_obj
@ -470,7 +470,7 @@ class document_storage(osv.osv):
do_create = (mode[0] in ('w','a')) )
fpath = os.path.join(path, npath[-1])
if (not os.path.exists(fpath)) and mode[0] == 'r':
raise IOError("File not found: %s" % fpath)
raise IOError("File not found: %s." % fpath)
elif mode[0] in ('w', 'a') and not ira.store_fname:
store_fname = os.path.join(*npath)
cr.execute('UPDATE ir_attachment SET store_fname = %s WHERE id = %s',
@ -521,7 +521,7 @@ class document_storage(osv.osv):
elif not ira.store_fname:
return None
else:
raise IOError(errno.ENOENT, "File not found: %s" % fpath)
raise IOError(errno.ENOENT, "File not found: %s." % fpath)
elif boo.type == 'virtual':
raise ValueError('Virtual storage does not support static file(s).')
@ -546,7 +546,7 @@ class document_storage(osv.osv):
if boo.readonly:
raise IOError(errno.EPERM, "Readonly medium!")
_logger.debug( "Store data for ir.attachment #%d" % ira.id)
_logger.debug( "Store data for ir.attachment #%d." % ira.id)
store_fname = None
fname = None
if boo.type == 'filestore':
@ -559,7 +559,7 @@ class document_storage(osv.osv):
fp.write(data)
finally:
fp.close()
_logger.debug( "Saved data to %s" % fname)
_logger.debug( "Saved data to %s." % fname)
filesize = len(data) # os.stat(fname).st_size
# TODO Here, an old file would be left hanging.
@ -588,12 +588,12 @@ class document_storage(osv.osv):
fp.write(data)
finally:
fp.close()
_logger.debug("Saved data to %s", fname)
_logger.debug("Saved data to %s.", fname)
filesize = len(data) # os.stat(fname).st_size
store_fname = os.path.join(*npath)
# TODO Here, an old file would be left hanging.
except Exception,e :
_logger.warning("Cannot save data:", exc_info=True)
_logger.warning("Cannot save data.", exc_info=True)
raise except_orm(_('Error!'), str(e))
elif boo.type == 'virtual':
@ -612,7 +612,7 @@ class document_storage(osv.osv):
mime, icont = cntIndex.doIndex(data, ira.datas_fname,
ira.file_type or None, fname)
except Exception:
_logger.debug('Cannot index file:', exc_info=True)
_logger.debug('Cannot index file.', exc_info=True)
pass
try:
@ -629,7 +629,7 @@ class document_storage(osv.osv):
file_node.content_type = mime
return True
except Exception, e :
self._logger.warning("Cannot save data:", exc_info=True)
self._logger.warning("Cannot save data.", exc_info=True)
# should we really rollback once we have written the actual data?
# at the db case (only), that rollback would be safe
raise except_orm(_('Error at doc write!'), str(e))
@ -667,7 +667,7 @@ class document_storage(osv.osv):
try:
os.unlink(fname)
except Exception:
_logger.warning("Cannot remove file %s, please remove manually.", fname, exc_info=True)
_logger.warning("Cannot remove file %s, please remove it manually.", fname, exc_info=True)
else:
_logger.warning("Unlink unknown key %s." % ktype)
@ -684,10 +684,10 @@ class document_storage(osv.osv):
assert sbro, "The file #%d didn't provide storage" % file_node.file_id
if not sbro.online:
raise IOError(errno.EREMOTE, 'medium offline')
raise IOError(errno.EREMOTE, 'Medium offline!')
if sbro.readonly:
raise IOError(errno.EPERM, "Readonly medium")
raise IOError(errno.EPERM, "Readonly medium!")
if sbro.type in ('filestore', 'db', 'db64'):
# nothing to do for a rename, allow to change the db field
@ -726,10 +726,10 @@ class document_storage(osv.osv):
assert sbro, "The file #%d didn't provide storage" % file_node.file_id
if not sbro.online:
raise IOError(errno.EREMOTE, 'medium offline')
raise IOError(errno.EREMOTE, 'Medium offline!')
if sbro.readonly:
raise IOError(errno.EPERM, "Readonly medium")
raise IOError(errno.EPERM, "Readonly medium!")
par = ndir_bro
psto = None

View File

@ -923,7 +923,7 @@ msgstr ""
#. module: document
#: sql_constraint:document.directory:0
msgid "Directory must have a parent or a storage"
msgid "Directory must have a parent or a storage."
msgstr ""
#. module: document

View File

@ -543,7 +543,7 @@ class node_dir(node_database):
try:
self.dctx['dctx_' + dfld.field] = safe_eval(dfld.expr,dc2)
except Exception,e:
print "Cannot eval %s" % dfld.expr
print "Cannot eval %s." % dfld.expr
print e
pass
@ -640,7 +640,7 @@ class node_dir(node_database):
raise OSError(39, 'Directory not empty.')
res = self.context._dirobj.unlink(cr, uid, [directory.id])
else:
raise OSError(1, 'Operation not permited.')
raise OSError(1, 'Operation is not permited.')
return res
def create_child_collection(self, cr, objname):
@ -654,7 +654,7 @@ class node_dir(node_database):
ctx.update(self.dctx)
obj = dirobj.browse(cr, uid, self.dir_id)
if obj and (obj.type == 'ressource') and not object2:
raise OSError(1, 'Operation not permited.')
raise OSError(1, 'Operation is not permited.')
#objname = uri2[-1]
val = {
@ -724,7 +724,7 @@ class node_dir(node_database):
assert self.parent
if self.parent != ndir_node:
_logger.debug('Cannot move dir %r from %r to %r', self, self.parent, ndir_node)
_logger.debug('Cannot move dir %r from %r to %r.', self, self.parent, ndir_node)
raise NotImplementedError('Cannot move dir to another dir.')
ret = {}
@ -832,7 +832,7 @@ class node_res_dir(node_class):
elif isinstance(app, tuple):
where.append(app)
else:
raise RuntimeError("incorrect domain expr: %s" % self.domain)
raise RuntimeError("Incorrect domain expr: %s." % self.domain)
if self.resm_id:
where.append(('id','=',self.resm_id))
@ -923,7 +923,7 @@ class node_res_obj(node_class):
try:
self.dctx[fld] = safe_eval(expr, dc2)
except Exception,e:
print "Cannot eval %s for %s" % (expr, fld)
print "Cannot eval %s for %s." % (expr, fld)
print e
pass
else:
@ -997,7 +997,7 @@ class node_res_obj(node_class):
def get_dav_eprop_DEPR(self, cr, ns, prop):
# Deprecated!
if ns != 'http://groupdav.org/' or prop != 'resourcetype':
_logger.warning("Who asked for %s:%s?" % (ns, prop))
_logger.warning("Who asks for %s:%s?" % (ns, prop))
return None
cntobj = self.context._dirobj.pool.get('document.directory.content')
uid = self.context.uid
@ -1114,7 +1114,7 @@ class node_res_obj(node_class):
obj = dirobj.browse(cr, uid, self.dir_id)
if obj and (obj.type == 'ressource') and not object2:
raise OSError(1, 'Operation not permited.')
raise OSError(1, 'Operation is not permited.')
val = {
@ -1213,7 +1213,7 @@ class node_file(node_class):
def open_data(self, cr, mode):
stor = self.storage_id
assert stor, "No storage for file #%s" % self.file_id
assert stor, "No storage for file #%s." % self.file_id
if not self.check_perms(4):
raise IOError(errno.EPERM, "Permission denied.")
@ -1314,10 +1314,10 @@ class node_file(node_class):
dbro = doc_obj.browse(cr, self.context.uid, self.file_id, context=self.context.context)
else:
dbro = fil_obj
assert dbro.id == self.file_id, "%s != %s for %r" % (dbro.id, self.file_id, self)
assert dbro.id == self.file_id, "%s != %s for %r." % (dbro.id, self.file_id, self)
if not dbro:
raise IndexError("Cannot locate doc %d", self.file_id)
raise IndexError("Cannot locate doc %d.", self.file_id)
if (not self.parent):
# there *must* be a parent node for this one
@ -1327,8 +1327,8 @@ class node_file(node_class):
ret = {}
if ndir_node and self.parent != ndir_node:
if not (isinstance(self.parent, node_dir) and isinstance(ndir_node, node_dir)):
_logger.debug('Cannot move file %r from %r to %r', self, self.parent, ndir_node)
raise NotImplementedError('Cannot move files between dynamic folders')
_logger.debug('Cannot move file %r from %r to %r.', self, self.parent, ndir_node)
raise NotImplementedError('Cannot move files between dynamic folders.')
if not ndir_obj:
ndir_obj = self.context._dirobj.browse(cr, self.context.uid, \
@ -1416,7 +1416,7 @@ class node_content(node_class):
elif mode in ('r+', 'w+'):
cperms = 'rw'
else:
raise IOError(errno.EINVAL, "Cannot open at mode %s" % mode)
raise IOError(errno.EINVAL, "Cannot open at mode %s." % mode)
if not self.check_perms(cperms):
raise IOError(errno.EPERM, "Permission denied.")
@ -1473,7 +1473,7 @@ class nodefd_content(StringIO, node_descriptor):
elif mode == 'a':
StringIO.__init__(self, None)
else:
_logger.error("Incorrect mode %s specified", mode)
_logger.error("Incorrect mode %s is specified.", mode)
raise IOError(errno.EINVAL, "Invalid file mode!")
self.mode = mode
@ -1499,7 +1499,7 @@ class nodefd_content(StringIO, node_descriptor):
raise NotImplementedError
cr.commit()
except Exception:
_logger.exception('Cannot update db content #%d for close:', par.cnt_id)
_logger.exception('Cannot update db content #%d for close.', par.cnt_id)
raise
finally:
cr.close()
@ -1527,7 +1527,7 @@ class nodefd_static(StringIO, node_descriptor):
elif mode == 'a':
StringIO.__init__(self, None)
else:
_logger.error("Incorrect mode %s specified", mode)
_logger.error("Incorrect mode %s is specified.", mode)
raise IOError(errno.EINVAL, "Invalid file mode!")
self.mode = mode
@ -1552,7 +1552,7 @@ class nodefd_static(StringIO, node_descriptor):
raise NotImplementedError
cr.commit()
except Exception:
_logger.exception('Cannot update db content #%d for close:', par.cnt_id)
_logger.exception('Cannot update db content #%d for close.', par.cnt_id)
raise
finally:
cr.close()

View File

@ -104,7 +104,7 @@ class DocIndex(indexer):
except OSError:
_logger.warn("Failed attempt to execute antiword (MS Word reader). Antiword is necessary to index the file %s of MIME type %s. Detailed error available at DEBUG level.", fname, self._getMimeTypes()[0])
_logger.debug("Trace of the failed file indexing attempt: ", exc_info=True)
_logger.debug("Trace of the failed file indexing attempt.", exc_info=True)
return False
cntIndex.register(DocIndex())

View File

@ -81,7 +81,7 @@ class abstracted_fs(object):
self.db_name_list.append(db_name)
cr.commit()
except Exception:
self._log.warning('Cannot use db "%s"', db_name)
self._log.warning('Cannot use db "%s".', db_name)
finally:
if cr is not None:
cr.close()
@ -143,33 +143,33 @@ class abstracted_fs(object):
child = node.child(cr, objname)
if child:
if child.type not in ('file','content'):
raise OSError(1, 'Operation not permited.')
raise OSError(1, 'Operation is not permitted.')
ret = child.open_data(cr, mode)
cr.commit()
assert ret, "Cannot create descriptor for %r: %r" % (child, ret)
assert ret, "Cannot create descriptor for %r: %r." % (child, ret)
return ret
except EnvironmentError:
raise
except Exception:
self._log.exception('Cannot locate item %s at node %s', objname, repr(node))
self._log.exception('Cannot locate item %s at node %s.', objname, repr(node))
pass
try:
child = node.create_child(cr, objname, data=None)
ret = child.open_data(cr, mode)
assert ret, "cannot create descriptor for %r" % child
assert ret, "Cannot create descriptor for %r." % child
cr.commit()
return ret
except EnvironmentError:
raise
except Exception:
self._log.exception('Cannot create item %s at node %s', objname, repr(node))
raise OSError(1, 'Operation not permited.')
self._log.exception('Cannot create item %s at node %s.', objname, repr(node))
raise OSError(1, 'Operation is not permitted.')
def open(self, datacr, mode):
if not (datacr and datacr[1]):
raise OSError(1, 'Operation not permited.')
raise OSError(1, 'Operation is not permitted.')
# Reading operation
cr, node, rem = datacr
try:
@ -211,7 +211,7 @@ class abstracted_fs(object):
self.cwd_node = None
return None
if not datacr[1]:
raise OSError(1, 'Operation not permitted.')
raise OSError(1, 'Operation is not permitted.')
if datacr[1].type not in ('collection','database'):
raise OSError(2, 'Path is not a directory.')
self.cwd = '/'+datacr[1].context.dbname + '/'
@ -223,7 +223,7 @@ class abstracted_fs(object):
"""Create the specified directory."""
cr, node, rem = datacr or (None, None, None)
if not node:
raise OSError(1, 'Operation not permited.')
raise OSError(1, 'Operation is not permitted.')
try:
basename =_to_unicode(basename)
@ -231,8 +231,8 @@ class abstracted_fs(object):
self._log.debug("Created child dir: %r", cdir)
cr.commit()
except Exception:
self._log.exception('Cannot create dir "%s" at node %s', basename, repr(node))
raise OSError(1, 'Operation not permited.')
self._log.exception('Cannot create dir "%s" at node %s.', basename, repr(node))
raise OSError(1, 'Operation is not permitted.')
def close_cr(self, data):
if data and data[0]:
@ -290,7 +290,7 @@ class abstracted_fs(object):
raise IOError(errno.EPERM, 'Cannot perform operation at root directory.')
dbname = p_parts[0]
if dbname not in self.db_list():
raise IOError(errno.ENOENT,'Invalid database path: %s' % dbname)
raise IOError(errno.ENOENT,'Invalid database path: %s.' % dbname)
try:
db = pooler.get_db(dbname)
except Exception:
@ -303,7 +303,7 @@ class abstracted_fs(object):
raise
if not uid:
cr.close()
raise OSError(2, 'Authentification Required.')
raise OSError(2, 'Authentification is Required!')
n = get_node_context(cr, uid, {})
node = n.get_uri(cr, p_parts[1:])
return (cr, node, rem_path)
@ -375,7 +375,7 @@ class abstracted_fs(object):
return self.rmdir(datacr)
elif datacr[1].type == 'file':
return self.rmfile(datacr)
raise OSError(1, 'Operation not permited.')
raise OSError(1, 'Operation is not permitted.')
def rmfile(self, datacr):
"""Remove the specified file."""
@ -399,8 +399,8 @@ class abstracted_fs(object):
except EnvironmentError:
raise
except Exception:
self._log.exception('Cannot rename "%s" to "%s" at "%s"', src, datacr[2], datacr[1])
raise OSError(1,'Operation not permited.')
self._log.exception('Cannot rename "%s" to "%s" at "%s".', src, datacr[2], datacr[1])
raise OSError(1,'Operation is not permitted.')
def stat(self, node):
raise NotImplementedError()

View File

@ -302,16 +302,16 @@ class DummyAuthorizer:
provide customized response strings when user log-in and quit.
"""
if self.has_user(username):
raise AuthorizerError('User "%s" already exists' %username)
raise AuthorizerError('User "%s" already exists!' %username)
homedir = os.path.realpath(homedir)
if not os.path.isdir(homedir):
raise AuthorizerError('No such directory: "%s"' %homedir)
raise AuthorizerError('No such directory: "%s"!' %homedir)
for p in perm:
if p not in 'elradfmw':
raise AuthorizerError('No such permission: "%s"' %p)
raise AuthorizerError('No such permission: "%s"!' %p)
for p in perm:
if (p in self.write_perms) and (username == 'anonymous'):
warnings.warn("write permissions assigned to anonymous user.",
warnings.warn("Write permissions are assigned to anonymous user.",
RuntimeWarning)
break
dic = {'pwd': str(password),
@ -532,7 +532,7 @@ class ActiveDTP(asyncore.dispatcher):
try:
self.connect((ip, port))
except socket.gaierror:
self.cmd_channel.respond("425 Can't connect to specified address.")
self.cmd_channel.respond("425 Cannot connect to specified address.")
self.close()
# --- connection / overridden
@ -542,14 +542,14 @@ class ActiveDTP(asyncore.dispatcher):
def handle_connect(self):
"""Called when connection is established."""
self.cmd_channel.respond('200 Active data connection established.')
self.cmd_channel.respond('200 Active data connection has been established.')
# delegate such connection to DTP handler
handler = self.cmd_channel.dtp_handler(self.socket, self.cmd_channel)
self.cmd_channel.data_channel = handler
self.cmd_channel.on_dtp_connection()
def handle_expt(self):
self.cmd_channel.respond("425 Can't connect to specified address.")
self.cmd_channel.respond("425 Cannot connect to specified address.")
self.close()
def handle_error(self):
@ -562,7 +562,7 @@ class ActiveDTP(asyncore.dispatcher):
pass
except:
logerror(traceback.format_exc())
self.cmd_channel.respond("425 Can't connect to specified address.")
self.cmd_channel.respond("425 Cannot connect to specified address.")
self.close()
class DTPHandler(asyncore.dispatcher):
@ -767,7 +767,7 @@ class DTPHandler(asyncore.dispatcher):
# some other exception occurred; we don't want to provide
# confidential error messages
logerror(traceback.format_exc())
error = "Internal error"
error = "Internal error!"
self.cmd_channel.respond("426 %s; transfer aborted." %error)
self.close()
@ -1485,7 +1485,7 @@ class FTPHandler(asynchat.async_chat):
buflimit = 2048
if self.in_buffer_len > buflimit:
self.respond('500 Command too long.')
self.log('Command received exceeded buffer limit of %s.' %(buflimit))
self.log('Command has been received exceeds buffer limit of %s.' %(buflimit))
self.in_buffer = []
self.in_buffer_len = 0
@ -1528,12 +1528,12 @@ class FTPHandler(asynchat.async_chat):
# let's check if user provided an argument for those commands
# needing one
if not arg and cmd in self.arg_cmds:
self.respond("501 Syntax error: command needs an argument.")
self.respond("501 Syntax error! Command needs an argument.")
return
# let's do the same for those commands requiring no argument.
elif arg and cmd in self.unarg_cmds:
self.respond("501 Syntax error: command does not accept arguments.")
self.respond("501 Syntax error! Command does not accept arguments.")
return
# provide a limited set of commands if user isn't
@ -1617,7 +1617,7 @@ class FTPHandler(asynchat.async_chat):
else:
self.in_buffer.append(data)
return
self.log("Can't handle OOB data.")
self.log("Cannot handle OOB data.")
self.close()
def handle_error(self):
@ -1801,7 +1801,7 @@ class FTPHandler(asynchat.async_chat):
except NotImplementedError, err:
cmdname = function.__name__
why = err.args[0] or 'Not implemented'
self.log('FAIL %s() not implemented: %s.' %(cmdname, why))
self.log('FAIL %s() is not implemented: %s.' %(cmdname, why))
self.respond('502 %s.' %why)
raise FTPExceptionSent(why)
except EnvironmentError, err:
@ -1811,7 +1811,7 @@ class FTPHandler(asynchat.async_chat):
except Exception:
pass
ret_code = eresp.get(err.errno, '451')
why = (err.strerror) or 'Error in command'
why = (err.strerror) or 'Error in command.'
self.log('FAIL %s() %s errno=%s: %s.' %(cmdname, uline, err.errno, why))
self.respond('%s %s.' % (str(ret_code), why))
@ -1841,15 +1841,15 @@ class FTPHandler(asynchat.async_chat):
if ip != self.remote_ip:
self.log("Rejected data connection to foreign address %s:%s."
%(ip, port))
self.respond("501 Can't connect to a foreign address.")
self.respond("501 Cannot connect to a foreign address.")
return
# ...another RFC-2577 recommendation is rejecting connections
# to privileged ports (< 1024) for security reasons.
if not self.permit_privileged_ports:
if port < 1024:
self.log('PORT against the privileged port "%s" refused.' %port)
self.respond("501 Can't connect over a privileged port.")
self.log('PORT against the privileged port "%s" has been refused.' %port)
self.respond("501 Cannot connect over a privileged port.")
return
# close existent DTP-server instance, if any.
@ -1889,7 +1889,7 @@ class FTPHandler(asynchat.async_chat):
# make sure we are not hitting the max connections limit
if self.server.max_cons:
if len(self._map) >= self.server.max_cons:
msg = "Too many connections. Can't open data channel."
msg = "Too many connections. Cannot open data channel."
self.respond("425 %s" %msg)
self.log(msg)
return
@ -2150,7 +2150,7 @@ class FTPHandler(asynchat.async_chat):
datacr = self.get_crdata2(line, mode='list')
# RFC-3659 requires 501 response code if path is not a directory
if not self.fs.isdir(datacr[1]):
err = 'No such directory'
err = 'No such directory!'
self.log('FAIL MLSD "%s". %s.' %(line, err))
self.respond("501 %s." %err)
return
@ -2191,7 +2191,7 @@ class FTPHandler(asynchat.async_chat):
fd.seek(self.restart_position)
ok = 1
except AssertionError:
why = "Invalid REST parameter"
why = "Invalid REST parameter!"
except IOError, err:
why = _strerror(err)
self.restart_position = 0
@ -2240,7 +2240,7 @@ class FTPHandler(asynchat.async_chat):
fd.seek(self.restart_position)
ok = 1
except AssertionError:
why = "Invalid REST parameter"
why = "Invalid REST parameter!"
except IOError, err:
why = _strerror(err)
self.restart_position = 0
@ -2275,7 +2275,7 @@ class FTPHandler(asynchat.async_chat):
# watch for STOU preceded by REST, which makes no sense.
if self.restart_position:
self.respond("450 Can't STOU while REST request is pending.")
self.respond("450 Cannot STOU while REST request is pending.")
return
@ -2296,7 +2296,7 @@ class FTPHandler(asynchat.async_chat):
# hitted the max number of tries to find out file with
# unique name
if err.errno == errno.EEXIST:
why = 'No usable unique file name found'
why = 'No usable unique file name found.'
# something else happened
else:
why = _strerror(err)
@ -2307,9 +2307,9 @@ class FTPHandler(asynchat.async_chat):
filename = line
if not self.authorizer.has_perm(self.username, 'w', filename):
self.log('FAIL STOU "%s". Not enough privileges'
self.log('FAIL STOU "%s". Not enough privileges.'
%self.fs.ftpnorm(line))
self.respond("550 Can't STOU: not enough privileges.")
self.respond("550 Cannot STOU: not enough privileges.")
self.fs.close_cr(datacr)
return
@ -2329,7 +2329,7 @@ class FTPHandler(asynchat.async_chat):
"""Append data to an existing file on the server."""
# watch for APPE preceded by REST, which makes no sense.
if self.restart_position:
self.respond("550 Can't APPE while REST request is pending.")
self.respond("550 Cannot APPE while REST request is pending.")
else:
self.ftp_STOR(line, mode='a')
@ -2405,7 +2405,7 @@ class FTPHandler(asynchat.async_chat):
# and account information already supplied and beginning the
# login sequence again.
self.flush_account()
msg = 'Previous account information was flushed'
msg = 'Previous account information is flushed.'
self.log('OK USER "%s". %s.' %(line, msg))
self.respond('331 %s, send password.' %msg)
self.username = line
@ -2584,7 +2584,7 @@ class FTPHandler(asynchat.async_chat):
try:
datacr = self.get_crdata2(line, mode='delete')
if not datacr[1]:
msg = "Can't remove root directory."
msg = "Cannot remove root directory."
self.respond("553 %s" %msg)
self.log('FAIL MKD "/". %s' %msg)
self.fs.close_cr(datacr)
@ -2617,7 +2617,7 @@ class FTPHandler(asynchat.async_chat):
if not datacr[1]:
self.respond("550 No such file or directory.")
elif not datacr[1]:
self.respond("553 Can't rename the home directory.")
self.respond("553 Cannot rename the home directory.")
else:
self.fs.rnfr = datacr[1]
self.respond("350 Ready for destination name.")
@ -2760,14 +2760,14 @@ class FTPHandler(asynchat.async_chat):
def ftp_OPTS(self, line):
"""Specify options for FTP commands as specified in RFC-2389."""
try:
assert (not line.count(' ') > 1), 'Invalid number of arguments'
assert (not line.count(' ') > 1), 'Invalid number of arguments!'
if ' ' in line:
cmd, arg = line.split(' ')
assert (';' in arg), 'Invalid argument'
assert (';' in arg), 'Invalid argument!'
else:
cmd, arg = line, ''
# actually the only command able to accept options is MLST
assert (cmd.upper() == 'MLST'), 'Unsupported command "%s"' %cmd
assert (cmd.upper() == 'MLST'), 'Unsupported command "%s".' %cmd
except AssertionError, err:
self.respond('501 %s.' %err)
else: