[IMP] Improved warning messages for document module
bzr revid: pso@tinyerp.com-20120725103334-rx24b2aojluvxuap
This commit is contained in:
parent
c8b2503d05
commit
d3f30baa81
|
@ -96,10 +96,10 @@ class indexer(object):
|
||||||
raise NhException('No appropriate method to index file !')
|
raise NhException('No appropriate method to index file !')
|
||||||
|
|
||||||
def _doIndexContent(self,content):
|
def _doIndexContent(self,content):
|
||||||
raise NhException("Content not handled here!")
|
raise NhException("Content cannot be handled here!")
|
||||||
|
|
||||||
def _doIndexFile(self,fpath):
|
def _doIndexFile(self,fpath):
|
||||||
raise NhException("Content not handled here!")
|
raise NhException("Content cannot be handled here!")
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return "<indexer %s.%s>" %(self.__module__, self.__class__.__name__)
|
return "<indexer %s.%s>" %(self.__module__, self.__class__.__name__)
|
||||||
|
@ -132,7 +132,7 @@ class contentIndex(object):
|
||||||
f = True
|
f = True
|
||||||
|
|
||||||
if f:
|
if f:
|
||||||
_logger.debug('Register content indexer: %r', obj)
|
_logger.debug('Register content indexer: %r.', obj)
|
||||||
if not f:
|
if not f:
|
||||||
raise Exception("Your indexer should at least support a mimetype or extension.")
|
raise Exception("Your indexer should at least support a mimetype or extension.")
|
||||||
|
|
||||||
|
@ -169,22 +169,22 @@ class contentIndex(object):
|
||||||
(result, _) = pop.communicate()
|
(result, _) = pop.communicate()
|
||||||
|
|
||||||
mime2 = result.split(';')[0]
|
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.
|
# Note that the temporary file still exists now.
|
||||||
mime,fobj = mime_match(mime2, self.mimes)
|
mime,fobj = mime_match(mime2, self.mimes)
|
||||||
if not mime:
|
if not mime:
|
||||||
mime = mime2
|
mime = mime2
|
||||||
except Exception:
|
except Exception:
|
||||||
_logger.exception('Cannot determine mime type')
|
_logger.exception('Cannot determine mime type.')
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if fobj:
|
if fobj:
|
||||||
res = (mime, fobj.indexContent(content,filename,fname or realfname) )
|
res = (mime, fobj.indexContent(content,filename,fname or realfname) )
|
||||||
else:
|
else:
|
||||||
_logger.debug("Have no object, return (%s, None)", mime)
|
_logger.debug("Have no object, return (%s, None).", mime)
|
||||||
res = (mime, None )
|
res = (mime, None )
|
||||||
except Exception:
|
except Exception:
|
||||||
_logger.exception("Could not index file %s (%s)",
|
_logger.exception("Cannot index file %s (%s).",
|
||||||
filename, fname or realfname)
|
filename, fname or realfname)
|
||||||
res = None
|
res = None
|
||||||
|
|
||||||
|
@ -193,7 +193,7 @@ class contentIndex(object):
|
||||||
try:
|
try:
|
||||||
os.unlink(fname)
|
os.unlink(fname)
|
||||||
except Exception:
|
except Exception:
|
||||||
_logger.exception("Could not unlink %s", fname)
|
_logger.exception("Cannot unlink %s.", fname)
|
||||||
return res
|
return res
|
||||||
|
|
||||||
cntIndex = contentIndex()
|
cntIndex = contentIndex()
|
||||||
|
|
|
@ -339,7 +339,7 @@ class document_file(osv.osv):
|
||||||
if r:
|
if r:
|
||||||
unres.append(r)
|
unres.append(r)
|
||||||
else:
|
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)
|
f.id, f.name)
|
||||||
res = super(document_file, self).unlink(cr, uid, ids, context)
|
res = super(document_file, self).unlink(cr, uid, ids, context)
|
||||||
stor.do_unlink(cr, uid, unres)
|
stor.do_unlink(cr, uid, unres)
|
||||||
|
|
|
@ -108,7 +108,7 @@ class document_directory(osv.osv):
|
||||||
_sql_constraints = [
|
_sql_constraints = [
|
||||||
('dirname_uniq', 'unique (name,parent_id,ressource_id,ressource_parent_type_id)', 'The directory name must be unique !'),
|
('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!'),
|
('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):
|
def name_get(self, cr, uid, ids, context=None):
|
||||||
res = []
|
res = []
|
||||||
|
@ -193,7 +193,7 @@ class document_directory(osv.osv):
|
||||||
elif dbro.type == 'ressource':
|
elif dbro.type == 'ressource':
|
||||||
return nodes.node_res_dir
|
return nodes.node_res_dir
|
||||||
else:
|
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):
|
def _prepare_context(self, cr, uid, nctx, context=None):
|
||||||
""" Fill nctx with properties for this database
|
""" Fill nctx with properties for this database
|
||||||
|
|
|
@ -188,7 +188,7 @@ class nodefd_db(StringIO, nodes.node_descriptor):
|
||||||
elif mode == 'a':
|
elif mode == 'a':
|
||||||
StringIO.__init__(self, None)
|
StringIO.__init__(self, None)
|
||||||
else:
|
else:
|
||||||
_logger.error("Incorrect mode %s specified", mode)
|
_logger.error("Incorrect mode %s is specified.", mode)
|
||||||
raise IOError(errno.EINVAL, "Invalid file mode!")
|
raise IOError(errno.EINVAL, "Invalid file mode!")
|
||||||
self.mode = mode
|
self.mode = mode
|
||||||
|
|
||||||
|
@ -238,7 +238,7 @@ class nodefd_db(StringIO, nodes.node_descriptor):
|
||||||
(out, len(data), par.file_id))
|
(out, len(data), par.file_id))
|
||||||
cr.commit()
|
cr.commit()
|
||||||
except Exception:
|
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
|
raise
|
||||||
finally:
|
finally:
|
||||||
cr.close()
|
cr.close()
|
||||||
|
@ -268,7 +268,7 @@ class nodefd_db64(StringIO, nodes.node_descriptor):
|
||||||
elif mode == 'a':
|
elif mode == 'a':
|
||||||
StringIO.__init__(self, None)
|
StringIO.__init__(self, None)
|
||||||
else:
|
else:
|
||||||
_logger.error("Incorrect mode %s specified", mode)
|
_logger.error("Incorrect mode %s is specified.", mode)
|
||||||
raise IOError(errno.EINVAL, "Invalid file mode!")
|
raise IOError(errno.EINVAL, "Invalid file mode!")
|
||||||
self.mode = mode
|
self.mode = mode
|
||||||
|
|
||||||
|
@ -420,7 +420,7 @@ class document_storage(osv.osv):
|
||||||
"""
|
"""
|
||||||
boo = self.browse(cr, uid, id, context=context)
|
boo = self.browse(cr, uid, id, context=context)
|
||||||
if not boo.online:
|
if not boo.online:
|
||||||
raise IOError(errno.EREMOTE, 'medium offline!')
|
raise IOError(errno.EREMOTE, 'Medium offline!')
|
||||||
|
|
||||||
if fil_obj:
|
if fil_obj:
|
||||||
ira = fil_obj
|
ira = fil_obj
|
||||||
|
@ -470,7 +470,7 @@ class document_storage(osv.osv):
|
||||||
do_create = (mode[0] in ('w','a')) )
|
do_create = (mode[0] in ('w','a')) )
|
||||||
fpath = os.path.join(path, npath[-1])
|
fpath = os.path.join(path, npath[-1])
|
||||||
if (not os.path.exists(fpath)) and mode[0] == 'r':
|
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:
|
elif mode[0] in ('w', 'a') and not ira.store_fname:
|
||||||
store_fname = os.path.join(*npath)
|
store_fname = os.path.join(*npath)
|
||||||
cr.execute('UPDATE ir_attachment SET store_fname = %s WHERE id = %s',
|
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:
|
elif not ira.store_fname:
|
||||||
return None
|
return None
|
||||||
else:
|
else:
|
||||||
raise IOError(errno.ENOENT, "File not found: %s" % fpath)
|
raise IOError(errno.ENOENT, "File not found: %s." % fpath)
|
||||||
|
|
||||||
elif boo.type == 'virtual':
|
elif boo.type == 'virtual':
|
||||||
raise ValueError('Virtual storage does not support static file(s).')
|
raise ValueError('Virtual storage does not support static file(s).')
|
||||||
|
@ -546,7 +546,7 @@ class document_storage(osv.osv):
|
||||||
if boo.readonly:
|
if boo.readonly:
|
||||||
raise IOError(errno.EPERM, "Readonly medium!")
|
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
|
store_fname = None
|
||||||
fname = None
|
fname = None
|
||||||
if boo.type == 'filestore':
|
if boo.type == 'filestore':
|
||||||
|
@ -559,7 +559,7 @@ class document_storage(osv.osv):
|
||||||
fp.write(data)
|
fp.write(data)
|
||||||
finally:
|
finally:
|
||||||
fp.close()
|
fp.close()
|
||||||
_logger.debug( "Saved data to %s" % fname)
|
_logger.debug( "Saved data to %s." % fname)
|
||||||
filesize = len(data) # os.stat(fname).st_size
|
filesize = len(data) # os.stat(fname).st_size
|
||||||
|
|
||||||
# TODO Here, an old file would be left hanging.
|
# TODO Here, an old file would be left hanging.
|
||||||
|
@ -588,12 +588,12 @@ class document_storage(osv.osv):
|
||||||
fp.write(data)
|
fp.write(data)
|
||||||
finally:
|
finally:
|
||||||
fp.close()
|
fp.close()
|
||||||
_logger.debug("Saved data to %s", fname)
|
_logger.debug("Saved data to %s.", fname)
|
||||||
filesize = len(data) # os.stat(fname).st_size
|
filesize = len(data) # os.stat(fname).st_size
|
||||||
store_fname = os.path.join(*npath)
|
store_fname = os.path.join(*npath)
|
||||||
# TODO Here, an old file would be left hanging.
|
# TODO Here, an old file would be left hanging.
|
||||||
except Exception,e :
|
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))
|
raise except_orm(_('Error!'), str(e))
|
||||||
|
|
||||||
elif boo.type == 'virtual':
|
elif boo.type == 'virtual':
|
||||||
|
@ -612,7 +612,7 @@ class document_storage(osv.osv):
|
||||||
mime, icont = cntIndex.doIndex(data, ira.datas_fname,
|
mime, icont = cntIndex.doIndex(data, ira.datas_fname,
|
||||||
ira.file_type or None, fname)
|
ira.file_type or None, fname)
|
||||||
except Exception:
|
except Exception:
|
||||||
_logger.debug('Cannot index file:', exc_info=True)
|
_logger.debug('Cannot index file.', exc_info=True)
|
||||||
pass
|
pass
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -629,7 +629,7 @@ class document_storage(osv.osv):
|
||||||
file_node.content_type = mime
|
file_node.content_type = mime
|
||||||
return True
|
return True
|
||||||
except Exception, e :
|
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?
|
# should we really rollback once we have written the actual data?
|
||||||
# at the db case (only), that rollback would be safe
|
# at the db case (only), that rollback would be safe
|
||||||
raise except_orm(_('Error at doc write!'), str(e))
|
raise except_orm(_('Error at doc write!'), str(e))
|
||||||
|
@ -667,7 +667,7 @@ class document_storage(osv.osv):
|
||||||
try:
|
try:
|
||||||
os.unlink(fname)
|
os.unlink(fname)
|
||||||
except Exception:
|
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:
|
else:
|
||||||
_logger.warning("Unlink unknown key %s." % ktype)
|
_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
|
assert sbro, "The file #%d didn't provide storage" % file_node.file_id
|
||||||
|
|
||||||
if not sbro.online:
|
if not sbro.online:
|
||||||
raise IOError(errno.EREMOTE, 'medium offline')
|
raise IOError(errno.EREMOTE, 'Medium offline!')
|
||||||
|
|
||||||
if sbro.readonly:
|
if sbro.readonly:
|
||||||
raise IOError(errno.EPERM, "Readonly medium")
|
raise IOError(errno.EPERM, "Readonly medium!")
|
||||||
|
|
||||||
if sbro.type in ('filestore', 'db', 'db64'):
|
if sbro.type in ('filestore', 'db', 'db64'):
|
||||||
# nothing to do for a rename, allow to change the db field
|
# 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
|
assert sbro, "The file #%d didn't provide storage" % file_node.file_id
|
||||||
|
|
||||||
if not sbro.online:
|
if not sbro.online:
|
||||||
raise IOError(errno.EREMOTE, 'medium offline')
|
raise IOError(errno.EREMOTE, 'Medium offline!')
|
||||||
|
|
||||||
if sbro.readonly:
|
if sbro.readonly:
|
||||||
raise IOError(errno.EPERM, "Readonly medium")
|
raise IOError(errno.EPERM, "Readonly medium!")
|
||||||
|
|
||||||
par = ndir_bro
|
par = ndir_bro
|
||||||
psto = None
|
psto = None
|
||||||
|
|
|
@ -923,7 +923,7 @@ msgstr ""
|
||||||
|
|
||||||
#. module: document
|
#. module: document
|
||||||
#: sql_constraint:document.directory:0
|
#: sql_constraint:document.directory:0
|
||||||
msgid "Directory must have a parent or a storage"
|
msgid "Directory must have a parent or a storage."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#. module: document
|
#. module: document
|
||||||
|
|
|
@ -543,7 +543,7 @@ class node_dir(node_database):
|
||||||
try:
|
try:
|
||||||
self.dctx['dctx_' + dfld.field] = safe_eval(dfld.expr,dc2)
|
self.dctx['dctx_' + dfld.field] = safe_eval(dfld.expr,dc2)
|
||||||
except Exception,e:
|
except Exception,e:
|
||||||
print "Cannot eval %s" % dfld.expr
|
print "Cannot eval %s." % dfld.expr
|
||||||
print e
|
print e
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -640,7 +640,7 @@ class node_dir(node_database):
|
||||||
raise OSError(39, 'Directory not empty.')
|
raise OSError(39, 'Directory not empty.')
|
||||||
res = self.context._dirobj.unlink(cr, uid, [directory.id])
|
res = self.context._dirobj.unlink(cr, uid, [directory.id])
|
||||||
else:
|
else:
|
||||||
raise OSError(1, 'Operation not permited.')
|
raise OSError(1, 'Operation is not permited.')
|
||||||
return res
|
return res
|
||||||
|
|
||||||
def create_child_collection(self, cr, objname):
|
def create_child_collection(self, cr, objname):
|
||||||
|
@ -654,7 +654,7 @@ class node_dir(node_database):
|
||||||
ctx.update(self.dctx)
|
ctx.update(self.dctx)
|
||||||
obj = dirobj.browse(cr, uid, self.dir_id)
|
obj = dirobj.browse(cr, uid, self.dir_id)
|
||||||
if obj and (obj.type == 'ressource') and not object2:
|
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]
|
#objname = uri2[-1]
|
||||||
val = {
|
val = {
|
||||||
|
@ -724,7 +724,7 @@ class node_dir(node_database):
|
||||||
assert self.parent
|
assert self.parent
|
||||||
|
|
||||||
if self.parent != ndir_node:
|
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.')
|
raise NotImplementedError('Cannot move dir to another dir.')
|
||||||
|
|
||||||
ret = {}
|
ret = {}
|
||||||
|
@ -832,7 +832,7 @@ class node_res_dir(node_class):
|
||||||
elif isinstance(app, tuple):
|
elif isinstance(app, tuple):
|
||||||
where.append(app)
|
where.append(app)
|
||||||
else:
|
else:
|
||||||
raise RuntimeError("incorrect domain expr: %s" % self.domain)
|
raise RuntimeError("Incorrect domain expr: %s." % self.domain)
|
||||||
if self.resm_id:
|
if self.resm_id:
|
||||||
where.append(('id','=',self.resm_id))
|
where.append(('id','=',self.resm_id))
|
||||||
|
|
||||||
|
@ -923,7 +923,7 @@ class node_res_obj(node_class):
|
||||||
try:
|
try:
|
||||||
self.dctx[fld] = safe_eval(expr, dc2)
|
self.dctx[fld] = safe_eval(expr, dc2)
|
||||||
except Exception,e:
|
except Exception,e:
|
||||||
print "Cannot eval %s for %s" % (expr, fld)
|
print "Cannot eval %s for %s." % (expr, fld)
|
||||||
print e
|
print e
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
|
@ -997,7 +997,7 @@ class node_res_obj(node_class):
|
||||||
def get_dav_eprop_DEPR(self, cr, ns, prop):
|
def get_dav_eprop_DEPR(self, cr, ns, prop):
|
||||||
# Deprecated!
|
# Deprecated!
|
||||||
if ns != 'http://groupdav.org/' or prop != 'resourcetype':
|
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
|
return None
|
||||||
cntobj = self.context._dirobj.pool.get('document.directory.content')
|
cntobj = self.context._dirobj.pool.get('document.directory.content')
|
||||||
uid = self.context.uid
|
uid = self.context.uid
|
||||||
|
@ -1114,7 +1114,7 @@ class node_res_obj(node_class):
|
||||||
|
|
||||||
obj = dirobj.browse(cr, uid, self.dir_id)
|
obj = dirobj.browse(cr, uid, self.dir_id)
|
||||||
if obj and (obj.type == 'ressource') and not object2:
|
if obj and (obj.type == 'ressource') and not object2:
|
||||||
raise OSError(1, 'Operation not permited.')
|
raise OSError(1, 'Operation is not permited.')
|
||||||
|
|
||||||
|
|
||||||
val = {
|
val = {
|
||||||
|
@ -1213,7 +1213,7 @@ class node_file(node_class):
|
||||||
|
|
||||||
def open_data(self, cr, mode):
|
def open_data(self, cr, mode):
|
||||||
stor = self.storage_id
|
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):
|
if not self.check_perms(4):
|
||||||
raise IOError(errno.EPERM, "Permission denied.")
|
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)
|
dbro = doc_obj.browse(cr, self.context.uid, self.file_id, context=self.context.context)
|
||||||
else:
|
else:
|
||||||
dbro = fil_obj
|
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:
|
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):
|
if (not self.parent):
|
||||||
# there *must* be a parent node for this one
|
# there *must* be a parent node for this one
|
||||||
|
@ -1327,8 +1327,8 @@ class node_file(node_class):
|
||||||
ret = {}
|
ret = {}
|
||||||
if ndir_node and self.parent != ndir_node:
|
if ndir_node and self.parent != ndir_node:
|
||||||
if not (isinstance(self.parent, node_dir) and isinstance(ndir_node, node_dir)):
|
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)
|
_logger.debug('Cannot move file %r from %r to %r.', self, self.parent, ndir_node)
|
||||||
raise NotImplementedError('Cannot move files between dynamic folders')
|
raise NotImplementedError('Cannot move files between dynamic folders.')
|
||||||
|
|
||||||
if not ndir_obj:
|
if not ndir_obj:
|
||||||
ndir_obj = self.context._dirobj.browse(cr, self.context.uid, \
|
ndir_obj = self.context._dirobj.browse(cr, self.context.uid, \
|
||||||
|
@ -1416,7 +1416,7 @@ class node_content(node_class):
|
||||||
elif mode in ('r+', 'w+'):
|
elif mode in ('r+', 'w+'):
|
||||||
cperms = 'rw'
|
cperms = 'rw'
|
||||||
else:
|
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):
|
if not self.check_perms(cperms):
|
||||||
raise IOError(errno.EPERM, "Permission denied.")
|
raise IOError(errno.EPERM, "Permission denied.")
|
||||||
|
@ -1473,7 +1473,7 @@ class nodefd_content(StringIO, node_descriptor):
|
||||||
elif mode == 'a':
|
elif mode == 'a':
|
||||||
StringIO.__init__(self, None)
|
StringIO.__init__(self, None)
|
||||||
else:
|
else:
|
||||||
_logger.error("Incorrect mode %s specified", mode)
|
_logger.error("Incorrect mode %s is specified.", mode)
|
||||||
raise IOError(errno.EINVAL, "Invalid file mode!")
|
raise IOError(errno.EINVAL, "Invalid file mode!")
|
||||||
self.mode = mode
|
self.mode = mode
|
||||||
|
|
||||||
|
@ -1499,7 +1499,7 @@ class nodefd_content(StringIO, node_descriptor):
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
cr.commit()
|
cr.commit()
|
||||||
except Exception:
|
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
|
raise
|
||||||
finally:
|
finally:
|
||||||
cr.close()
|
cr.close()
|
||||||
|
@ -1527,7 +1527,7 @@ class nodefd_static(StringIO, node_descriptor):
|
||||||
elif mode == 'a':
|
elif mode == 'a':
|
||||||
StringIO.__init__(self, None)
|
StringIO.__init__(self, None)
|
||||||
else:
|
else:
|
||||||
_logger.error("Incorrect mode %s specified", mode)
|
_logger.error("Incorrect mode %s is specified.", mode)
|
||||||
raise IOError(errno.EINVAL, "Invalid file mode!")
|
raise IOError(errno.EINVAL, "Invalid file mode!")
|
||||||
self.mode = mode
|
self.mode = mode
|
||||||
|
|
||||||
|
@ -1552,7 +1552,7 @@ class nodefd_static(StringIO, node_descriptor):
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
cr.commit()
|
cr.commit()
|
||||||
except Exception:
|
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
|
raise
|
||||||
finally:
|
finally:
|
||||||
cr.close()
|
cr.close()
|
||||||
|
|
|
@ -104,7 +104,7 @@ class DocIndex(indexer):
|
||||||
except OSError:
|
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.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
|
return False
|
||||||
|
|
||||||
cntIndex.register(DocIndex())
|
cntIndex.register(DocIndex())
|
||||||
|
|
|
@ -81,7 +81,7 @@ class abstracted_fs(object):
|
||||||
self.db_name_list.append(db_name)
|
self.db_name_list.append(db_name)
|
||||||
cr.commit()
|
cr.commit()
|
||||||
except Exception:
|
except Exception:
|
||||||
self._log.warning('Cannot use db "%s"', db_name)
|
self._log.warning('Cannot use db "%s".', db_name)
|
||||||
finally:
|
finally:
|
||||||
if cr is not None:
|
if cr is not None:
|
||||||
cr.close()
|
cr.close()
|
||||||
|
@ -143,33 +143,33 @@ class abstracted_fs(object):
|
||||||
child = node.child(cr, objname)
|
child = node.child(cr, objname)
|
||||||
if child:
|
if child:
|
||||||
if child.type not in ('file','content'):
|
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)
|
ret = child.open_data(cr, mode)
|
||||||
cr.commit()
|
cr.commit()
|
||||||
assert ret, "Cannot create descriptor for %r: %r" % (child, ret)
|
assert ret, "Cannot create descriptor for %r: %r." % (child, ret)
|
||||||
return ret
|
return ret
|
||||||
except EnvironmentError:
|
except EnvironmentError:
|
||||||
raise
|
raise
|
||||||
except Exception:
|
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
|
pass
|
||||||
|
|
||||||
try:
|
try:
|
||||||
child = node.create_child(cr, objname, data=None)
|
child = node.create_child(cr, objname, data=None)
|
||||||
ret = child.open_data(cr, mode)
|
ret = child.open_data(cr, mode)
|
||||||
assert ret, "cannot create descriptor for %r" % child
|
assert ret, "Cannot create descriptor for %r." % child
|
||||||
cr.commit()
|
cr.commit()
|
||||||
return ret
|
return ret
|
||||||
except EnvironmentError:
|
except EnvironmentError:
|
||||||
raise
|
raise
|
||||||
except Exception:
|
except Exception:
|
||||||
self._log.exception('Cannot create item %s at node %s', objname, repr(node))
|
self._log.exception('Cannot create item %s at node %s.', objname, repr(node))
|
||||||
raise OSError(1, 'Operation not permited.')
|
raise OSError(1, 'Operation is not permitted.')
|
||||||
|
|
||||||
def open(self, datacr, mode):
|
def open(self, datacr, mode):
|
||||||
if not (datacr and datacr[1]):
|
if not (datacr and datacr[1]):
|
||||||
raise OSError(1, 'Operation not permited.')
|
raise OSError(1, 'Operation is not permitted.')
|
||||||
# Reading operation
|
# Reading operation
|
||||||
cr, node, rem = datacr
|
cr, node, rem = datacr
|
||||||
try:
|
try:
|
||||||
|
@ -211,7 +211,7 @@ class abstracted_fs(object):
|
||||||
self.cwd_node = None
|
self.cwd_node = None
|
||||||
return None
|
return None
|
||||||
if not datacr[1]:
|
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'):
|
if datacr[1].type not in ('collection','database'):
|
||||||
raise OSError(2, 'Path is not a directory.')
|
raise OSError(2, 'Path is not a directory.')
|
||||||
self.cwd = '/'+datacr[1].context.dbname + '/'
|
self.cwd = '/'+datacr[1].context.dbname + '/'
|
||||||
|
@ -223,7 +223,7 @@ class abstracted_fs(object):
|
||||||
"""Create the specified directory."""
|
"""Create the specified directory."""
|
||||||
cr, node, rem = datacr or (None, None, None)
|
cr, node, rem = datacr or (None, None, None)
|
||||||
if not node:
|
if not node:
|
||||||
raise OSError(1, 'Operation not permited.')
|
raise OSError(1, 'Operation is not permitted.')
|
||||||
|
|
||||||
try:
|
try:
|
||||||
basename =_to_unicode(basename)
|
basename =_to_unicode(basename)
|
||||||
|
@ -231,8 +231,8 @@ class abstracted_fs(object):
|
||||||
self._log.debug("Created child dir: %r", cdir)
|
self._log.debug("Created child dir: %r", cdir)
|
||||||
cr.commit()
|
cr.commit()
|
||||||
except Exception:
|
except Exception:
|
||||||
self._log.exception('Cannot create dir "%s" at node %s', basename, repr(node))
|
self._log.exception('Cannot create dir "%s" at node %s.', basename, repr(node))
|
||||||
raise OSError(1, 'Operation not permited.')
|
raise OSError(1, 'Operation is not permitted.')
|
||||||
|
|
||||||
def close_cr(self, data):
|
def close_cr(self, data):
|
||||||
if data and data[0]:
|
if data and data[0]:
|
||||||
|
@ -290,7 +290,7 @@ class abstracted_fs(object):
|
||||||
raise IOError(errno.EPERM, 'Cannot perform operation at root directory.')
|
raise IOError(errno.EPERM, 'Cannot perform operation at root directory.')
|
||||||
dbname = p_parts[0]
|
dbname = p_parts[0]
|
||||||
if dbname not in self.db_list():
|
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:
|
try:
|
||||||
db = pooler.get_db(dbname)
|
db = pooler.get_db(dbname)
|
||||||
except Exception:
|
except Exception:
|
||||||
|
@ -303,7 +303,7 @@ class abstracted_fs(object):
|
||||||
raise
|
raise
|
||||||
if not uid:
|
if not uid:
|
||||||
cr.close()
|
cr.close()
|
||||||
raise OSError(2, 'Authentification Required.')
|
raise OSError(2, 'Authentification is Required!')
|
||||||
n = get_node_context(cr, uid, {})
|
n = get_node_context(cr, uid, {})
|
||||||
node = n.get_uri(cr, p_parts[1:])
|
node = n.get_uri(cr, p_parts[1:])
|
||||||
return (cr, node, rem_path)
|
return (cr, node, rem_path)
|
||||||
|
@ -375,7 +375,7 @@ class abstracted_fs(object):
|
||||||
return self.rmdir(datacr)
|
return self.rmdir(datacr)
|
||||||
elif datacr[1].type == 'file':
|
elif datacr[1].type == 'file':
|
||||||
return self.rmfile(datacr)
|
return self.rmfile(datacr)
|
||||||
raise OSError(1, 'Operation not permited.')
|
raise OSError(1, 'Operation is not permitted.')
|
||||||
|
|
||||||
def rmfile(self, datacr):
|
def rmfile(self, datacr):
|
||||||
"""Remove the specified file."""
|
"""Remove the specified file."""
|
||||||
|
@ -399,8 +399,8 @@ class abstracted_fs(object):
|
||||||
except EnvironmentError:
|
except EnvironmentError:
|
||||||
raise
|
raise
|
||||||
except Exception:
|
except Exception:
|
||||||
self._log.exception('Cannot rename "%s" to "%s" at "%s"', src, datacr[2], datacr[1])
|
self._log.exception('Cannot rename "%s" to "%s" at "%s".', src, datacr[2], datacr[1])
|
||||||
raise OSError(1,'Operation not permited.')
|
raise OSError(1,'Operation is not permitted.')
|
||||||
|
|
||||||
def stat(self, node):
|
def stat(self, node):
|
||||||
raise NotImplementedError()
|
raise NotImplementedError()
|
||||||
|
|
|
@ -302,16 +302,16 @@ class DummyAuthorizer:
|
||||||
provide customized response strings when user log-in and quit.
|
provide customized response strings when user log-in and quit.
|
||||||
"""
|
"""
|
||||||
if self.has_user(username):
|
if self.has_user(username):
|
||||||
raise AuthorizerError('User "%s" already exists' %username)
|
raise AuthorizerError('User "%s" already exists!' %username)
|
||||||
homedir = os.path.realpath(homedir)
|
homedir = os.path.realpath(homedir)
|
||||||
if not os.path.isdir(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:
|
for p in perm:
|
||||||
if p not in 'elradfmw':
|
if p not in 'elradfmw':
|
||||||
raise AuthorizerError('No such permission: "%s"' %p)
|
raise AuthorizerError('No such permission: "%s"!' %p)
|
||||||
for p in perm:
|
for p in perm:
|
||||||
if (p in self.write_perms) and (username == 'anonymous'):
|
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)
|
RuntimeWarning)
|
||||||
break
|
break
|
||||||
dic = {'pwd': str(password),
|
dic = {'pwd': str(password),
|
||||||
|
@ -532,7 +532,7 @@ class ActiveDTP(asyncore.dispatcher):
|
||||||
try:
|
try:
|
||||||
self.connect((ip, port))
|
self.connect((ip, port))
|
||||||
except socket.gaierror:
|
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()
|
self.close()
|
||||||
|
|
||||||
# --- connection / overridden
|
# --- connection / overridden
|
||||||
|
@ -542,14 +542,14 @@ class ActiveDTP(asyncore.dispatcher):
|
||||||
|
|
||||||
def handle_connect(self):
|
def handle_connect(self):
|
||||||
"""Called when connection is established."""
|
"""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
|
# delegate such connection to DTP handler
|
||||||
handler = self.cmd_channel.dtp_handler(self.socket, self.cmd_channel)
|
handler = self.cmd_channel.dtp_handler(self.socket, self.cmd_channel)
|
||||||
self.cmd_channel.data_channel = handler
|
self.cmd_channel.data_channel = handler
|
||||||
self.cmd_channel.on_dtp_connection()
|
self.cmd_channel.on_dtp_connection()
|
||||||
|
|
||||||
def handle_expt(self):
|
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()
|
self.close()
|
||||||
|
|
||||||
def handle_error(self):
|
def handle_error(self):
|
||||||
|
@ -562,7 +562,7 @@ class ActiveDTP(asyncore.dispatcher):
|
||||||
pass
|
pass
|
||||||
except:
|
except:
|
||||||
logerror(traceback.format_exc())
|
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()
|
self.close()
|
||||||
|
|
||||||
class DTPHandler(asyncore.dispatcher):
|
class DTPHandler(asyncore.dispatcher):
|
||||||
|
@ -767,7 +767,7 @@ class DTPHandler(asyncore.dispatcher):
|
||||||
# some other exception occurred; we don't want to provide
|
# some other exception occurred; we don't want to provide
|
||||||
# confidential error messages
|
# confidential error messages
|
||||||
logerror(traceback.format_exc())
|
logerror(traceback.format_exc())
|
||||||
error = "Internal error"
|
error = "Internal error!"
|
||||||
self.cmd_channel.respond("426 %s; transfer aborted." %error)
|
self.cmd_channel.respond("426 %s; transfer aborted." %error)
|
||||||
self.close()
|
self.close()
|
||||||
|
|
||||||
|
@ -1485,7 +1485,7 @@ class FTPHandler(asynchat.async_chat):
|
||||||
buflimit = 2048
|
buflimit = 2048
|
||||||
if self.in_buffer_len > buflimit:
|
if self.in_buffer_len > buflimit:
|
||||||
self.respond('500 Command too long.')
|
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 = []
|
||||||
self.in_buffer_len = 0
|
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
|
# let's check if user provided an argument for those commands
|
||||||
# needing one
|
# needing one
|
||||||
if not arg and cmd in self.arg_cmds:
|
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
|
return
|
||||||
|
|
||||||
# let's do the same for those commands requiring no argument.
|
# let's do the same for those commands requiring no argument.
|
||||||
elif arg and cmd in self.unarg_cmds:
|
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
|
return
|
||||||
|
|
||||||
# provide a limited set of commands if user isn't
|
# provide a limited set of commands if user isn't
|
||||||
|
@ -1617,7 +1617,7 @@ class FTPHandler(asynchat.async_chat):
|
||||||
else:
|
else:
|
||||||
self.in_buffer.append(data)
|
self.in_buffer.append(data)
|
||||||
return
|
return
|
||||||
self.log("Can't handle OOB data.")
|
self.log("Cannot handle OOB data.")
|
||||||
self.close()
|
self.close()
|
||||||
|
|
||||||
def handle_error(self):
|
def handle_error(self):
|
||||||
|
@ -1801,7 +1801,7 @@ class FTPHandler(asynchat.async_chat):
|
||||||
except NotImplementedError, err:
|
except NotImplementedError, err:
|
||||||
cmdname = function.__name__
|
cmdname = function.__name__
|
||||||
why = err.args[0] or 'Not implemented'
|
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)
|
self.respond('502 %s.' %why)
|
||||||
raise FTPExceptionSent(why)
|
raise FTPExceptionSent(why)
|
||||||
except EnvironmentError, err:
|
except EnvironmentError, err:
|
||||||
|
@ -1811,7 +1811,7 @@ class FTPHandler(asynchat.async_chat):
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
ret_code = eresp.get(err.errno, '451')
|
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.log('FAIL %s() %s errno=%s: %s.' %(cmdname, uline, err.errno, why))
|
||||||
self.respond('%s %s.' % (str(ret_code), why))
|
self.respond('%s %s.' % (str(ret_code), why))
|
||||||
|
|
||||||
|
@ -1841,15 +1841,15 @@ class FTPHandler(asynchat.async_chat):
|
||||||
if ip != self.remote_ip:
|
if ip != self.remote_ip:
|
||||||
self.log("Rejected data connection to foreign address %s:%s."
|
self.log("Rejected data connection to foreign address %s:%s."
|
||||||
%(ip, port))
|
%(ip, port))
|
||||||
self.respond("501 Can't connect to a foreign address.")
|
self.respond("501 Cannot connect to a foreign address.")
|
||||||
return
|
return
|
||||||
|
|
||||||
# ...another RFC-2577 recommendation is rejecting connections
|
# ...another RFC-2577 recommendation is rejecting connections
|
||||||
# to privileged ports (< 1024) for security reasons.
|
# to privileged ports (< 1024) for security reasons.
|
||||||
if not self.permit_privileged_ports:
|
if not self.permit_privileged_ports:
|
||||||
if port < 1024:
|
if port < 1024:
|
||||||
self.log('PORT against the privileged port "%s" refused.' %port)
|
self.log('PORT against the privileged port "%s" has been refused.' %port)
|
||||||
self.respond("501 Can't connect over a privileged port.")
|
self.respond("501 Cannot connect over a privileged port.")
|
||||||
return
|
return
|
||||||
|
|
||||||
# close existent DTP-server instance, if any.
|
# 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
|
# make sure we are not hitting the max connections limit
|
||||||
if self.server.max_cons:
|
if self.server.max_cons:
|
||||||
if len(self._map) >= 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.respond("425 %s" %msg)
|
||||||
self.log(msg)
|
self.log(msg)
|
||||||
return
|
return
|
||||||
|
@ -2150,7 +2150,7 @@ class FTPHandler(asynchat.async_chat):
|
||||||
datacr = self.get_crdata2(line, mode='list')
|
datacr = self.get_crdata2(line, mode='list')
|
||||||
# RFC-3659 requires 501 response code if path is not a directory
|
# RFC-3659 requires 501 response code if path is not a directory
|
||||||
if not self.fs.isdir(datacr[1]):
|
if not self.fs.isdir(datacr[1]):
|
||||||
err = 'No such directory'
|
err = 'No such directory!'
|
||||||
self.log('FAIL MLSD "%s". %s.' %(line, err))
|
self.log('FAIL MLSD "%s". %s.' %(line, err))
|
||||||
self.respond("501 %s." %err)
|
self.respond("501 %s." %err)
|
||||||
return
|
return
|
||||||
|
@ -2191,7 +2191,7 @@ class FTPHandler(asynchat.async_chat):
|
||||||
fd.seek(self.restart_position)
|
fd.seek(self.restart_position)
|
||||||
ok = 1
|
ok = 1
|
||||||
except AssertionError:
|
except AssertionError:
|
||||||
why = "Invalid REST parameter"
|
why = "Invalid REST parameter!"
|
||||||
except IOError, err:
|
except IOError, err:
|
||||||
why = _strerror(err)
|
why = _strerror(err)
|
||||||
self.restart_position = 0
|
self.restart_position = 0
|
||||||
|
@ -2240,7 +2240,7 @@ class FTPHandler(asynchat.async_chat):
|
||||||
fd.seek(self.restart_position)
|
fd.seek(self.restart_position)
|
||||||
ok = 1
|
ok = 1
|
||||||
except AssertionError:
|
except AssertionError:
|
||||||
why = "Invalid REST parameter"
|
why = "Invalid REST parameter!"
|
||||||
except IOError, err:
|
except IOError, err:
|
||||||
why = _strerror(err)
|
why = _strerror(err)
|
||||||
self.restart_position = 0
|
self.restart_position = 0
|
||||||
|
@ -2275,7 +2275,7 @@ class FTPHandler(asynchat.async_chat):
|
||||||
|
|
||||||
# watch for STOU preceded by REST, which makes no sense.
|
# watch for STOU preceded by REST, which makes no sense.
|
||||||
if self.restart_position:
|
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
|
return
|
||||||
|
|
||||||
|
|
||||||
|
@ -2296,7 +2296,7 @@ class FTPHandler(asynchat.async_chat):
|
||||||
# hitted the max number of tries to find out file with
|
# hitted the max number of tries to find out file with
|
||||||
# unique name
|
# unique name
|
||||||
if err.errno == errno.EEXIST:
|
if err.errno == errno.EEXIST:
|
||||||
why = 'No usable unique file name found'
|
why = 'No usable unique file name found.'
|
||||||
# something else happened
|
# something else happened
|
||||||
else:
|
else:
|
||||||
why = _strerror(err)
|
why = _strerror(err)
|
||||||
|
@ -2307,9 +2307,9 @@ class FTPHandler(asynchat.async_chat):
|
||||||
|
|
||||||
filename = line
|
filename = line
|
||||||
if not self.authorizer.has_perm(self.username, 'w', filename):
|
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.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)
|
self.fs.close_cr(datacr)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -2329,7 +2329,7 @@ class FTPHandler(asynchat.async_chat):
|
||||||
"""Append data to an existing file on the server."""
|
"""Append data to an existing file on the server."""
|
||||||
# watch for APPE preceded by REST, which makes no sense.
|
# watch for APPE preceded by REST, which makes no sense.
|
||||||
if self.restart_position:
|
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:
|
else:
|
||||||
self.ftp_STOR(line, mode='a')
|
self.ftp_STOR(line, mode='a')
|
||||||
|
|
||||||
|
@ -2405,7 +2405,7 @@ class FTPHandler(asynchat.async_chat):
|
||||||
# and account information already supplied and beginning the
|
# and account information already supplied and beginning the
|
||||||
# login sequence again.
|
# login sequence again.
|
||||||
self.flush_account()
|
self.flush_account()
|
||||||
msg = 'Previous account information was flushed'
|
msg = 'Previous account information is flushed.'
|
||||||
self.log('OK USER "%s". %s.' %(line, msg))
|
self.log('OK USER "%s". %s.' %(line, msg))
|
||||||
self.respond('331 %s, send password.' %msg)
|
self.respond('331 %s, send password.' %msg)
|
||||||
self.username = line
|
self.username = line
|
||||||
|
@ -2584,7 +2584,7 @@ class FTPHandler(asynchat.async_chat):
|
||||||
try:
|
try:
|
||||||
datacr = self.get_crdata2(line, mode='delete')
|
datacr = self.get_crdata2(line, mode='delete')
|
||||||
if not datacr[1]:
|
if not datacr[1]:
|
||||||
msg = "Can't remove root directory."
|
msg = "Cannot remove root directory."
|
||||||
self.respond("553 %s" %msg)
|
self.respond("553 %s" %msg)
|
||||||
self.log('FAIL MKD "/". %s' %msg)
|
self.log('FAIL MKD "/". %s' %msg)
|
||||||
self.fs.close_cr(datacr)
|
self.fs.close_cr(datacr)
|
||||||
|
@ -2617,7 +2617,7 @@ class FTPHandler(asynchat.async_chat):
|
||||||
if not datacr[1]:
|
if not datacr[1]:
|
||||||
self.respond("550 No such file or directory.")
|
self.respond("550 No such file or directory.")
|
||||||
elif not datacr[1]:
|
elif not datacr[1]:
|
||||||
self.respond("553 Can't rename the home directory.")
|
self.respond("553 Cannot rename the home directory.")
|
||||||
else:
|
else:
|
||||||
self.fs.rnfr = datacr[1]
|
self.fs.rnfr = datacr[1]
|
||||||
self.respond("350 Ready for destination name.")
|
self.respond("350 Ready for destination name.")
|
||||||
|
@ -2760,14 +2760,14 @@ class FTPHandler(asynchat.async_chat):
|
||||||
def ftp_OPTS(self, line):
|
def ftp_OPTS(self, line):
|
||||||
"""Specify options for FTP commands as specified in RFC-2389."""
|
"""Specify options for FTP commands as specified in RFC-2389."""
|
||||||
try:
|
try:
|
||||||
assert (not line.count(' ') > 1), 'Invalid number of arguments'
|
assert (not line.count(' ') > 1), 'Invalid number of arguments!'
|
||||||
if ' ' in line:
|
if ' ' in line:
|
||||||
cmd, arg = line.split(' ')
|
cmd, arg = line.split(' ')
|
||||||
assert (';' in arg), 'Invalid argument'
|
assert (';' in arg), 'Invalid argument!'
|
||||||
else:
|
else:
|
||||||
cmd, arg = line, ''
|
cmd, arg = line, ''
|
||||||
# actually the only command able to accept options is MLST
|
# 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:
|
except AssertionError, err:
|
||||||
self.respond('501 %s.' %err)
|
self.respond('501 %s.' %err)
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in New Issue